df['B'] = df.index.get_level_values(level=1) # Zero based indexing.
# df['B'] = df.index.get_level_values(level='second') # This also works.
>>> df
A B
first second
foo one 12 one
two 11 two
bar one 16 one
two 12 two
three 11 three
Вы можете просто сложить значения 14.row и получить количество (количество) заболевших собак:
count = A[13,:].sum() # number of ill dogs -- 13 because the index starts with 0
Предположим, у нас есть этот вектор:
>import numpy as np
>arr = np.arange(30).reshape(6,5)
>arr
array([[ 0, 1, 2, 3, 4],
[ 5, 6, 7, 8, 9],
[10, 11, 12, 13, 14],
[15, 16, 17, 18, 19],
[20, 21, 22, 23, 24],
[25, 26, 27, 28, 29]])
С этим вы получите сумму всех значений для конкретной строки:
>np.sum(arr[1,:]) #On row 1
35
Для вашего конкретного случая используйте:
>np.sum(arr[13,:])