Pandas: groupby двух столбцов и уточнение значения в третьем
Такое работает
df.groupby('column_1').target.mean()
такое тоже ok
df.groupby(["column_1", "column_2"])["target"].transform("mean")
и такое
df.groupby(df['column_1'][df['target'] == 1]).size()
такое (groupby по двум колонкам + уточнение данных по третьей) нет:
df.groupby(df['column_1','column_2'][df['target'] == 1]).size()
Какие именно функции типа size или mean на конце - не важно.
Ошибка:
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/hashtable_class_helper.pxi in
pandas._libs.hashtable.PyObjectHashTable.get_item()
pandas/_libs/hashtable_class_helper.pxi in
pandas._libs.hashtable.PyObjectHashTable.get_item()
....if tolerance is not None ... KeyError: ('column_1', 'column_2')
что делать?