jeudi 31 décembre 2020

Issue with IF statement not following condition

I am reading data from a .csv file with columns having values as "TRUE" or "FALSE". My code sample is as of below. The value reads out to be "FALSE" in the list index but when I run same in loop the failed condition result is printed. If I change the 1st value of each column being read from FALSE or TRUE to any other letter then the loop runs fine.

import pandas as  pd


df = pd.read_csv('File Link')


headers = df.columns # Getting Headers from File

print (df['Sushi'][0]) #prints "False"

if df['Sushi'][0] == str('False'):
    print ('yes')

else:
    print ('not working') #prints not working even though the value is False

Aucun commentaire:

Enregistrer un commentaire