Sean Girgis
asked on
Python - Pandas - DataFrame- update a column from another based on compare
#Python3.78 #Pandas #DataFrame
I have a dataframe servers.csv
I want to update rating1 from rating2 as follows: -
rating1 will be equal to rating2 when rating2 > rating1
servers.csv file
------------
Server, rating1 , rating2
'Serv1' , 500.54,
'Serv2' , , 750.21
'Serv3' , 500, 750.35
'Serv4' , 999.99, 399
outcome.csv file
------------
Server, rating1 , rating2
'Serv1' , 500.54,
'Serv2' , 750.21 , 750.21
'Serv3' , 750.35, 750.35
'Serv4' , 999.99, 399
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
what the code <<df.columns = df.columns.str.strip()>> is doing?It just strips off the whitespace of the column for my testing purpose only.
ASKER
Thanks,
this worked great., but I want to understand what the code <<df.columns = df.columns.str.strip()>> is doing?