Pandas寻找一排排的方法

2024-05-08 02:48:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我是一个熊猫新手,我偶然发现了一个数据集,其中包含了从1990年到2017年金氏县的季节性失业率。当前数据帧如下所示: Image of my current dataset

虽然没有显示,名单一直到1990年。 我该怎么做才能找到每年所有月份的总和,从而找到每年的平均失业率?你知道吗

我为糟糕的问题格式道歉有没有一个代码,将输出地区,年份,和失业率一起?谢谢


Tags: of数据代码imagemy格式currentdataset
1条回答
网友
1楼 · 发布于 2024-05-08 02:48:58

如果您的数据帧被称为df

# Make a new column with unemployment rate as a float, rather than a formatted string with % symbol
df['Unemployment Rate float'] = df['Unemployed'] / df['Labor Force']

# Group by year, and get the mean of the "unemployment rate float" column
df.groupby('Year').mean()['Unemployment Rate Float']

我可以推荐^{} tour吗?你知道吗

相关问题 更多 >