相关性分析 散点图

import pandas as pd
df2=pd.read_excel('./data/data2.xlsx',index_col='产品编码')
df2.head()
x=df2['供应商进货价']
y=df2['销售价']
from pylab import mpl
mpl.rcParams['font.sans-serif']=['FangSong']
#散点图
import matplotlib.pyplot as plt

fig,ax=plt.subplots()
ax.scatter(x,y,color='green')
ax.set(xlabel='供应商进货价',ylabel='销售价',title='销售情况分析')
plt.show()

#散点矩阵
from pandas.plotting import scatter_matrix
scatter_matrix(df2,figsize=(10,10),marker='o',alpha=0.5)
plt.show()

#相关系数
df2.corr()
df2['销售价'].corr(df2['供应商进货价'])

posted @ 2019-10-03 20:03  天天见和  阅读(3394)  评论(0编辑  收藏  举报