回答編集履歴
4
欠損処理忘れていたので追加
test
CHANGED
@@ -96,7 +96,9 @@
|
|
96
96
|
|
97
97
|
|
98
98
|
|
99
|
+
# 上昇2、下降1、変動なし3、欠損None
|
100
|
+
|
99
|
-
df_diff["Sign"] = df_diff["CalcPrice"].apply(lambda x: 1 if x < 0 else 2 if x > 0 else 3)
|
101
|
+
df_diff["Sign"] = df_diff["CalcPrice"].apply((lambda x: 1 if x < 0 else 2 if x > 0 else 3 if x == 0 else None))
|
100
102
|
|
101
103
|
|
102
104
|
|
3
30秒の条件訂正
test
CHANGED
@@ -102,7 +102,7 @@
|
|
102
102
|
|
103
103
|
# 30秒以内変動がないものを欠損
|
104
104
|
|
105
|
-
df_diff["Sign"] = df_diff["Sign"].mask((df_diff["CurrentPriceTime"]
|
105
|
+
df_diff["Sign"] = df_diff["Sign"].mask((df_diff["CurrentPriceTime"] < pd.Timedelta(seconds=30)) & (df_diff["Sign"] == 3))
|
106
106
|
|
107
107
|
|
108
108
|
|
2
勘違いしていたので修正
test
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
9:00から15:00の内11:30から12:30は
|
1
|
+
9:00から15:00の内11:30から12:30は0
|
2
2
|
|
3
|
-
同一銘柄の
|
3
|
+
同一銘柄のを上がったら2、下がったら1、変動なしのうち30秒以上は3、30秒以内は欠損にしています
|
4
4
|
|
5
5
|
|
6
6
|
|
@@ -74,7 +74,7 @@
|
|
74
74
|
|
75
75
|
|
76
76
|
|
77
|
-
|
77
|
+
InTime= df["CurrentPriceTime"].dt.time.apply(
|
78
78
|
|
79
79
|
lambda d: (datetime.time(8) < d < datetime.time(11, 30))
|
80
80
|
|
@@ -84,7 +84,7 @@
|
|
84
84
|
|
85
85
|
|
86
86
|
|
87
|
-
df1 = df.loc[
|
87
|
+
df1 = df.loc[:, ["SymbolName", "CurrentPriceTime", "CalcPrice"]]
|
88
88
|
|
89
89
|
|
90
90
|
|
@@ -96,17 +96,23 @@
|
|
96
96
|
|
97
97
|
|
98
98
|
|
99
|
-
# 30秒以上は欠損
|
100
|
-
|
101
|
-
df_diff["
|
99
|
+
df_diff["Sign"] = df_diff["CalcPrice"].apply(lambda x: 1 if x < 0 else 2 if x > 0 else 3)
|
102
|
-
|
103
|
-
df_diff["CurrentPriceTime"] < pd.Timedelta(seconds=30)
|
104
|
-
|
105
|
-
)
|
106
100
|
|
107
101
|
|
108
102
|
|
103
|
+
# 30秒以内変動がないものを欠損
|
104
|
+
|
109
|
-
df["Sign"] = df_diff["C
|
105
|
+
df_diff["Sign"] = df_diff["Sign"].mask((df_diff["CurrentPriceTime"] > pd.Timedelta(seconds=30)) & (df_diff["Sign"] == 3))
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
# 時間外を0
|
110
|
+
|
111
|
+
df_diff.loc[~InTime, "Sign"] = 0
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
df["Sign"] = df_diff["Sign"]
|
110
116
|
|
111
117
|
|
112
118
|
|
1
抽出の書き方変更
test
CHANGED
@@ -84,7 +84,7 @@
|
|
84
84
|
|
85
85
|
|
86
86
|
|
87
|
-
df1 = df[df["InTime"]
|
87
|
+
df1 = df.loc[df["InTime"], ["SymbolName", "CurrentPriceTime", "CalcPrice"]]
|
88
88
|
|
89
89
|
|
90
90
|
|