Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 表中的行索引_Python_Pandas - Fatal编程技术网

Python 表中的行索引

Python 表中的行索引,python,pandas,Python,Pandas,我正在将以下数组读入数据帧: 1 0.140000 0.180000 0.200000 2 0.240000 0.320000 0.320000 3 0.340000 0.430000 0.460000 pd.read_table("test.txt", sep = ' ', header = None, index_col= 0) 这是可行的,除非我得到一个空的“零”行: 如何修复行索引 谢谢。实际上,“0”是此数据帧中的索引名,要删除此名称,可以使用以下命令: pd.read_table

我正在将以下数组读入数据帧:

1 0.140000 0.180000 0.200000
2 0.240000 0.320000 0.320000
3 0.340000 0.430000 0.460000

pd.read_table("test.txt", sep = ' ', header = None, index_col= 0)
这是可行的,除非我得到一个空的“零”行:

如何修复行索引


谢谢。

实际上,“0”是此数据帧中的索引名,要删除此名称,可以使用以下命令:

pd.read_table(textfile, sep = ' ', header = None, index_col = 0).rename_axis(None)
输出:

      1     2     3
1  0.14  0.18  0.20
2  0.24  0.32  0.32
3  0.34  0.43  0.46

尝试将index_col=None设置为0,而不是0。然后,第一列(对行进行索引)变为数据,否?哦,是的,可能会发生这种情况。我无法在我的方面重复这个问题,调试如此困难。
      1     2     3
1  0.14  0.18  0.20
2  0.24  0.32  0.32
3  0.34  0.43  0.46