change the value of dataframe

linkaiyi
Follow

Change Value of a Dataframe Column Based on a Filter

df['purchase'] = 0
df.loc[df['dollars_spent'] > 0, 'purchase'] = 1
df['purchase'] = df['dollars_spent'].apply(lambda x: 1 if x > 0 else 0)
Object has 0 attachments

Was this article helpful?

This article is viewed 19 times!

0 Comments

Leave a Comment

Support