2024-04-26 23:31:29 发布
网友
这是我的数据帧:-你知道吗
A B C D 1 23 34 23 3 23 21 4 4 5 6 7
what i want to do is read 0th row and add it into a list like this [A,B,C,D](here this column name can be anything)
what i want to do is read 0th row and add it into a list like this [A,B,C,D]
[A,B,C,D]
(here this column name can be anything)
我用过
data = pd.read_csv(file_path, nrows=0)
但我无法将其添加/存储到列表中
怎么做?你知道吗
您可以轻松做到:
list(data)
但更明确的是这样写:
list(data.columns.values)
编辑:正如RafAelC所说的,最好像这样使用tolist():
tolist()
data.columns.values.tolist()
您可以轻松做到:
但更明确的是这样写:
编辑:正如RafAelC所说的,最好像这样使用
tolist()
:相关问题 更多 >
编程相关推荐