import matplotlib.pyplot as plt
import pandas as pd
datafile = 'air_data.csv'
resultfile = 'explore.csv'
data = pd.read_csv(datafile,encoding='utf-8')
explore = data.describe(percentiles=[],include='all').T
explore['null'] = len(data) - explore['count']
explore = explore[['null','max','min']]
explore.columns = [u'空数值',u'最大值',u'最小值']
explore.to_csv(resultfile)
from datetime import datetime
ffp = data['FFP_DATE'].apply(lambda x:datetime.strptime(x,'%Y/%m/%d'))
ffp_year = ffp.map(lambda x:x.year)
fig = plt.figure(figsize=(8,5))
plt.rcParams['font.sans-serif'] = 'SimHei'
plt.rcParams['axes.unicode_minus'] = False
plt.hist(ffp_year,bins='auto',color='#0504aa')
plt.xlabel('年份')
plt.ylabel('入会人数')
plt.title('各年份会员人数 学号3119')
plt.show()
plt.close()
#提取会员不同性别人数
male = pd.value_counts(data['GENDER'])['男']
female = pd.value_counts(data['GENDER'])['女']
#绘制会员性别比例饼图
fig = plt.figure(figsize=(7, 4)) #设置画布大小
plt.pie([male, female], labels=['男', '女'], colors=['lightskyblue', 'lightcoral'], autopct='%1.1f%%')
plt.title('会员性别比例 学号3119')
plt.show()
plt.close()
标签:数据分析,plt,python,ffp,explore,year,csv,data From: https://www.cnblogs.com/panlongcong/p/17212849.html