How to get the median of a column based on another column value using Pandas?
Try this:
df[df['Gender']=='Woman']['ConvertedComp'].median()
How can I get the median  of ConvertedComp column for all Gender = 'Woman' from this Pandas dataframe (It only shows 'Man' because I'm only showing df.head(10)):





ConvertedComp
Gender




0
61000.0
Man


1
95179.0
Man


2
90000.0
Man


3
455452.0
Man


4
65277.0
Man


5
31140.0
Man


6
41244.0
Man


7
103000.0
Man


8
69000.0
Man


9
26388.0
Man