回答編集履歴
1
テストデータ修正
test
CHANGED
@@ -25,6 +25,12 @@
|
|
25
25
|
lst.append(random.sample(CHARS,random.randint(1,len(CHARS))))
|
26
26
|
|
27
27
|
df = pd.DataFrame({"column":lst})
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
# テストデータ
|
32
|
+
|
33
|
+
df = pd.DataFrame({"column":[["a", "c", "e"], ["b"], ["c", "e"], ["a", "e"], ["a", "b", "c"]]})
|
28
34
|
|
29
35
|
print(df)
|
30
36
|
|
@@ -84,6 +90,28 @@
|
|
84
90
|
|
85
91
|
ret = pd.DataFrame(b, columns=columns)
|
86
92
|
|
93
|
+
|
94
|
+
|
95
|
+
# 列名を昇順に
|
96
|
+
|
97
|
+
ret = ret.loc[:,sorted(columns)]
|
98
|
+
|
87
99
|
print(ret)
|
88
100
|
|
101
|
+
"""
|
102
|
+
|
103
|
+
a b c e
|
104
|
+
|
105
|
+
0 1 0 1 1
|
106
|
+
|
107
|
+
1 0 1 0 0
|
108
|
+
|
109
|
+
2 0 0 1 1
|
110
|
+
|
111
|
+
3 1 0 0 1
|
112
|
+
|
113
|
+
4 1 1 1 0
|
114
|
+
|
115
|
+
"""
|
116
|
+
|
89
117
|
```
|