November 27, 2019
Calculating Column Statistics
Combine all values from a column for a single calculation.
The general syntax for these calculations is:
df.column_name.command()
Some common commands:
- nunique
- unique
- mean
- std
- median
- max
- min
Calculating Aggregate Functions
.groupby
grades = df.groupby(‘student’).grade.mean()
df.groupby(‘column1’).column2.measurement()
This creates a Series not a DataFrame.
If we use reset_index, it will be changed to a DataFrame from a Series.
measurement().reset_index()
We can rename columns using:
df = df.rename(columns = {“old” : “new”})