我从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'
对象是不可调用的,它不会打印我想要的数据如何解决这个问题?
1条答案
按热度按时间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()