回答編集履歴
1
d
test
CHANGED
@@ -33,3 +33,27 @@
|
|
33
33
|
# AttributeError: 'Series' object has no attribute 'columns'
|
34
34
|
|
35
35
|
```
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
DataFrame の列をリストで取得したい場合は以下のようにすればよいです。
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
```python
|
44
|
+
|
45
|
+
import pandas as pd
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
df = pd.DataFrame({"A": [1, 2, 3],
|
50
|
+
|
51
|
+
"B": [4, 5, 6],
|
52
|
+
|
53
|
+
"C": [7, 8, 9]})
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
print(df.columns.tolist()) # ['A', 'B', 'C']
|
58
|
+
|
59
|
+
```
|