Pandas in运算符根据dateframe列中的多个值提取行
我使用in
运算符从输入中提取行,如下所示,但在底部得到错误消息。有没有人能搞清楚我为什么会出错?
Date AgeGroup Gender Count
2048-09-30 50-54 M 1000
2048-09-30 55-59 F 1200
2048-09-30 55-59 M 1300
2048-09-30 60-64 F 1400
2048-09-30 60-64 M 1500
2048-09-30 65-69 F 1600
2048-09-30 65-69 M 1700
2048-09-30 70-74 F 1890
2048-09-30 70-74 M 1500
2048-09-30 75-79 F 1320
2048-09-30 75-79 M 1100
2048-09-30 80-84 F 1240
2048-09-30 80-84 M 2000
2048-09-30 85+ F 1730
2048-09-30 85+ M 1800
AGEGE65F = df.loc[(df['Gender']=='F') & (df['AgeGroup'] in ('65-69','70-74','75-79','80-84','85+')]
File "<ipython-input-86-4920f0add248>", line 23
AGEGE65F = df.loc[(df['Gender']=='F') & (df['Age Groups'] in ('65-69','70-74','75-79','80-84','85+')]
^
SyntaxError: invalid syntax
转载请注明出处:http://www.xgclsm.com/article/20230526/1344389.html