Find the total number of visits of the bird Cranes?
Program:
import pandas as pd
import numpy as np
df = pd.DataFrame({'birds': ['Cranes', 'Cranes', 'plovers', 'spoonbills', 'spoonbills', 'Cranes', 'plovers', 'Cranes', 'spoonbills', 'spoonbills'], 'age': [3.5, 4, 1.5, np.nan, 6, 3, 5.5, np.nan, 8, 4], 'visits': [2, 4, 3, 4, 3, 4, 2, 2, 3, 2], 'priority': ['yes', 'yes', 'no', 'yes', 'no', 'no', 'no', 'yes', 'no', 'no']})
g=df.groupby(['birds','visits']).sum()
g
OUTPUT:
        age
birds   visits  
Cranes     2    3.5
           4    7.0
plovers    2    5.5
           3    1.5
spoonbills 2    4.0
           3    14.0
           4    0.0
Desired Output:
birds   visits
Cranes    2
Cranes    4
Cranes    4
Cranes    2
Total    12
Also let me know how to remove the age column which is coming?
If i try using groupby also other columns are coming and the result is not clear
 
     
    