这是我的数据
threats = pd.read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-08-18/threats.csv', index_col = 0)这是我的代码 -
df = (threats
.query('threatened>0')
.groupby(['continent', 'threat_type'])
.agg({'threatened':'size'}))然而df.columns 只是Index(['threatened'], dtype='object')结果。也就是说,只有 threatened 列不显示我实际上按 ie continent 和 threat_type 分组的列,尽管存在于我的数据框中。
我想对我的数据框的大陆列执行操作,但它没有显示为列之一。例如 - continents = df.continent.unique()。此命令给我一个未找到的关键错误continent。
MMTTMM
相关分类