商品銷售統計
-
畫出不同洲的歷年咖啡消費量:千袋(每袋60kg)
import pandas as pd import csv # 匯入plotly套件,以便繪製視覺化圖形 from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot import plotly.graph_objs as go # 讀入資料 data = pd.read_csv('coffee.csv') print(data) # 取得特定資料 zone1 = data.loc[0][1:] zone2 = data.loc[1][1:] zone3 = data.loc[2][1:] zone4 = data.loc[3][1:] zone5 = data.loc[4][1:] zone6 = data.loc[5][1:] #取得欄位名稱 xName = list(data.columns.values) trace1 = go.Bar( x = xName[1:5], y = zone1*60*1000, name = data.loc[0][0] ) trace2 = go.Bar( x = xName[1:5], y = zone2*60*1000, name = data.loc[1][0] ) trace3 = go.Bar( x = xName[1:5], y = zone3*60*1000, name = data.loc[2][0] ) trace4 = go.Bar( x = xName[1:5], y = zone4*60*1000, name = data.loc[3][0] ) trace5 = go.Bar( x = xName[1:5], y = zone5*60*1000, name = data.loc[4][0] ) trace6 = go.Bar( x = xName[1:5], y = zone6*60*1000, name = data.loc[5][0] ) data = [trace1, trace2, trace3, trace4, trace5, trace6] iplot(data, filename='scatter-mode')
問題與討論:
(1)觀察咖啡的消費量和生產量,咖啡生產量最大的洲是哪一洲? 消費量最大的是哪一洲?
(2)試著分析世界咖啡主要消費和主要生產區域的差異。
-