0
if chapa['Service Type'] == 'Managed Services' and chapa['Term'] == 12:
chapa['payout'] * 10000

else:
     pass

ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

I am trying to change a cell (payout) based upon the conditions within its row. Not sure what the best way to do this in Pandas is. It must only be effected by its specific row.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
mcccc
  • 13
  • 4
  • Can you provide some sample data? – statnet22 Aug 02 '22 at 14:51
  • `chapa.loc[(chapa['Service Type'] == 'Managed Services') & (chapa['Term'] == 12), 'payout'] *= 1000` – mozway Aug 02 '22 at 14:52
  • @mozway I get the invalid syntax when I try to use this. Any idea why? it has a problem with the *= – mcccc Aug 02 '22 at 15:29
  • @mcccc I double checked, the syntax is valid and the command works. Please provide a fully reproducible example in your question. Note that the above code replaces the loop completely. – mozway Aug 02 '22 at 15:39

0 Answers0