pandas中如何使用合并append函数?
pandas中如何使用合并append函数?
介绍了这么多关于pandas拼接的方法,那你知道如果想要拼接拼接一个或者多个,还可以追加serise到原来的dataframe里面如何操作吗?其实还是很简单的,使用append函数就可以解决。本文介绍pandas中使用合并append函数的相关介绍。
1、使用语法
append(self,other,ignore_index=False,verify_integrity=False)
2、使用参数
other:另一个df;
ignore_index:若为True,则对index进行重排;
verify_integrity:对index的唯一性进行验证,若有重复,报错。若已经设置了ignore_index,则该参数无效。
3、返回值
返回添加完成连接的一个新对象
4、使用实例
importpandasaspd
importnumpyasnp
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))
拓展知识:
append函数
可以拼接一个或者多个,也可以追加serise到原来的dataframe里面。
将其他行添加到此DataFrame的末尾,返回一个新对象。不在此DataFrame中的列将作为新列添加。
以上就是pandas中使用合并append函数的相关介绍,是不是也没有想象中的那么难,快用起来吧~更多Python学习教程请关注IT培训机构:千锋教育。

相关推荐HOT
更多>>
pythonfor循环是什么
pythonfor循环是什么在做遍历的时候,对于一些数据的反复循环执行,我们会用到for循环的语句。可以说这是新手入门必学的语句之一,在很多基础循...详情>>
2023-11-13 07:46:36
pythoncontextmanager()的转换
python中contextmanager()的转换1、说明当发出请求时,requests库会在将请求实际发送到目标服务器之前准备该请求。请求准备包括像验证头信息和...详情>>
2023-11-13 06:34:35
python使用items()遍历键值对
python使用items()遍历键值对字典可以用来存储各种方式的信息,所以有很多方式可以通过字典的所有键值对、键或值。说明1、即使通过字典,键值对...详情>>
2023-11-13 04:24:15
python实例方法中self的作用
python实例方法中self的作用说明1、无论是创建类的构造方法还是实例方法,最少要包含一个参数self。2、通过实例的self参数与对象进行绑定,程序...详情>>
2023-11-13 03:46:48