I have the following sample code:
import pandas as pd
import numpy as np
d = {'Fruit': ['Apples', 'Oranges', 'Apples', 'Kiwi', 'Kiwi'], 'Amount':
[10, 15, 65, 5, 13]}
df = pd.DataFrame(data=d)
table = pd.pivot_table(df, index='Fruit', aggfunc= np.sum)
The table results appear like this:
Fruit Amount
Apples 75
Kiwi 18
Oranges 15
How do you add a grand total to the bottom? Also, I'd like to choose the order, example:
Fruit Amount
Oranges 15
Apples 75
Kiwi 15
Total 105
How do I go about doing this? Thanks!