I have the below table
A B C D 1 2 3 E 4 5 6 F 6 7 8
After fit_transform(), and converting back to dataframe, I get the below table
0 1 2 0 v1 v2 v3 1 v4 v5 v5 2 v6 v7 v8
v1-v8 some normalised values.
But I want to retain my column and row names while doing fit_transform/after converting to dataframes. I'm not getting how to do that. Please help.
Try assigning column and index of the original df to the new one by:
out_df.columns = df.columns out_df.index = df.index
df is the original dataframe;
out_df is the dataframe after fit_transform()
Note : This will work if the cell order of the dataframe i.e. rows and column are in the same order as that of original