Answers for "if and throug pandas dataframe"

7

pandas if python

df['new column name'] = df['column name'].apply(lambda x: 'value if condition is met' if x condition else 'value if condition is not met')
Posted by: Guest on January-21-2021
3

if condition dataframe python

df.loc[df['age1'] - df['age2'] > 0, 'diff'] = df['age1'] - df['age2']
Posted by: Guest on May-20-2020

Python Answers by Framework

Browse Popular Code Answers by Language