jeudi 8 juin 2017

String startswith a particular text

I'm trying to read a csv file and I've to do column operations based on some condition. Its completely ignoring my if condition and executes else statement. Its a pain after lot of troubleshooting, i'm unable to rectify it.

Here is the code:
Tweet is my column name for tweets...

    inf = pd.read_csv('string.csv')
for r in inf : 
    if "RT @" in inf.Tweet :   
        inf["Engagements"] = 0  
    else : 
        inf["Engagements"] = inf["Favorite_Count"] + inf["Retweet_Count"]

inf.to_csv('string2.csv', index=False)

Aucun commentaire:

Enregistrer un commentaire