data: DataFrame values: Columns to aggregate index: columns or grouper columns: columns or grouper aggfunc: defalut numpy.mean , functions fill_value: replace missing value margins : bool, default False, subtotal grand total dropna: bool , default True , remove columns if all are NaN. observed bool, default false
This is our sample DataFrame and we created by using sales.csv file or use this
Using this DataFrame we will use the method pivot_table()
Here we are getting the average value of quantity ( qty ) against each product. By using aggfunc we can get sum, max, min value. Here we used one single column product as index.
default value for aggfunc is mean ( np.mean) , we can specify others line sum , max , min etc or use numpy function ( import numpy before using numpy functions). Here we are using sum to get the sum of quanity ( qty ) column.