pandas.DataFrame.append()

DataFrame.append(other, ignore_index=False, verify_integrity=False, sort=None)

用法

将其他行添加到此DataFrame的末尾,返回一个新对象。 不在此DataFrame中的列将作为新列添加。

参数

  • other:DataFrame或Series / dict-like对象,或者这些要附加的数据的列表

  • ignore_index: 布尔值,默认False。如果为真,就不会使用索引标签。
    例如:

>>> df = pd.DataFrame([[1, 2], [3, 4]], columns=list('AB'))
>>> df
   A  B
0  1  2
1  3  4

ignore_index=False

>>> df2 = pd.DataFrame([[5, 6], [7, 8]], columns=list('AB'))
>>> df.append(df2)
   A  B
0  1  2
1  3  4
0  5  6
1  7  8

ignore_index=True

>>> df.append(df2, ignore_index=True)
   A  B
0  1  2
1  3  4
2  5  6
3  7  8
  • verify_integrity : boolean, default False

  • sort : boolean, default None

猜你喜欢

转载自blog.csdn.net/turing365/article/details/80646681
今日推荐