Data is below (df)
id,cost,spend
1,123456,281257
2,150434,838451
3,100435,757565
4,650343,261071
5,-454236,275760
6,-547296,239225
How to get the IQR for each value
output >> id,cost,cost_IQR,spend,spend_IQR
For Z score below is my code
cols = list(df.columns)
cols.remove('id')
#df[cols]
for col in cols:
col_zscore = col + '_zscore'
df[col_zscore] = (df[col] - df[col].mean())/df[col].std(ddof=0)
Like the above code i generate the cost_zscore,spend_zscore, How to generate cost_IQR, spend_IQR