有没有办法在添加新行时设置一个自动递增pandas.DataFrame索引的选项,或者定义一个管理新索引创建的函数?
发布于 2013-02-09 01:45:37
可以在append-ing时设置ignore_index=True:
In [1]: df = pd.DataFrame([[1,2],[3,4]])
In [2]: row = pd.Series([5,6])
In [3]: df.append(row, ignore_index=True)
Out[3]:
0 1
0 1 2
1 3 4
2 5 6https://stackoverflow.com/questions/14778042
复制相似问题