質問編集履歴

1

2020/02/13 08:55

投稿

SnowBallEffect
test CHANGED
File without changes
test CHANGED
@@ -46,6 +46,56 @@
46
46
 
47
47
  dfi = df[i]
48
48
 
49
+
50
+
51
+ # odd columns
52
+
53
+ dfi_tmp1 = dfi.iloc[::2].reset_index(drop=True)
54
+
55
+ dfi_tmp1.columns = dfi.columns.get_level_values(0)
56
+
57
+
58
+
59
+ new = dfi_tmp1['AB']
60
+
61
+
62
+
63
+ # splitting
64
+
65
+ dfi_tmp1['A'] = new[:0]
66
+
67
+ # splitting
68
+
69
+ dfi_tmp1['B'] = new[:0]
70
+
71
+
72
+
73
+ # even columns
74
+
75
+ dfi_tmp2 = dfi.iloc[1::2].reset_index(drop=True)
76
+
77
+ dfi_tmp2.columns = dfi.columns.get_level_values(1)
78
+
79
+
80
+
81
+ # grouping together
82
+
83
+ dfi = pd.concat([dfi_tmp1, dfi_tmp2], axis=1)
84
+
85
+
86
+
87
+ # Dropping the two blank columns and AB
88
+
89
+ dfi_tmp2.drop(columns=['AB'], inplace=True)
90
+
91
+
92
+
93
+ dfi = dfi[dfi['ファンドコード'] != '合計']
94
+
95
+ dfi = pd.concat([dfi])
96
+
97
+
98
+
49
99
 
50
100
 
51
101
  writer = pd.ExcelWriter(destination, engine='xlsxwriter')