我有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'
对象无法调用
它不会打印我想要的数据
如何解决该问题?
答案 0 :(得分:0)
在提取列之前,您需要执行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()