質問編集履歴
2
修正したコードを追記しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -86,41 +86,43 @@
|
|
86
86
|
|
87
87
|
for i in range(10):
|
88
88
|
|
89
|
-
year=2010+i
|
89
|
+
year=2010+i
|
90
90
|
|
91
|
-
place="秋田"
|
91
|
+
place="秋田"
|
92
92
|
|
93
93
|
|
94
94
|
|
95
|
-
date_time, YuugiHako, YuugihaShuuki = [], [], []
|
95
|
+
date_time, YuugiHako, YuugihaShuuki = [], [], []
|
96
96
|
|
97
97
|
|
98
98
|
|
99
|
-
with open(f"{place}/{place} {year}.txt", 'r') as f:
|
99
|
+
with open(f"{place}/{place} {year}.txt", 'r') as f:
|
100
100
|
|
101
|
-
f.readline()
|
101
|
+
f.readline()
|
102
102
|
|
103
|
-
for line in f:
|
103
|
+
for line in f:
|
104
104
|
|
105
|
-
date_str = line[0:12].replace(' ', '0')
|
105
|
+
date_str = line[0:12].replace(' ', '0')
|
106
106
|
|
107
|
-
date_str = f"{date_str[0:4]}-{date_str[4:6]}-{date_str[6:8]} {date_str[8:10]}:{date_str[10:12]}"
|
107
|
+
date_str = f"{date_str[0:4]}-{date_str[4:6]}-{date_str[6:8]} {date_str[8:10]}:{date_str[10:12]}"
|
108
108
|
|
109
|
-
date_time.append(datetime.strptime(date_str, "%Y-%m-%d %H:%M"))
|
109
|
+
date_time.append(datetime.strptime(date_str, "%Y-%m-%d %H:%M"))
|
110
110
|
|
111
|
-
YuugiHako.append(float(line[36:42]))
|
111
|
+
YuugiHako.append(float(line[36:42]))
|
112
112
|
|
113
|
-
YuugihaShuuki.append(float(line[43:49]))
|
113
|
+
YuugihaShuuki.append(float(line[43:49]))
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
df= pd.DataFrame({"日付": date_time, "有義波高 (m)": YuugiHako, "有義波周期 (s)": YuugihaShuuki})
|
118
|
+
|
119
|
+
df = df.set_index("日付")
|
114
120
|
|
115
121
|
|
116
122
|
|
117
|
-
df
|
123
|
+
dfs.append(df)
|
118
124
|
|
119
|
-
df = df.set_index("日付")
|
120
125
|
|
121
|
-
dfs = []
|
122
|
-
|
123
|
-
dfs.append(df)
|
124
126
|
|
125
127
|
df1 = pd.concat(dfs)
|
126
128
|
|
1
修正したコードを追記しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -68,6 +68,64 @@
|
|
68
68
|
|
69
69
|
|
70
70
|
|
71
|
+
###修正したコード
|
72
|
+
|
73
|
+
```ここに言語を入力
|
74
|
+
|
75
|
+
import pandas as pd
|
76
|
+
|
77
|
+
from datetime import datetime
|
78
|
+
|
79
|
+
import numpy as np
|
80
|
+
|
81
|
+
import matplotlib.dates as dt
|
82
|
+
|
83
|
+
import matplotlib.pyplot as plt
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
for i in range(10):
|
88
|
+
|
89
|
+
year=2010+i
|
90
|
+
|
91
|
+
place="秋田"
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
date_time, YuugiHako, YuugihaShuuki = [], [], []
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
with open(f"{place}/{place} {year}.txt", 'r') as f:
|
100
|
+
|
101
|
+
f.readline()
|
102
|
+
|
103
|
+
for line in f:
|
104
|
+
|
105
|
+
date_str = line[0:12].replace(' ', '0')
|
106
|
+
|
107
|
+
date_str = f"{date_str[0:4]}-{date_str[4:6]}-{date_str[6:8]} {date_str[8:10]}:{date_str[10:12]}"
|
108
|
+
|
109
|
+
date_time.append(datetime.strptime(date_str, "%Y-%m-%d %H:%M"))
|
110
|
+
|
111
|
+
YuugiHako.append(float(line[36:42]))
|
112
|
+
|
113
|
+
YuugihaShuuki.append(float(line[43:49]))
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
df= pd.DataFrame({"日付": date_time, "有義波高 (m)": YuugiHako, "有義波周期 (s)": YuugihaShuuki})
|
118
|
+
|
119
|
+
df = df.set_index("日付")
|
120
|
+
|
121
|
+
dfs = []
|
122
|
+
|
123
|
+
dfs.append(df)
|
124
|
+
|
125
|
+
df1 = pd.concat(dfs)
|
126
|
+
|
127
|
+
```
|
128
|
+
|
71
129
|
|
72
130
|
|
73
131
|
### 発生している問題・エラーメッセージ
|
@@ -82,10 +140,6 @@
|
|
82
140
|
|
83
141
|
|
84
142
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
143
|
### 補足情報(FW/ツールのバージョンなど)
|
90
144
|
|
91
145
|
|