python-3.x 获取“DataFrameGroupBy”对象在jupyter中不可调用

ckx4rj1h  于 2023-11-20  发布在  Python
关注(0)|答案(1)|浏览(113)

我从https://www.data.gov.au/dataset/airport-traffic-data/resource/f0fbdc3d-1a82-4671-956f-7fee3bf9d7f2得到了这个csv文件
我试着把

airportdata = Airports.groupby(['Year_Ended_December'])('Dom_Pax_in','Dom_Pax_Out')
airportdata.sum()

字符串
然而,我一直得到'DataFrameGroupBy'对象是不可调用的,它不会打印我想要的数据如何解决这个问题?

oknrviil

oknrviil1#

您需要在提取列之前执行sum聚合:airportdata_agg = Airports.groupby(['Year_Ended_December']).sum()[['Dom_Pax_in','Dom_Pax_Out']]或者,如果您想确保不聚合列,则不使用:用途:airportdata_agg = Airports[['Dom_Pax_in','Dom_Pax_Out', 'Year_Ended_December']].groupby(['Year_Ended_December']).sum()

相关问题