回答編集履歴

1

サンプルの追加

2017/10/03 23:15

投稿

magichan
magichan

スコア15898

test CHANGED
@@ -43,3 +43,29 @@
43
43
 
44
44
 
45
45
  などはどうでしょうか?
46
+
47
+
48
+
49
+ ---
50
+
51
+
52
+
53
+ **【追加】**
54
+
55
+
56
+
57
+ 3.``DataFrame.where()`` を使う
58
+
59
+
60
+
61
+ ```Python
62
+
63
+ import pandas as pd
64
+
65
+
66
+
67
+ df = pd.DataFrame({'X':[1,2,0,4,5],'Y':[1,0,3,0,5]})
68
+
69
+ df = df.where(df!=0, df.shift(1))
70
+
71
+ ```