質問編集履歴
2
質問を修正しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
PadasのMultiIndexカラムのDataFrameとシングルカラムのDataFrameを結合したいです。
|
1
|
+
PadasのMultiIndexカラムのDataFrameとシングルカラムのDataFrameをMultiIndexのまま結合したいです。
|
2
2
|
結合した時にタプルになってしまいます。
|
3
3
|
シングルカラムをカラムのMの行かWの行に並べたいです。
|
4
4
|
|
1
横方向に結合するようにプログラム修正しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
PadasのMultiIndexカラムのDataFrameとシングルカラムのDataFrameを結合したいです。
|
2
|
-
結合した時に
|
2
|
+
結合した時にタプルになってしまいます。
|
3
|
+
シングルカラムをカラムのMの行かWの行に並べたいです。
|
3
4
|
|
4
5
|
|
5
6
|
```python
|
@@ -15,6 +16,13 @@
|
|
15
16
|
test=pd.DataFrame(data=np.round(np.random.randn(4,3),1),index=[0,1,2,3],columns=list('ABC'))
|
16
17
|
print(test)
|
17
18
|
|
18
|
-
test2=pd.concat([test,multidata])
|
19
|
+
test2=pd.concat([test,multidata],axis=1)
|
20
|
+
print(test2)
|
19
21
|
|
20
|
-
```
|
22
|
+
```
|
23
|
+
|
24
|
+
A B C (M1, W1) (M1, W2) (M1, W3) (M1, W4) (M1, W5) (M2, W1) (M2, W2) (M2, W3) (M2, W4) (M2, W5) (M3, W1) (M3, W2) (M3, W3) (M3, W4) (M3, W5)
|
25
|
+
0 1.5 0.5 -1.1 -0.8 0.9 0.6 -1.7 -0.1 -0.3 -1.0 -1.1 -3.5 1.6 0.9 -2.2 1.0 0.5 -0.4
|
26
|
+
1 0.7 -0.3 0.9 -0.6 -0.3 -0.9 0.0 1.8 0.9 1.5 -0.3 1.4 0.6 -0.4 -0.7 -1.3 -1.0 0.1
|
27
|
+
2 0.4 -0.8 -0.6 -1.2 0.4 0.2 0.9 -0.5 -0.9 -0.8 1.5 -0.4 -1.6 -0.5 -0.9 -0.4 1.4 0.2
|
28
|
+
3 1.9 1.5 -1.6 0.6 0.5 -1.4 0.0 -1.7 -0.5 1.9 0.3 -0.4 -0.3 -1.4 -0.3 0.2 1.0 1.3
|