df = pd.DataFrame(np.array([[1, 2, 3, 0, 5], [1, 2, 3, 4, 5], [1, 1, 1, 6, 
    1], [1, 0, 0, 0, 0]]), columns=['a', 'b', 'c', 'd', 'q'], index=[0, 1, 
    2, 3])
df.iloc[[0, 2, 3], [0, 1, 3]].mean(axis=0)
Calcuate mean for selected rows for selected columns in pandas data frame