Reputation: 498
The sample of my data is as follows.
date traffic_amount factor
-----------------------------------------------
2012-01-01 613.586982 1.000000
2012-02-01 598.591841 1.107143
2012-03-01 653.042743 1.000000
2012-04-01 666.692536 1.033333
I tried to change value which has index 2012-02-01 using loc and column name. But I failed to do that. The value remained the same.
data_per_member.loc['2012-02-01']['factor'] = 31/29
print(data_per_member.loc['2012-02-01']['factor'])
1.1071428571428572
31/29 is 1.0689655172413792. So I noticed that my code 'data_per_member.loc['2012-02-01']['factor'] = 31/29' did not work. Why did not my code work?
Upvotes: 0
Views: 885
Reputation: 323276
Do not chain the loc
with []
data_per_member.loc['2012-02-01','factor'] = 31/29
Upvotes: 3