I know how to apply an IF condition in Pandas DataFrame. link
However, my question is how to do the following:
if (df[df['col1'] == 0]):
sys.path.append("/desktop/folder/")
import self_module as sm
df = sm.call_function(df)
What I really want to do is when value in col1 equals to 0 then call function call_function().
def call_function(ds):
ds['new_age'] = (ds['age']* 0.012345678901).round(12)
return ds
I provide a simple example above for call_function().
df = sm.call_function(df)? Do you meandf = sm.call_function(df[df['col1']== 0]), that is, to transform only part of the data?call_function()ifdf['col1']== 0, for those not equal to 0, leavepd.NaT.