这篇教程关于python写得很实用,希望能帮到您。
python DataFrame的合并方法Python的Pandas针对DataFrame,Series提供了多个合并函数,通过参数的调整可以轻松实现DatafFrame的合并。 首先,定义3个DataFrame df1,df2,df3,进行concat、merge、append函数的实验。 df1=pd.DataFrame([[1,2,3],[2,3,4]],columns=['a','b','c'])df2=pd.DataFrame([[2,3,4],[3,4,5]],columns=['a','b','c'])df3=pd.DataFrame([[1,2,3],[2,3,4]],columns=['a','b','d']) df1 a b c0 1 2 31 2 3 4df2 a b c0 2 3 41 3 4 5df3 a b d0 1 2 31 2 3 4
#concat函数pandas中concat函数的完整表达,包含多个参数,常用的有axis,join,ignore_index. concat函数的第一个参数为objs,一般为一个list列表,包含要合并两个或多个DataFrame,多个Series pandas.concat(objs, axis=0, join='outer', join_axes=None, ignore_index=False, python3 python |