pandas中怎么使用合并append函数

小编给大家分享一下pandas中怎么使用合并append函数,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!

具体内容如下:

1、append函数

可以拼接一个或者多个,也可以追加serise到原来的dataframe里面。

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

2、使用语法

append(self, other, ignore_index=False, verify_integrity=False)

3、使用参数

other:另一个df;

ignore_index:若为True,则对index进行重排;

verify_integrity:对index的唯一性进行验证,若有重复,报错。若已经设置了ignore_index,则该参数无效。

4、返回值

返回添加完成连接的一个新对象

5、使用实例

import pandas as pd
import numpy as np

df = pd.DataFrame(np.random.randint(0, 20, (3, 2)), columns=['A', 'B'])
print(df)

narry = np.random.randint(0, 20, (2, 2))
data = pd.DataFrame(narry, columns=['A', 'B'])
print(df.append(data, ignore_index=True))

看完了这篇文章,相信你对“pandas中怎么使用合并append函数”有了一定的了解,如果想了解更多相关知识,欢迎关注行业资讯频道,感谢各位的阅读!