Skip to content
Advertisement

pandas dataframe add a column computing the median from the first row

I have a dataframe with a column filled with floats. I want to add a column which computes the median from the first row to the current row. I do no want to compute a rolling median but the median with all the inforamtion known ar each step.

Advertisement

Answer

You can check with expanding

df['your col'].expanding().median()
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement