9951 explained code solutions for 126 technologies


python-pandasHow to find dataframe median


import pandas as pd

df = pd.DataFrame({
  'phone': ['ip5', 'ip6', 'ip8', 'sms', 'xi'],
  'price': [204, 304, 404, 405, 305],
  'size':  [100, 101, 101, 99, 95]
})

result = df.median()ctrl + c
import pandas as pd

load Pandas module

pd.DataFrame

creates Pandas DataFrame object

.median()

finds median values for all numeric columns of a dataframe

result

series with resulting values