I have the following example of code
import pandas as pd
df = pd.DataFrame({'a':[1, 2, 3],
'b':[10, 20, 30],
'c':[100, 200, 300],
'd':['q', 'w', 'r']})
Get the values of the dataframe
In [12]: df[['a', 'b', 'c']].values
Out[12]:
array([[ 1, 10, 100],
[ 2, 20, 200],
[ 3, 30, 300]])
Then i normalize the values
from sklearn.preprocessing import normalize
norm = normalize(df[['a', 'b', 'c']].values, axis=0)
In [11]: norm
Out[11]:
array([[0.26726124, 0.26726124, 0.26726124],
[0.53452248, 0.53452248, 0.53452248],
[0.80178373, 0.80178373, 0.80178373]])
Now i want to do something like
df[['a', 'b', 'c']].values = norm
But i get the error (i knew about it)
AttributeError: can't set attribute
How can i modify those values without affecting the other parts of the dataframe (i.e the column 'e' and the indices); just the values.
Thanks.