回答編集履歴
2
再度修正
test
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
以下でいかがでしょうか。
|
2
2
|
|
3
3
|
レスがあったので再度行ってみましたが、こちらではうまくいってます。
|
4
|
+
|
5
|
+
固定長とのことですの再度修正しました。
|
4
6
|
|
5
7
|
```python
|
6
8
|
|
@@ -8,7 +10,7 @@
|
|
8
10
|
|
9
11
|
|
10
12
|
|
11
|
-
In [2]: df3 = pd.DataFrame({'A': ['2019 1 1 0 0', '2019 2 2 1 2', '2019
|
13
|
+
In [2]: df3 = pd.DataFrame({'A': ['2019 1 1 0 0', '2019 2 2 1 2', '201912312359'],
|
12
14
|
|
13
15
|
...: 'B': [12, 22, 32],
|
14
16
|
|
@@ -16,21 +18,21 @@
|
|
16
18
|
|
17
19
|
|
18
20
|
|
19
|
-
In [3]: df3.
|
21
|
+
In [3]: df3.columns=["Time (GMT+9)", "有義波高 (H1/3) (m)", "最高波周期 (Tp) (s)"]
|
20
|
-
|
21
|
-
Out[3]:
|
22
|
-
|
23
|
-
A object
|
24
|
-
|
25
|
-
B int64
|
26
|
-
|
27
|
-
C int64
|
28
|
-
|
29
|
-
dtype: object
|
30
22
|
|
31
23
|
|
32
24
|
|
25
|
+
In [4]: df3
|
26
|
+
|
27
|
+
Out[4]:
|
28
|
+
|
33
|
-
|
29
|
+
Time (GMT+9) 有義波高 (H1/3) (m) 最高波周期 (Tp) (s)
|
30
|
+
|
31
|
+
0 2019 1 1 0 0 12 13
|
32
|
+
|
33
|
+
1 2019 2 2 1 2 22 23
|
34
|
+
|
35
|
+
2 201912312359 32 33
|
34
36
|
|
35
37
|
|
36
38
|
|
@@ -48,27 +50,31 @@
|
|
48
50
|
|
49
51
|
|
50
52
|
|
51
|
-
In [6]: df3
|
52
|
-
|
53
|
-
Out[6]:
|
54
|
-
|
55
|
-
|
53
|
+
In [6]: df3["Time (GMT+9)"] = df3["Time (GMT+9)"].str.replace(' ', '0')
|
56
|
-
|
57
|
-
0 2019 1 1 0 0 12 13
|
58
|
-
|
59
|
-
1 2019 2 2 1 2 22 23
|
60
|
-
|
61
|
-
2 2019 12 31 23 59 32 33
|
62
54
|
|
63
55
|
|
64
56
|
|
57
|
+
In [7]: df3
|
58
|
+
|
59
|
+
Out[7]:
|
60
|
+
|
65
|
-
|
61
|
+
Time (GMT+9) 有義波高 (H1/3) (m) 最高波周期 (Tp) (s)
|
62
|
+
|
63
|
+
0 201901010000 12 13
|
64
|
+
|
65
|
+
1 201902020102 22 23
|
66
|
+
|
67
|
+
2 201912312359 32 33
|
66
68
|
|
67
69
|
|
68
70
|
|
69
|
-
In [8]: df3
|
71
|
+
In [8]: df3['Time (GMT+9)'] = pd.to_datetime(df3['Time (GMT+9)'], format="%Y%m%d%H%M")
|
70
72
|
|
73
|
+
|
74
|
+
|
75
|
+
In [9]: df3
|
76
|
+
|
71
|
-
Out[
|
77
|
+
Out[9]:
|
72
78
|
|
73
79
|
Time (GMT+9) 有義波高 (H1/3) (m) 最高波周期 (Tp) (s)
|
74
80
|
|
@@ -80,9 +86,9 @@
|
|
80
86
|
|
81
87
|
|
82
88
|
|
83
|
-
In [
|
89
|
+
In [10]: df3.dtypes
|
84
90
|
|
85
|
-
Out[
|
91
|
+
Out[10]:
|
86
92
|
|
87
93
|
Time (GMT+9) datetime64[ns]
|
88
94
|
|
@@ -94,7 +100,7 @@
|
|
94
100
|
|
95
101
|
|
96
102
|
|
97
|
-
In [1
|
103
|
+
In [11]:
|
98
104
|
|
99
105
|
|
100
106
|
|
1
修正
test
CHANGED
@@ -1,24 +1,100 @@
|
|
1
|
-
以下でいかがでしょうか
|
1
|
+
以下でいかがでしょうか。
|
2
|
+
|
3
|
+
レスがあったので再度行ってみましたが、こちらではうまくいってます。
|
2
4
|
|
3
5
|
```python
|
4
6
|
|
5
|
-
import pandas as pd
|
7
|
+
In [1]: import pandas as pd
|
6
8
|
|
7
9
|
|
8
10
|
|
9
|
-
|
11
|
+
In [2]: df3 = pd.DataFrame({'A': ['2019 1 1 0 0', '2019 2 2 1 2', '2019 12 31 23 59'],
|
12
|
+
|
13
|
+
...: 'B': [12, 22, 32],
|
14
|
+
|
15
|
+
...: 'C': [13, 23, 33]})
|
10
16
|
|
11
17
|
|
12
18
|
|
13
|
-
|
19
|
+
In [3]: df3.dtypes
|
20
|
+
|
21
|
+
Out[3]:
|
22
|
+
|
23
|
+
A object
|
24
|
+
|
25
|
+
B int64
|
26
|
+
|
27
|
+
C int64
|
28
|
+
|
29
|
+
dtype: object
|
14
30
|
|
15
31
|
|
16
32
|
|
17
|
-
|
33
|
+
In [4]: df3.columns=["Time (GMT+9)", "有義波高 (H1/3) (m)", "最高波周期 (Tp) (s)"]
|
18
34
|
|
19
|
-
# 1 2019-02-02 03:04:00
|
20
35
|
|
36
|
+
|
37
|
+
In [5]: df3.dtypes
|
38
|
+
|
39
|
+
Out[5]:
|
40
|
+
|
41
|
+
Time (GMT+9) object
|
42
|
+
|
43
|
+
有義波高 (H1/3) (m) int64
|
44
|
+
|
45
|
+
最高波周期 (Tp) (s) int64
|
46
|
+
|
47
|
+
dtype: object
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
In [6]: df3
|
52
|
+
|
53
|
+
Out[6]:
|
54
|
+
|
55
|
+
Time (GMT+9) 有義波高 (H1/3) (m) 最高波周期 (Tp) (s)
|
56
|
+
|
57
|
+
0 2019 1 1 0 0 12 13
|
58
|
+
|
59
|
+
1 2019 2 2 1 2 22 23
|
60
|
+
|
61
|
+
2 2019 12 31 23 59 32 33
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
In [7]: df3['Time (GMT+9)'] = pd.to_datetime(df3['Time (GMT+9)'], format="%Y %m %d %H %M")
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
In [8]: df3
|
70
|
+
|
71
|
+
Out[8]:
|
72
|
+
|
73
|
+
Time (GMT+9) 有義波高 (H1/3) (m) 最高波周期 (Tp) (s)
|
74
|
+
|
75
|
+
0 2019-01-01 00:00:00 12 13
|
76
|
+
|
77
|
+
1 2019-02-02 01:02:00 22 23
|
78
|
+
|
79
|
+
2 2019-12-31 23:59:00 32 33
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
In [9]: df3.dtypes
|
84
|
+
|
85
|
+
Out[9]:
|
86
|
+
|
21
|
-
|
87
|
+
Time (GMT+9) datetime64[ns]
|
88
|
+
|
89
|
+
有義波高 (H1/3) (m) int64
|
90
|
+
|
91
|
+
最高波周期 (Tp) (s) int64
|
92
|
+
|
93
|
+
dtype: object
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
In [10]:
|
22
98
|
|
23
99
|
|
24
100
|
|