我正在尝试计算数字分组中未关闭status_2的每个实例
df['conditional_count'] = df.groupby(['no_',(df['status_2']!=('closed'))]).transform('count')
no_ status 1 status 2
1 Opened Opened
1 Opened Closed
3 Opened Opened
4 Opened Opened
5 Opened Opened
5 Opened Opened
6 Opened Opened
我希望表格看起来像这样:
no_ status 1 status 2 Count
1 Opened Opened 1
1 Opened Closed 1
3 Opened Opened 1
4 Opened Opened 1
5 Opened Opened 2
5 Opened Opened 2
6 Opened Opened 1