import pandas as pd
import matplotlib.pyplot as plt
inputfile=r"C:\Users\admin\Documents\WeChat Files\wxid_b0fz4hqogenr22\FileStorage\File\2023-03\original_data.xls"
data=pd.read_excel(inputfile)
lv_non=pd.value_counts(data['有无水流'])['无']
lv_move=pd.value_counts(data['有无水流'])['有']
fig=plt.figure(figsize=(6,5))
plt.rcParams['font.sans-serif']='SimHei'
plt.rcParams['axes.unicode_minus']=False
plt.bar(x=range(2),height=[lv_non,lv_move],width=0.4,alpha=0.8,color='skyblue')
plt.xticks([index for index in range(2)],['无','有'])
plt.xlabel('水流状态')
plt.ylabel('记录数')
plt.title('不同水流状态记录数--3029')
plt.show()
plt.close()
water=data['水流量']
fig=plt.figure(figsize=(5,8))
plt.boxplot(water,
patch_artist=True,
labels=['水流量'],
boxprops={'facecolor':'lightblue'})
plt.title('水流量分布箱型图--3029')
plt.grid(axis='y')
plt.show()
import pandas as pd
import numpy as np
data=pd.read_excel(r"C:\Users\admin\Documents\WeChat Files\wxid_b0fz4hqogenr22\FileStorage\File\2023-03\original_data.xls")
print('初始状态的数据形状为:',data.shape)
data.drop(labels=["热水器编号","有无水流","节能模式"],axis=1,inplace=True)
print('删除冗余属性后的数据形状为:',data.shape)
data.to_csv(r"C:\Users\admin\Documents\WeChat Files\wxid_b0fz4hqogenr22\FileStorage\File\2023-03\water_heart.csv",index=False)
标签:数据分析,Files,plt,lv,pd,data,水流 From: https://www.cnblogs.com/x3029/p/17236566.html