2015 ~ 2017 高中自學生
2017 ~ NOW 交大應數系
www.sli.do/SITCON18-T22
不會寫程式的有多少?預期1/10
知道Pandas的有多少?預期 1/3
嘗試過校園用電分析的有多少?預期 1/3
對這個主題有興趣的?預期 1/4
Fig.1 Baby step
Fig.2 Baby step
請教學校最了解用電的人:
學校營繕組
大樓管理人
資料分析
視覺化
時段
季節
2018/03/10 13:00
科學一館
主迴路
北區
教學
54.87 度/Hr
Value 海苔:True
DF[魚 = ‘紅色’] 就會有 [鮪魚壽司, 鮭魚壽司, etc]
import pandas as pd
df = pd.read_csv([PATH])
df.head() #頭長怎樣
df.describe() #數值的統計
df.Time.value_counts() #1:00有幾筆, 2:00有幾筆, etc
df.Building.unique() #Building 這一欄有多少種類的值
# 產生關於時間的欄位
def generate_date_time_columns(df):
if('DateTime' in df.columns):
df['Date'] = df.DateTime.str[:10]
df['Date'] = pd.to_datetime(df['Date'], format='%Y-%m-%d')
df['Weekday'] = df['Date'].dt.dayofweek + 1
df['Time'] = df.DateTime.str[11:]
df['Week'] = df['Date'].dt.week
else:
print('DataTime not in column. Please rename columns name.')
return df
# cost_rate:一度電大概多少錢
def generate_cost_columns(df, cost_rate):
df['Cost'] = df.Usage * cost_rate
print('Column "Cost" had been generated!')
return df
#把原始資料的空格拿掉
def clear_white_space(df):
print("Before: ", df.Building.unique())
for y in df.select_dtypes(include = 'object').columns:
df[y] = df[y].str.strip()
print('After: ', df.Building.unique())
clear_white_space(df)
對象:在一棟大樓中
用電隨時間變化是如何?
極大 / 極小值發生在何時?
對象:不同大樓之間
用電的變化是否有不同?
106 年平均月用電比例
106年
平均月用電比例
106年
平均月用電比例
資料來源:科學三館,2016.09 - 2017.08
日期
用
電
度
數
Index(隨時間正序)
用
電
度
數
顏色代表第幾周
Weekday
用
電
度
數
Weekday
用
電
度
數
顏色代表第幾周
時間(小時)
用
電
度
數
00:00
23:00
時間(小時)
用
電
度
數
00:00
23:00
顏色代表Weekday
時間(小時)
用
電
度
數
00:00
23:00
顏色代表第幾周
時間(小時)
成
長
率
00:00
23:00
顏色代表星期幾
日期
紅色:夜用電
綠色:日用電
紫色:日/夜 (經縮放)
其實還在構想(有建議嗎?)
*最簡單也最重要的一件事