Skip to content Skip to sidebar Skip to footer

Normalizing .csv Labelled File Using Pandas In Python

I was normalizing the .csv (labelled) and i was following the answer given on this link: Normalize data in pandas So, my question is how do i preserve labels and normalize the data

Solution 1:

try this:

df_norm = (df.ix[:, 0:-1] - df.ix[:, 0:-1].mean()) / (df.ix[:, 0:-1].max() - df.ix[:, 0:-1].min())

and then add your label column:

rslt =  pd.concat([df_norm, df.ix[:, -1]], axis=1)

Post a Comment for "Normalizing .csv Labelled File Using Pandas In Python"