Answers for "if condition for pandas datframe"

5

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
2

pandas if else

df.loc[df['column name'] condition, 'new column name'] = 'value if condition is met'
Posted by: Guest on May-10-2020

Code answers related to "if condition for pandas datframe"

Python Answers by Framework

Browse Popular Code Answers by Language