question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError: 'int' object has no attribute 'split'

See original GitHub issue

If I try this:

spectra.columns = spectra.columns.astype(str)
features = FeatureWiz(corr_limit=0.70, feature_engg='', category_encoders='', dask_xgboost_flag=False,
							nrows=None, verbose=2)
X_train_selected = features.fit_transform(spectra, mask_list)
selected_features = features.features 

I get this error message:

Imported DASK version = 0.1.00. nrows=None uses all rows. Set nrows=1000 to randomly sample fewer rows.
output = featurewiz(dataname, target, corr_limit=0.70, verbose=2, sep=',', 
		header=0, test_data='',feature_engg='', category_encoders='',
		dask_xgboost_flag=False, nrows=None)
Create new features via 'feature_engg' flag : ['interactions','groupby','target']
############################################################################################
############       F A S T   F E A T U R E  E N G G    A N D    S E L E C T I O N ! ########
# Be judicious with featurewiz. Don't use it to create too many un-interpretable features! #
############################################################################################
Skipping feature engineering since no feature_engg input...
Skipping category encoding since no category encoders specified in input...
Loading train data...
    Shape of your Data Set loaded: (26717, 788)
    Caution: We will try to reduce the memory usage of dataframe from 80.23 MB
        memory usage after optimization is: 40.16 MB
        decreased by 50.0%
     Loaded. Shape = (26717, 788)
Traceback (most recent call last):
  File "/snap/pycharm-professional/271/plugins/python/helpers/pydev/pydevd.py", line 1483, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/snap/pycharm-professional/271/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/home/saskra/PycharmProjects/bmc/bmc5.py", line 121, in <module>
    X_train_selected = features.fit_transform(spectra, mask_list)
  File "/home/saskra/anaconda3/envs/bmc/lib/python3.9/site-packages/sklearn/base.py", line 855, in fit_transform
    return self.fit(X, y, **fit_params).transform(X)
  File "/home/saskra/anaconda3/envs/bmc/lib/python3.9/site-packages/featurewiz/featurewiz.py", line 3553, in fit
    features, X_sel = featurewiz(df, target, self.corr_limit, self.verbose, self.sep, 
  File "/home/saskra/anaconda3/envs/bmc/lib/python3.9/site-packages/featurewiz/featurewiz.py", line 1029, in featurewiz
    dataname = remove_special_chars_in_names(dataname, target, verbose=1)
  File "/home/saskra/anaconda3/envs/bmc/lib/python3.9/site-packages/featurewiz/featurewiz.py", line 3586, in remove_special_chars_in_names
    sel_preds = ["_".join(x.split(" ")) for x in sel_preds]
  File "/home/saskra/anaconda3/envs/bmc/lib/python3.9/site-packages/featurewiz/featurewiz.py", line 3586, in <listcomp>
    sel_preds = ["_".join(x.split(" ")) for x in sel_preds]
AttributeError: 'int' object has no attribute 'split'
python-BaseException

The first line in my code was already a futile attempt to fix the supposed problem because the original column names in the dataframe were floating point numbers. Can anyone help?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
AutoViMLcommented, Feb 24, 2022

Hi @saskra 👍 Okay I found the problem. I need all the columns in the dataset to have a name. Since your y_train is a pd.Series without a name, it was erroring. You just have to change the code to this and re-run. That should work fine.

import numpy as np
import pandas as pd
from featurewiz import FeatureWiz

df2 = pd.read_csv('small_example_spectra.csv')
y_train = pd.Series(np.random.choice([0, 1], size=(len(df2),)),name='target')
features = FeatureWiz(corr_limit=0.70, feature_engg='', category_encoders='', dask_xgboost_flag=False, nrows=None,
					  verbose=2)
X_train_selected = features.fit_transform(df2, y_train)

Hope this is helpful. Thanks AutoViML

0reactions
saskracommented, Feb 24, 2022

Thanks a lot!

Read more comments on GitHub >

github_iconTop Results From Across the Web

AttributeError: 'int' object has no attribute 'split' - Stack Overflow
The code error says: AttributeError: 'int' object has no attribute 'split' The input is a file (given from the shell with the command: ......
Read more >
AttributeError: 'int' object has no attribute 'split' - YouTube
fixed attributeerror : ' int' object has no attribute 'split 'thanks for watching! subscribe(); to support 00110110 thank you ...
Read more >
AttributeError: 'int' object has no attribute 'split' - Reddit
AttributeError : 'int' object has no attribute 'split'. Hi! I am trying to count the items listed in each cell of a column....
Read more >
AttributeError: 'function' object has no attribute 'split'
PathList= string.split(FullPath, "/") is generating the above error message. when I run my script, but works just fine from the python command line!...
Read more >
facing an runtime python error "int object has no attribute split "
split () is a string's method, but your table contains integers.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found