Python Forum
Value error - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: Value error (/thread-25753.html)



Value error - jithin123 - Apr-10-2020

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().



RE: Value error - avinash8s - Apr-11-2020

please post your all relevant source code


RE: Value error - jefsummers - Apr-12-2020

Check the type of data in your for loop