I am using the following code to create a new column whose value is derived based on the values in two other columns of my Python dataframe.
# Create a list to store the data
MSP = []
for row in df_EVENT5_18['FLT']:
if df_EVENT5_18['FLT'].str.contains('1234') & df_EVENT5_18['AR'].str.contains('ABC1'):
MSP.append(29)
elif (df_EVENT5_18['FLT'].str.contains('1234')) & (df_EVENT5_18['AR'].str.contains('ABC2')):
MSP.append(25)
else:
MSP.append('')
# Create a new column from the list
df_EVENT5_18['MSP'] = MSP
When I run the above code, I get the following error:
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Aucun commentaire:
Enregistrer un commentaire