I have a percentile dataframe df
as follows:
col1 col2 col3
GDStart
2019-09-02 100 11 12
2019-09-03 60 16 14
2019-09-04 60 67 13
and an external function as:
import numpy as np
def Fn(x, a):
return np.percentile(x, a)
I want to get apply my custom Fn
to each row of df
to get median for each row. I am expecting the following answer when using np.percentile(x, 50) i.e. median for each row:
col1
GDStart
2019-09-02 12
2019-09-03 16
2019-09-04 60
I am not sure how to apply the lambda
or apply
function here. My situation is tricky as I might need to find 30th percentile, or 50th percentile etc; a
changes.