0

I have a dataframe return from a SQL

assuming

df="the data frame value of the sql result" . # the sql is ```select 2```

print(df) #return 0    2

print(type(df))  #return <class 'pandas.core.series.Series'>

then i want to make an if logic to see if the this data frame value equals to 2 or not. I have tried many ways but nothing works

if df.astype(str) == str(2):

  do something

else:

  do others

errors

ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

Any good way to do so? Thank you!

Chubaka
  • 2,933
  • 7
  • 43
  • 58

0 Answers0