Chapter 7 Aggregate Methods
Contents
Chapter 7 Aggregate Methods¶
import pandas as pd
import numpy as np
url = 'https://github.com/mattharrison/datasets/raw/master/data/vehicles.csv.zip'
df = pd.read_csv(url, usecols = ['city08'])
city_mpg = df.city08
Exercise 3¶
Find the number of unique entries of a series
city_mpg.nunique()
105
city_mpg.nunique(dropna=True)
105
Exercise 6¶
Use the .agg method to find all of the above.
city_mpg.agg(['count', 'size', 'nunique', 'mean', 'max'])
count 41144.000000
size 41144.000000
nunique 105.000000
mean 18.369045
max 150.000000
Name: city08, dtype: float64