User_id name 1 2 3 4 5
100 a 10 0. 12 0. 0
200. d 0 0. 11 0. 0
300. c. 0 0. 11 0. 0
I want to apply cummax log from day 1 column on row level axis=1
I have tried model_cluster_one.loc[:, 'day1':'day5 '].cummax(axis=1)
but it doesn't work and make the changes to the data frame what am I missing here
I think you need assign output back:
model_cluster_one.loc[:, 'day1':'day5 '] = model_cluster_one.loc[:, 'day1':'day5 '].cummax(axis=1)
Or filter columns by positions with DataFrame.iloc and assign back:
model_cluster_one.iloc[:, 2:] = model_cluster_one.iloc[:, 2:].cummax(axis=1)
print (model_cluster_one)
User_id name 1 2 3 4 5
0 100 a 10.0 10.0 12.0 12.0 12.0
1 200 d 0.0 0.0 11.0 11.0 11.0
2 201 c 0.0 0.0 11.0 11.0 11.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With