[英]How to read CSV file with of data frame with row names in Pandas
I have a CSV file ( tmp.csv
) that looks like this: 我有一个CSV文件(
tmp.csv
),如下所示:
x y z
bar 0.55 0.55 0.0
foo 0.3 0.4 0.1
qux 0.0 0.3 5.55
It was created with Pandas this way: 它是用Pandas这样创建的:
In [103]: df_dummy
Out[103]:
x y z
bar 0.55 0.55 0.00
foo 0.30 0.40 0.10
qux 0.00 0.30 5.55
In [104]: df_dummy.to_csv("tmp.csv",sep="\t")
What I want to do is to read that CSV into the same dataframe representation. 我想要做的是将CSV读入相同的数据帧表示。 I tried this but doesn't give what I want:
我尝试了这个,但没有给出我想要的东西:
In [108]: pd.io.parsers.read_csv("tmp.csv",sep="\t")
Out[108]:
Unnamed: 0 x y z
0 bar 0.55 0.55 0.00
1 foo 0.30 0.40 0.10
2 qux 0.00 0.30 5.55
What's the right way to do it? 什么是正确的方法呢?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.