Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Value error
#1
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().
Reply
#2
please post your all relevant source code
Reply
#3
Check the type of data in your for loop
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020