数据分析数据拼接案例
生活随笔
收集整理的這篇文章主要介紹了
数据分析数据拼接案例
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
#-*-coding:utf-8-*-
import pandas as pd
#加載數據
detail_0=pd.read_excel('./meal_order_detail.xlsx',sheetname=0)
detail_1=pd.read_excel('./meal_order_detail.xlsx',sheetname=1)
detail_2=pd.read_excel('./meal_order_detail.xlsx',sheetname=2)
#進行行的方向上,進行inner
detail=pd.concat((detail_0,detail_1,detail_2),axis=0,join='inner')
#訂單的詳情信息
print(detail.shape)
#預測那些人經常點哪些菜--對應菜品進行打折,或者推薦
#detail繼續與infor進行拼接
#detail里面只有訂單id--可以找到其他的信息
#info里面是那些人點了哪些訂單
#info與detail進行主鍵拼接
#加載info
info=pd.read_csv('./meal_order_info.csv',encoding='ansi')
users=pd.read_excel('./users.xlsx')
res=pd.merge(left=detail,right=info,how='inner',left_on='order_id',right_on='info_id')
#print(res)
#將res與users進行主鍵拼接
res2=pd.merge(left=res,right=users,how='inner',left_on='name',right_on='ACCOUNT')
print(res2)
總結
以上是生活随笔為你收集整理的数据分析数据拼接案例的全部內容,希望文章能夠幫你解決所遇到的問題。