回答編集履歴
1
追記
test
CHANGED
@@ -19,3 +19,59 @@
|
|
19
19
|
df
|
20
20
|
|
21
21
|
```
|
22
|
+
|
23
|
+
【追記】
|
24
|
+
|
25
|
+
```Python
|
26
|
+
|
27
|
+
import pandas as pd
|
28
|
+
|
29
|
+
import numpy as np
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
def func(df):
|
34
|
+
|
35
|
+
af=df.copy()
|
36
|
+
|
37
|
+
df=df.add(af, fill_value=0.0)
|
38
|
+
|
39
|
+
return df
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
global df
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
df=pd.DataFrame(np.arange(4*4).reshape(4,4))
|
48
|
+
|
49
|
+
print(df)
|
50
|
+
|
51
|
+
# 0 1 2 3
|
52
|
+
|
53
|
+
#0 0 1 2 3
|
54
|
+
|
55
|
+
#1 4 5 6 7
|
56
|
+
|
57
|
+
#2 8 9 10 11
|
58
|
+
|
59
|
+
#3 12 13 14 15
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
df=func(df)
|
64
|
+
|
65
|
+
print(df)
|
66
|
+
|
67
|
+
# 0 1 2 3
|
68
|
+
|
69
|
+
#0 0 2 4 6
|
70
|
+
|
71
|
+
#1 8 10 12 14
|
72
|
+
|
73
|
+
#2 16 18 20 22
|
74
|
+
|
75
|
+
#3 24 26 28 30
|
76
|
+
|
77
|
+
```
|