Python 数据帧索引的自动递增选项
在添加新行时,是否有方法设置pandas.DataFrame索引的自动递增选项,或定义管理新索引创建的函数?您可以在以下情况下设置Python 数据帧索引的自动递增选项,python,indexing,append,row,pandas,Python,Indexing,Append,Row,Pandas,在添加新行时,是否有方法设置pandas.DataFrame索引的自动递增选项,或定义管理新索引创建的函数?您可以在以下情况下设置ignore\u 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 6
ignore\u 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 6