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?

I tried

df.xs('rowlabel') /= df.xs('rowlabel').max() 

as I'd do on a numpy array, but it didn't work.

Answers


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)

Need Your Help

How can I get unique members per category using perl?

perl hash unique

I used a hash to store members id. I avoid the duplicity using the following validation:

Rails Controller Query

ruby-on-rails controller

I am trying to display a list of users on a page based on an attribute of the current user. If the current user has its instance variable called :position as "High School" list all the users with the

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.