user_id date type transaction_part_sum transaction_part_count
1000616411022604 2011-12-20 debit 51.58 1
1000616411022604 2013-06-10 debit 25.52 1
1000616411022604 2013-11-07 credit 533.29 1
1000616411022604 2013-12-26 debit 3.82 1
1000616411022604 2013-12-31 credit 259.68 1
1000616411022604 2014-01-02 debit 79.10 1
1000616411022604 2014-02-25 debit 9.99 1
1000616411022604 2014-03-26 debit 3.42 1
1000616411022604 2014-04-02 debit 71.90 1
In a pandas DataFrame as shown above, I want to change the debit row of the "transaction_part_sum" to negative value.
I did this
grouped.loc[grouped['type'] == 'debit', 'transaction_part_sum'] = -1 * grouped['transaction_part_sum']
but when printing grouped. The values in the debit row don't get populated. If I multiply with any other positive number I get the values populated. How can I change the debit row to negative value?
output:
user_id date type transaction_part_sum transaction_part_count
1000616411022604 2011-12-20 debit 1
1000616411022604 2013-06-10 debit 1
1000616411022604 2013-11-07 credit 533.29 1
1000616411022604 2013-12-26 debit 1
1000616411022604 2013-12-31 credit 259.68 1
1000616411022604 2014-01-02 debit 1
1000616411022604 2014-02-25 debit 1
1000616411022604 2014-03-26 debit 1
1000616411022604 2014-04-02 debit 1