[英]Pandas read .csv and set index column
I have a problem when I read a .csv and set the 'Column A' as index column.我在读取 .csv 并将“A 列”设置为索引列时遇到问题。
df = pd.read_csv(index_col = 'Column A')
print(df.colums)
However, I cannot access 'Column A' anymore.但是,我无法再访问“A 列”了。 I still want to use it as one column to access its date.我仍然想用它作为一列来访问它的日期。
Can anyone help?任何人都可以帮忙吗?
我发现这非常简单:只需将索引设置为列。
df['index1'] = df.index
这将起到作用,简单而干净:
df = pd.read_csv().set_index('Column A')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.