9951 explained code solutions for 126 technologies


python-pandasHow to find dataframe mean


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.mean()ctrl + c
import pandas as pd

load Pandas module

pd.DataFrame

creates Pandas DataFrame object

.mean()

finds mean for all numeric columns of a dataframe

result

series with resulting values