Skip to content

Commit 59af686

Browse files
authored
Add files via upload
0 parents  commit 59af686

3 files changed

Lines changed: 37 additions & 0 deletions

File tree

2023年10月溫度資訊.xlsx

5.85 KB
Binary file not shown.

drow.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import pandas as pd
2+
import lxml
3+
import openpyxl
4+
from IPython.display import display
5+
import matplotlib.pyplot as plt
6+
def drowpilot(year,month,obs,T,Tmax,Tmin):
7+
8+
fig,ax1=plt.subplots(figsize=(8,6))
9+
ax1.plot(obs,Tmax,color='#BB3D00',label="最高氣溫")
10+
ax1.plot(obs,T,color='#FF5809',label="氣溫")
11+
ax1.plot(obs,Tmin,color='#FF9D6F',label="最低氣溫")
12+
plt.grid(1)
13+
ax1.legend(bbox_to_anchor=(1, 1))
14+
plt.title(year+'年'+month+'月氣溫變化')
15+
ax1.set_xlabel('時間(日)')
16+
ax1.set_ylabel('氣溫(℃)')
17+
plt.rcParams['font.sans-serif'] = ['Microsoft JhengHei']
18+
plt.show()

main.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import pandas as pd
2+
import lxml
3+
import openpyxl
4+
from IPython.display import display
5+
import matplotlib.pyplot as plt
6+
import drow
7+
# 提取天氣資料
8+
year=str(2023)
9+
month=str(10)
10+
table = pd.read_html("https://e-service.cwa.gov.tw/HistoryDataQuery/MonthDataController.do?command=viewMain&station=467410&stname=%25E8%2587%25BA%25E5%258D%2597&datepicker="+year+"-"+month+"&altitude=40.8m", encoding='utf-8')
11+
new=table[1]
12+
ObsTime_data = new['Unnamed: 0_level_0']['觀測時間 (day)']
13+
Temperature_data=new['temperature']['氣溫 (℃)']
14+
TMax_data=new['temperature']['最高氣溫 (℃)']
15+
TMin_data=new['temperature']['最低氣溫 (℃)']
16+
Sunshine_data=new['SunShine']['日照時數 (hour)']
17+
data=ObsTime_data.join(Temperature_data).join(TMax_data).join(TMin_data).join(Sunshine_data)
18+
data.to_excel(year+'年'+month+'月'+'溫度資訊.xlsx')
19+
drow.drowpilot(year,month,ObsTime_data,Temperature_data,TMax_data,TMin_data)

0 commit comments

Comments
 (0)