繁体   English   中英

从两个在 Pandas 中缺少行的表中创建最完整的表

[英]Create the most complete table from two tables with missing rows in pandas

我有两个熊猫数据帧df1df2

df1:      df2:

   A         A

1 10      2 21
2 20      3 31
5 50      4 41
6 60      5 51

并希望根据它们的索引将两个 DataFrame 合并到最完整的一个。 结果应如下所示:

df_full

   A

1 10
2 20
3 31
4 41
5 50
6 60

你有combine_first

df1.combine_first(df2).astype(int)

    col1
1    10
2    20
3    31
4    41
5    50
6    60

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM