My dataframe looks like this orders_total
:
price amount side
0 0.003019 100 bids
0 0.003143 100 asks
When I try t
You're attempting to modify in-place when you really are ending up with a copy
of the dataframe, not a view, and hence the original dataframe remains unchanged. This is known as chained indexing.
To find out more on this check: Returning a view versus a copy.
You want to index along both axis using .loc
. This will lead to a single call to __getitem__
which will return a view of the dataframe, and changes to this view will be reflected on the original dataframe:
orders_total.loc[orders_total.side == 'asks', 'amount'] -= 10