數(shù)據(jù)源:catering_sale_all.xls
Paste_Image.png
代碼結(jié)果:餐飲銷量數(shù)據(jù)相關(guān)性分析
Paste_Image.png
源代碼
import pandas as pd
catering_sale = 'F:/python 數(shù)據(jù)挖掘分析實(shí)戰(zhàn)/Data/catering_sale_all.xls' #餐飲數(shù)據(jù)伤极,含有其他屬性
data = pd.read_excel(catering_sale, index_col = u'日期') #讀取數(shù)據(jù),指定“日期”列為索引列
print(data.corr()) # 任意兩列的相關(guān)系數(shù)姨伤,相關(guān)系數(shù)矩陣哨坪,即給出了任意兩款菜式之間的相關(guān)系數(shù)
print(data.corr()[u'百合醬蒸鳳爪']) #只顯示“百合醬蒸鳳爪”與其他菜式的相關(guān)系數(shù)
print(data[u'百合醬蒸鳳爪'].corr(data[u'翡翠蒸香茜餃'])) #計(jì)算“百合醬蒸鳳爪”與“翡翠蒸香茜餃”的相關(guān)系數(shù)
參考資料:《Python數(shù)據(jù)分析與挖掘?qū)崙?zhàn)》