The code I used to create the column is returning with the following error:
The truth value of a series is ambiguous. Use a.empty, a.bool (), a.item (), a.any () or a.all ().
I do not know how to resolve this error.
import pandas as pd
import numpy as np
raw_data = {'regiment': ['Nighthawks', 'Nighthawks', 'Nighthawks', 'Nighthawks'],
'company': ['1st', '1st', '2nd', '2nd'],
'deaths': ['kkk', 52, '25', 616],
'battles': [5, 42, 2, 2],
'size': ['l', 'll', 'l', 'm']}
df = pd.DataFrame(raw_data, columns = ['regiment', 'company', 'deaths', 'battles', 'size'])
def valida_CEP(x):
if x < 9:
return '0' + str(x)
else:
return str(x)
df['batles_comzero'] = df.apply(valida_CEP(df['battles']),axis=1)
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().