I want to apply below calculations to only rows that meet certain criteria.
i.e where snapshot column = '2021-02-02'
df['numerator']/df['denominator']
how do I do that?
CodePudding user response:
IIUC use:
m = df['snapshot'] == '2021-02-02'
df.loc[m, 'new'] = df['numerator']/df['denominator']