熊猫:将两个数据帧与samse结构相结合

时间:2018-01-15 15:03:35

标签: python python-2.7 pandas dataframe

我使用的是python 2.7,我有两个这样的数据帧:

df1

| index |  colA   |  colB  | colC |
-----------------------------------
|   1   |    A    |  None  |   X  |
|   2   |   None  |  None  |   D  |
|   3   |    B    |   C    | None |

df2

| index |  colA   |  colB  | colC |
-----------------------------------
|   1   |   None  |  None  | None |
|   2   |    Y    |   Z    | None |
|   3   |   None  |   None | None |

我的目标是将它们组合在一个包含最小None值的数据框中。 两个数据帧都有相同的索引。

df3

| index |  colA   |  colB  | colC |
-----------------------------------
|   1   |    A    |  None  |   X  |
|   2   |    Y    |   Z    |   D  |
|   3   |    B    |   C    | None |

0 个答案:

没有答案