I have a pandas dataframe exported to CSV, storing an index, username, and a string specific to the user. I want a function to edit the string of the user if they already exist in the database, and create a user if they don't. For example:
,User,String
0,Bob,Bob Is Cool
1,Joe,Joe Is Great
Adding Joe
and Joe is Smart
will make it:
,User,String
0,Bob,Bob Is Cool
1,Joe,Joe Is Smart
Adding Jeff
and Jeff is Good
will make it:
,User,String
0,Bob,Bob Is Cool
1,Joe,Joe Is Smart
2,Jeff,Jeff is Good
I tried using in
. For Example:
if user in df.User:
if user in df.values:
And so on but I can't seem to get it to work. It always adds a new entry no matter what.
Any help is appreciated. Thanks in Advance!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…