擅长:python、mysql、java
<p>在更新之前,日期框<code>b</code>由{a1}填充,因此b变成</p>
<pre><code>In [5]: b.reindex_like(a)
Out[5]:
a b isBool isBool2
0 45 45 NaN NaN
1 NaN NaN NaN NaN
</code></pre>
<p>然后使用<a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.where.html" rel="nofollow">numpy.where</a>更新数据帧。在</p>
<p>不幸的是,对于<code>numpy.where</code>,如果两个数据具有不同的类型,则会使用更通用的类型。例如</p>
^{pr2}$
<p>由于<code>numpy</code>中的<code>NaN</code>是浮动类型,它也将返回一个浮动类型。在</p>
<pre><code>In [22]: np.where(True, [True], [np.nan])
Out[22]: array([ 1.])
</code></pre>
<p>因此,在更新之后,“isBool”和“isBool2”列将变为浮动类型。在</p>
<p>我在<a href="https://github.com/pydata/pandas/issues/3016" rel="nofollow">the issue tracker for pandas</a>上添加了此问题</p>