Pandas_规整数据_组合数据_combine_first

组合数据

combine_first() 是一个实例方法,用一个DataFrame的数据补充到另一个DataFrame,生成一个新的对象。

a.combine_first(b)  用b的数据填补a的缺失值

b.combine_first(a)  用a的数据填补b的缺失值

df1
	one	two
0	11.0	NaN
1	12.0	22.0
2	NaN	23.0
3	13.0	NaN
4	NaN	24.0

df2
        one	two	three
0	0	10.0	100.000000
1	1	28.0	158.489319
2	2	46.0	251.188643
3	3	64.0	398.107171
4	4	82.0	630.957344
5	5	100.0	1000.000000

<>
df1.combine_first(df2)
	one	three	        two
0	11.0	100.000000	10.0
1	12.0	158.489319	22.0
2	2.0	251.188643	23.0
3	13.0	398.107171	64.0
4	4.0	630.957344	24.0
5	5.0	1000.000000	100.0

 

你可能感兴趣的:(Pandas_规整数据_组合数据_combine_first)