AttributeError: 'numpy.ndarray' object has no attribute 'drop' AttributeError: 'numpy.ndarray' object has no attribute 'drop' pandas pandas

AttributeError: 'numpy.ndarray' object has no attribute 'drop'


The problem lies in the following line:

df = StandardScaler().fit_transform(df) 

It returns a numpy array (see docs), which does not have a drop function. You would have to convert it into a pd.DataFrame first!

new_df = pd.DataFrame(StandardScaler().fit_transform(df), columns=df.columns, index=df.index)