SB
Size: a a a
SB
NP
Р
Для
воспроизводимости результата
first = [9,9,9,10,10,10]
second = ['one', 'two', 'three', 'one', 'two', 'three']
third = [10, 20, 30, 20, 40, 50]
test = pd.DataFrame(zip(first, second, third), columns=['mon', 'name', 'val'])
test_gr = test.groupby(['mon', 'name']).sum()
test_gr
Р
Для
воспроизводимости результата
first = [9,9,9,10,10,10]
second = ['one', 'two', 'three', 'one', 'two', 'three']
third = [10, 20, 30, 20, 40, 50]
test = pd.DataFrame(zip(first, second, third), columns=['mon', 'name', 'val'])
test_gr = test.groupby(['mon', 'name']).sum()
test_gr
W
СИ
df_by_month_group.index.levels
FrozenList([[9, 10, 11], ['one', 'two', 'three']])
Все ок. df_by_month_group.index.levels[0]
Int64Index([9, 10, 11], dtype='int64', name='month')
for
i
in
df_by_month_group.index.levels[0]:
print(i)
9
10
11
df_by_month_group.iloc[df_by_month_group.index.levels[0]==9]
IndexError: Boolean index has wrong length: 3 instead of 159
test_gr.iloc[test_gr.index.get_level_values(0) == 9]
или test_gr[test_gr.index.get_level_values(0) == 9]
AD
W
AD
W
AD
VA
VA
W
W
👑️
Д
NP
VA
W