datawig icon indicating copy to clipboard operation
datawig copied to clipboard

AttributeError: 'Index' object has no attribute 'contains' while using the predict method

Open aagrawal357 opened this issue 2 years ago • 5 comments


AttributeError Traceback (most recent call last) in 19 return imputed 20 ---> 21 actor1_pred = predict_missing_values(original_data, "Actor1") 22 actor1_pred

in predict_missing_values(df, col) 16 17 #Impute missing values and return original dataframe with predictions ---> 18 imputed = imputer.predict(df_test) 19 return imputed 20

~/opt/anaconda3/lib/python3.8/site-packages/datawig/simple_imputer.py in predict(self, data_frame, precision_threshold, imputation_suffix, score_suffix, inplace) 417 :return: data_frame original dataframe with imputations and likelihood in additional column 418 """ --> 419 imputations = self.imputer.predict(data_frame, precision_threshold, imputation_suffix, 420 score_suffix, inplace=inplace) 421

~/opt/anaconda3/lib/python3.8/site-packages/datawig/imputer.py in predict(self, data_frame, precision_threshold, imputation_suffix, score_suffix, inplace) 820 for label, imputations in predictions: 821 imputation_col = label + imputation_suffix --> 822 if data_frame.columns.contains(imputation_col): 823 raise ColumnOverwriteException( 824 "DataFrame contains column {}; remove column and try again".format(

AttributeError: 'Index' object has no attribute 'contains'

I saw a similar issue (#118 ) and the suggestion was to go back to pandas 0.25.0. I have pandas 1.2.4 and going back to 0.25.0 is not an option since it's deprecated. Is there a resolution or a workaround for this? Any pointers will be appreciated. Thanks!

aagrawal357 avatar Apr 01 '22 05:04 aagrawal357

Hi,

we did update the dependencies and refactored the code where needed, but I guess the code was not released on pypi yet.

You could try and install the package from source to get the latest version with:

git clone [email protected]:awslabs/datawig.git
cd datawig
python3 -m venv venv
./venv/bin/pip install -e .

felixbiessmann avatar Apr 01 '22 15:04 felixbiessmann

Thank you for your response! I'll try that and shall update you.

aagrawal357 avatar Apr 02 '22 21:04 aagrawal357

Did this work?

RDEvans31 avatar Apr 06 '22 19:04 RDEvans31

No, it didn't for me. I am getting access/security issues while doing git clone [email protected]:awslabs/datawig.git I haven't found time to investigate why.

aagrawal357 avatar Apr 06 '22 20:04 aagrawal357

Is there an answer for this yet ? And also is there by any chance that .transform return the same value as .predict but it just with reformat index and in dictionary form ? I got this problem when run it on google colab notebook but just fine when using kaggle notebook

KyleeValencia avatar Jul 06 '22 11:07 KyleeValencia