用电预测:
import pandas as pd
import matplotlib.pyplot as plt
df_normal =pd.read_csv("C:/Users/admin/Documents/WeChat Files/wxid_b0fz4hqogenr22/FileStorage/File/2023-03/data/data/user.csv")
plt.figure(figsize=(8,6))
plt.plot(df_normal['Date'],df_normal['Eletricity'])
x_major_locator=plt.MultipleLocator(7)
ax=plt.gca()
ax.xaxis.set_major_locator(x_major_locator)
plt.rcParams['font.sans-serif']=['SimHei']
plt.ylabel('每日用电')
plt.xlabel('日期')
plt.title('正常用户电量趋势')
plt.show()
df_steal=pd.read_csv("C:/Users/admin/Documents/WeChat Files/wxid_b0fz4hqogenr22/FileStorage/File/2023-03/data/data/Steal user.csv")
plt.figure(figsize=(10,9))
plt.plot(df_steal['Date'],df_steal['Eletricity'])
'''plt.xlabel('日期')'''
'''plt.ylabel('日期')'''
x_major_locator=plt.MultipleLocator(7)
ax=plt.gca()
ax.xaxis.set_major_locator(x_major_locator)
plt.title('窃电用户电量趋势')
plt.rcParams['font.sans-serif']=['SimHei']
plt.show()
帕累托图:
import pandas as pd
dish_profit="C:/Users/admin/Documents/WeChat Files/wxid_b0fz4hqogenr22/FileStorage/File/2023-03/data/data/catering_dish_profit.xls"
data=pd.read_excel(dish_profit,index_col='菜品名')
data=data['盈利'].copy()
data.sort_values(ascending=False)
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['SimHei']
plt.rcParams['axes.unicode_minus']=False
plt.figure()
data.plot(kind='bar')
plt.ylabel('盈利(元)')
p=1.0*data.cumsum()/data.sum()
p.plot(color='r',secondary_y=True,style='-o',linewidth=2)
plt.annotate(format(p[6],'.4%'),xy=(6,p[6]),xytext=(6*0.9,p[6]*0.9),arrowprops=dict(arrowstyle='->',connectionstyle='arc3,rad=.2'))
plt.ylabel('盈利(比例)')
plt.title('3029')
plt.show()
相关性分析:
import pandas as pd
import matplotlib.pyplot as plt
catering_sale="C:/Users/admin/Documents/WeChat Files/wxid_b0fz4hqogenr22/FileStorage/File/2023-03/data/data/catering_sale_all.xls"
data=pd.read_excel(catering_sale,index_col='日期')
print(data.corr())
print(data.corr()['百合酱蒸凤爪'])
print(data['百合酱蒸凤爪'].corr(data['翡翠蒸香茜饺']))
x=['百合酱蒸凤爪', '翡翠蒸香茜饺', '金银蒜汁蒸排骨' ,'乐膳真味鸡', '蜜汁焗餐包', '生炒菜心', '铁板酸菜豆腐' ,'香煎韭菜饺', '香煎罗卜糕', '原汁原味菜心']
y=[data['百合酱蒸凤爪'].corr(data['百合酱蒸凤爪']),data['百合酱蒸凤爪'].corr(data['翡翠蒸香茜饺']),data['百合酱蒸凤爪'].corr(data['金银蒜汁蒸排骨']),data['百合酱蒸凤爪'].corr(data['乐膳真味鸡']),data['百合酱蒸凤爪'].corr(data['蜜汁焗餐包']),data['百合酱蒸凤爪'].corr(data['生炒菜心']),data['百合酱蒸凤爪'].corr(data['铁板酸菜豆腐']),data['百合酱蒸凤爪'].corr(data['香煎韭菜饺']),data['百合酱蒸凤爪'].corr(data['香煎罗卜糕']),data['百合酱蒸凤爪'].corr(data['原汁原味菜心'])]
plt.figure(figsize=(15,8))
plt.bar(x,y)
plt.rcParams['font.sans-serif']=['SimHei']
'''plt.ylabel('百合酱蒸凤爪的相关性')
plt.xlabel('菜品')'''
plt.title('相关性分析(条形图)-3029')
plt.show()
热力图:
import numpy as np
import pandas as pd
inputfile="C:/Users/admin/Documents/WeChat Files/wxid_b0fz4hqogenr22/FileStorage/File/2023-03/data.csv"
data=pd.read_csv(inputfile)
description=[data.min(),data.max(),data.mean(),data.std()]
description=pd.DataFrame(description,index=['Min','Max','Mean','STD']).T
print('描述性统计结果:\n',np.round(description,2))
corr=data.corr(method='pearson')
import matplotlib.pyplot as plt
import seaborn as sns
plt.subplots(figsize=(10,10))
sns.heatmap(corr,annot=True,vmax=(1),square=True,cmap='Greens')
plt.title('相关热力图-3029')
plt.rcParams['font.sans-serif']=['SimHei']
plt.show()
plt.close
标签:数据分析,plt,凤爪,报告,酱蒸,百合,corr,data From: https://www.cnblogs.com/x3029/p/17167899.html