Assigning to a Row in Pandas
I need to edit rows in a pandas dataframe by dividing each value by the row.max()
what is the recommended way to do this?
df.xs('rowlabel') /= df.xs('rowlabel').max()
as I'd do on a numpy array, but it didn't work.
The syntax for a single row is:
df.ix['rowlabel'] /= df.ix['rowlabel'].max()
If you want that done on every row in the dataframe, you can use apply (with axis=1 to select rows instead of columns):
df.apply(lambda x: x / x.max(), axis=1)