atan1 / DataAnalysis_Capstone_MuscleHub_AlfredTan

0 stars 0 forks source link

Alternative methods to working with null values in pandas dataframe #1

Open JagaRamesh opened 6 years ago

JagaRamesh commented 6 years ago

I noticed that you have used the following command to identify NULL, which is not wrong. df['ab_test_group'] = df.fitness_test_date.apply(lambda x: 'B' if x == None else 'A')

I would like you to be aware of the following alternative methods : df['ab_test_group'] = df.fitness_test_date.apply(lambda x: 'A' if pd.notnull(x) else 'B')

df['ab_test_group'] = df.fitness_test_date.apply(lambda x: 'B' if pd.isnull(x) else 'A')

atan1 commented 6 years ago

Thanks Jaga for pointing this out. There is definitely lots of APIs to know about :-)