ToB企服应用市场:ToB评测及商务社交产业平台

标题: 【数据分析】python带你分析122万人的生活工作和死亡数据 [打印本页]

作者: 圆咕噜咕噜    时间: 2022-10-12 22:54
标题: 【数据分析】python带你分析122万人的生活工作和死亡数据
前言

嗨喽~大家好呀,这里是魔王呐 !
闲的无聊的得我又来倒腾代码了~
今天给大家分享得是——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 &




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4