【发布时间】:2016-08-23 13:52:43
【问题描述】:
我遇到了一个奇怪的问题,combine_first 方法导致存储为 bool 的值向上转换为 float64。 示例:
In [1]: import pandas as pd
In [2]: df1 = pd.DataFrame({"a": [True]})
In [3]: df2 = pd.DataFrame({"b": ['test']})
In [4]: df2.combine_first(df1)
Out[4]:
a b
0 1.0 test
这个问题已经在 3 年前的一篇文章中报告过:pandas DataFrame combine_first and update methods have strange behavior。这个问题被告知要解决,但我在 pandas 0.18.1 下仍然有这种行为
感谢您的帮助
【问题讨论】:
-
问题是什么?
-
我想知道为什么 combine_first 方法不保留“a”列中的布尔值?