【数据分析】python带你分析122万人的生活工作和死亡数据 ...

打印 上一主题 下一主题

主题 557|帖子 557|积分 1671

前言

嗨喽~大家好呀,这里是魔王呐 !
闲的无聊的得我又来倒腾代码了~
今天给大家分享得是——122万人的生活工作和死亡数据分析
准备好了嘛~现在开始发车喽!!
@TOC
所需素材


获取素材点击
代码
  1. import pandas as pd
  2. df = pd.read_csv('.\data\AgeDatasetV1.csv')
  3. df.info()
  4. df.describe().to_excel(r'.\result\describe.xlsx')
  5. df.isnull().sum().to_excel(r'.\result\nullsum.xlsx')
  6. df[df.duplicated()].to_excel(r'.\result\duplicated.xlsx')
  7. df.rename(columns=lambda x: x.replace(' ', '_').replace('-', '_'), inplace=True)
  8. print(df.columns)
  9. print(df[df['Birth_year'] < 0].to_excel(r'.\result\biryear0.xlsx'))  # 出生负数表示公元前
复制代码
  1. import pandas as pd
  2. import matplotlib.pyplot as plt
  3. import seaborn as sns
复制代码
  1. plt.rcParams['font.sans-serif'] = ['SimHei']  # 显示中文标签
  2. plt.rcParams['axes.unicode_minus'] = False
  3. df1 = pd.read_csv('./data/AgeDatasetV1.csv')
  4. # 列名规范化 重命名
  5. df1.rename(columns=lambda x: x.replace(' ', '_').replace('-', '_'), inplace=True)
  6. print(df1.columns)
  7. # print(Data.corr()) # 相关性
  8. # print(df1['Gender'].unique())  # 性别
复制代码
[code]# # 按不同年龄范围的死亡率百分比plt.figure(figsize=(12, 10))count = [df1[df1['Age_of_death'] > 100].shape[0],         df1.shape[0] - df1[(df1['Age_of_death']  90)].shape[0],         df1[(df1['Age_of_death']  70)].shape[0],         df1[(df1['Age_of_death']  50)].shape[0],         df1.shape[0] - (df1[df1['Age_of_death'] > 100].shape[0] +                         df1[(df1['Age_of_death']  90)].shape[0]                         + df1[(df1['Age_of_death']  50)].shape[0]                         + df1[(df1['Age_of_death']  70)].shape[0])         ]age = ['> 100', '> 90 &  70 &  50 &

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

圆咕噜咕噜

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表