1

I have seen other questions on the 'ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().' but they seem to be related to boolean operators. Mine is not, so hopefully is allowed.

I have a dataframe ev_df which contains 4 columns of different values. I am trying to make a new column which is the minimum of either my 'Useable_battery' column or 'Constraint' column with the following code:

ev_df['Constrained_useable_battery'] = min(ev_df['Useable_battery'], ev_df['Constraint'])

However, whenever I run this I get the 'ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().' and cannot work out why. The line of code works with int values in place of the df columns, so I'm guessing the issue is something to do with the way the code is reading my columns, but cannot work out why. Both the 'Useable_battery' and 'Constraint' columns are of dtype float.64

CJ90
  • 99
  • 1
  • 10

0 Answers0