回答編集履歴

1

Update

2021/12/26 16:02

投稿

melian
melian

スコア20655

test CHANGED
@@ -10,9 +10,9 @@
10
10
 
11
11
 
12
12
 
13
- def getTemperature(time):
13
+ def getTemperature(df, time):
14
14
 
15
- time = datetime.strptime(time, "%Y%m%d%H")
15
+ time = datetime.strptime(time, '%Y%m%d%H')
16
16
 
17
17
  return df[df['time'] == time]
18
18
 
@@ -22,9 +22,9 @@
22
22
 
23
23
  path = './weather/temp_' + year + '.csv'
24
24
 
25
- df = pd.read_csv(path, header=4, names=["time", 0, 1, 2], parse_dates=["time"])
25
+ df = pd.read_csv(path, header=4, names=['time', 0, 1, 2], parse_dates=['time'])
26
26
 
27
- temperature = getTemperature("2017040100")
27
+ temperature = getTemperature(df, '2017040100')
28
28
 
29
29
  print(temperature)
30
30