Python Forum

Full Version: Value error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
for data in alldata:
    if (data['Familysize']==1):
        data['isalone']=1
What is the error in this simple code?

Error:
ValueError Traceback (most recent call last) <ipython-input-20-853203b87769> in <module> 1 for data in alldata: ----> 2 if (data['Familysize']==1): 3 data['isalone']=1 ~\Anaconda3\lib\site-packages\pandas\core\generic.py in __nonzero__(self) 1553 "The truth value of a {0} is ambiguous. " 1554 "Use a.empty, a.bool(), a.item(), a.any() or a.all().".format( -> 1555 self.__class__.__name__ 1556 ) 1557 ) ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
please post your all relevant source code
Check the type of data in your for loop