Place the grouping column in the groupby method and then call the agg method with a dictionary pairing the aggregating column with its aggregating function:
Alternatively, you may place the aggregating column in the indexing operator and then pass the aggregating function as a string to agg:
>>> flights.groupby('AIRLINE')['ARR_DELAY'].agg('mean').head() AIRLINE
AA 5.542661
AS -0.833333
B6 8.692593
DL 0.339691
EV 7.034580
Name: ARR_DELAY, dtype: float64
The string names used in the previous step are a convenience pandas offers you to refer to a particular aggregation function. You can pass any aggregating function directly to the agg method such as the NumPy mean function. The output is the same as the previous step: