I'm trying to resample my dataset after splitting it into train and test partitions using SMOTE. Here's my code: smote_X = df[cols] smote_Y = df[target_col] #Split train and test data smote_train_X,smote_test_X,smote_train_Y,smote_test_Y = train_test_split(smote_X,smote_Y,test_size = .25,random_state = 111) smote_train_Y_series = smote_train_Y.iloc[:,0] #oversampling minority class using smote os = SMOTE(random_state = 0) os_smote_X,os_smote_Y = os.fit_sample(smote_train_X,smote_train_Y_series) I added line #5 to convert the DataFrame coming out of `train_test_split` to Series as the newer version of SMOTE `fit_sample` ([docs][1]) wants this data type but it now throws the following error. Any ideas how to fix it? > -------------------------------------------------------------------------- KeyError Traceback (most recent call > last) <ipython-input-96-789bdf3598bf> in <module> > 16 #oversampling minority class using smote > 17 os = SMOTE(random_state = 0) > ---> 18 os_smote_X,os_smote_Y = os.fit_sample(smote_train_X,smote_train_Y_series) > 19 os_smote_X = pd.DataFrame(data = os_smote_X,columns=cols) > 20 os_smote_Y = pd.DataFrame(data = os_smote_Y,columns=target_col) > > /opt/conda/lib/python3.6/site-packages/imblearn/base.py in > fit_resample(self, X, y) > 86 if self._X_columns is not None: > 87 X_ = pd.DataFrame(output[0], columns=self._X_columns) > ---> 88 X_ = X_.astype(self._X_dtypes) > 89 else: > 90 X_ = output[0] > > /opt/conda/lib/python3.6/site-packages/pandas/core/generic.py in > astype(self, dtype, copy, errors, **kwargs) 5863 > results.append( 5864 col.astype( > -> 5865 dtype=dtype[col_name], copy=copy, errors=errors, **kwargs 5866 ) 5867 > ) > > /opt/conda/lib/python3.6/site-packages/pandas/core/generic.py in > astype(self, dtype, copy, errors, **kwargs) 5846 if > len(dtype) > 1 or self.name not in dtype: 5847 > raise KeyError( > -> 5848 "Only the Series name can be used for " 5849 "the key in Series dtype mappings." > 5850 ) > > KeyError: 'Only the Series name can be used for the key in Series > dtype mappings.' [1]: https://imbalanced-learn.readthedocs.io/en/stable/generated/imblearn.over_sampling.SMOTE.html#imblearn.over_sampling.SMOTE.fit_sample