<h4 dir="auto">Code Sample,</h4>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
In [4]: df = pd.DataFrame({'series': pd.Series(range(3))})

In [5]: df[&quot;name&quot;] = &quot;abc&quot;

In [6]: df_copy = df.copy()

In [7]: df.series.loc[2] = None

In [8]: df
Out[8]: 
   series name
0     0.0  abc
1     1.0  abc
2     NaN  abc

In [9]: df_copy
Out[9]: 
   series name
0       0  abc
1       1  abc
2       2  abc

In [10]: df[df.isnull()] = df_copy

#or
#df.where(-df.isnull(), df_copy, inplace=True)
#basically it's doing that at the end"><pre class="notranslate"><span class="pl-v">In</span> [<span class="pl-c1">4</span>]: <span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>({<span class="pl-s">'series'</span>: <span class="pl-s1">pd</span>.<span class="pl-v">Series</span>(<span class="pl-en">range</span>(<span class="pl-c1">3</span>))})

<span class="pl-v">In</span> [<span class="pl-c1">5</span>]: <span class="pl-s1">df</span>[<span class="pl-s">"name"</span>] <span class="pl-c1">=</span> <span class="pl-s">"abc"</span>

<span class="pl-v">In</span> [<span class="pl-c1">6</span>]: <span class="pl-s1">df_copy</span> <span class="pl-c1">=</span> <span class="pl-s1">df</span>.<span class="pl-en">copy</span>()

<span class="pl-v">In</span> [<span class="pl-c1">7</span>]: <span class="pl-s1">df</span>.<span class="pl-s1">series</span>.<span class="pl-s1">loc</span>[<span class="pl-c1">2</span>] <span class="pl-c1">=</span> <span class="pl-c1">None</span>

<span class="pl-v">In</span> [<span class="pl-c1">8</span>]: <span class="pl-s1">df</span>
<span class="pl-v">Out</span>[<span class="pl-c1">8</span>]: 
   <span class="pl-s1">series</span> <span class="pl-s1">name</span>
<span class="pl-c1">0</span>     <span class="pl-c1">0.0</span>  <span class="pl-s1">abc</span>
<span class="pl-c1">1</span>     <span class="pl-c1">1.0</span>  <span class="pl-s1">abc</span>
<span class="pl-c1">2</span>     <span class="pl-v">NaN</span>  <span class="pl-s1">abc</span>

<span class="pl-v">In</span> [<span class="pl-c1">9</span>]: <span class="pl-s1">df_copy</span>
<span class="pl-v">Out</span>[<span class="pl-c1">9</span>]: 
   <span class="pl-s1">series</span> <span class="pl-s1">name</span>
<span class="pl-c1">0</span>       <span class="pl-c1">0</span>  <span class="pl-s1">abc</span>
<span class="pl-c1">1</span>       <span class="pl-c1">1</span>  <span class="pl-s1">abc</span>
<span class="pl-c1">2</span>       <span class="pl-c1">2</span>  <span class="pl-s1">abc</span>

<span class="pl-v">In</span> [<span class="pl-c1">10</span>]: <span class="pl-s1">df</span>[<span class="pl-s1">df</span>.<span class="pl-en">isnull</span>()] <span class="pl-c1">=</span> <span class="pl-s1">df_copy</span>

<span class="pl-c">#or</span>
<span class="pl-c">#df.where(-df.isnull(), df_copy, inplace=True)</span>
<span class="pl-c">#basically it's doing that at the end</span></pre></div>
<h4 dir="auto">Problem description</h4>
<p dir="auto">Pandas throws a TypeError:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File &quot;.../test_replace.py&quot;, line 8, in &lt;module&gt;
    df[df.isnull()] = df_copy
  File &quot;.../anaconda/lib/python2.7/site-packages/pandas/core/frame.py&quot;, line 2516, in __setitem__
    self._setitem_frame(key, value)
  File &quot;.../anaconda/lib/python2.7/site-packages/pandas/core/frame.py&quot;, line 2552, in _setitem_frame
    self._check_inplace_setting(value)
  File &quot;.../anaconda/lib/python2.7/site-packages/pandas/core/generic.py&quot;, line 3738, in _check_inplace_setting
    raise TypeError('Cannot do inplace boolean setting on '
TypeError: Cannot do inplace boolean setting on mixed-types with a non np.nan value"><pre class="notranslate"><span class="pl-v">Traceback</span> (<span class="pl-s1">most</span> <span class="pl-s1">recent</span> <span class="pl-s1">call</span> <span class="pl-s1">last</span>):
  <span class="pl-v">File</span> <span class="pl-s">".../test_replace.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">8</span>, <span class="pl-s1">in</span> <span class="pl-c1">&lt;</span><span class="pl-s1">module</span><span class="pl-c1">&gt;</span>
    <span class="pl-s1">df</span>[<span class="pl-s1">df</span>.<span class="pl-en">isnull</span>()] <span class="pl-c1">=</span> <span class="pl-s1">df_copy</span>
  <span class="pl-v">File</span> <span class="pl-s">".../anaconda/lib/python2.7/site-packages/pandas/core/frame.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">2516</span>, <span class="pl-s1">in</span> <span class="pl-s1">__setitem__</span>
    <span class="pl-s1">self</span>.<span class="pl-en">_setitem_frame</span>(<span class="pl-s1">key</span>, <span class="pl-s1">value</span>)
  <span class="pl-v">File</span> <span class="pl-s">".../anaconda/lib/python2.7/site-packages/pandas/core/frame.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">2552</span>, <span class="pl-s1">in</span> <span class="pl-s1">_setitem_frame</span>
    <span class="pl-s1">self</span>.<span class="pl-en">_check_inplace_setting</span>(<span class="pl-s1">value</span>)
  <span class="pl-v">File</span> <span class="pl-s">".../anaconda/lib/python2.7/site-packages/pandas/core/generic.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">3738</span>, <span class="pl-s1">in</span> <span class="pl-s1">_check_inplace_setting</span>
    <span class="pl-k">raise</span> <span class="pl-v">TypeError</span>(<span class="pl-s">'Cannot do inplace boolean setting on '</span>
<span class="pl-v">TypeError</span>: <span class="pl-v">Cannot</span> <span class="pl-s1">do</span> <span class="pl-s1">inplace</span> <span class="pl-s1">boolean</span> <span class="pl-s1">setting</span> <span class="pl-s1">on</span> <span class="pl-s1">mixed</span><span class="pl-c1">-</span><span class="pl-s1">types</span> <span class="pl-s1">with</span> <span class="pl-s1">a</span> <span class="pl-s1">non</span> <span class="pl-s1">np</span>.<span class="pl-s1">nan</span> <span class="pl-s1">value</span></pre></div>
<p dir="auto">I understand that in-place setting doesn't like to work with the mixed types, but I can't see a reason why it shouldn't work in this case and maybe check in "_check_inplace_setting()" is a bit too tight ?</p>
<h4 dir="auto">Expected Output</h4>
<p dir="auto">same as with df.where(-df.isnull(), df_copy)</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="In [12]: df.where(-df.isnull(), df_copy)
Out[12]: 
   series name
0     0.0  abc
1     1.0  abc
2     2.0  abc
"><pre class="notranslate"><span class="pl-v">In</span> [<span class="pl-c1">12</span>]: <span class="pl-s1">df</span>.<span class="pl-en">where</span>(<span class="pl-c1">-</span><span class="pl-s1">df</span>.<span class="pl-en">isnull</span>(), <span class="pl-s1">df_copy</span>)
<span class="pl-v">Out</span>[<span class="pl-c1">12</span>]: 
   <span class="pl-s1">series</span> <span class="pl-s1">name</span>
<span class="pl-c1">0</span>     <span class="pl-c1">0.0</span>  <span class="pl-s1">abc</span>
<span class="pl-c1">1</span>     <span class="pl-c1">1.0</span>  <span class="pl-s1">abc</span>
<span class="pl-c1">2</span>     <span class="pl-c1">2.0</span>  <span class="pl-s1">abc</span></pre></div>
<h4 dir="auto">Problem description</h4>
<p dir="auto"><code class="notranslate">pandas.DataFrame.where</code> seems to be not replacing NaTs properly.</p>
<p dir="auto">As in the example below, NaT values stay in data frame after applying <code class="notranslate">.where((pd.notnull(df)), None)</code></p>
<h4 dir="auto">Code sample</h4>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="In [26]: pd.__version__
Out[26]: '0.19.2'

In [27]: df
Out[27]: 
           d     v
0 2015-01-01  30.0
1        NaT  40.0
2 2015-01-03   NaN

In [28]: pd.notnull(df)
Out[28]: 
       d      v
0   True   True
1  False   True
2   True  False

In [29]: df.where((pd.notnull(df)), None)
Out[29]: 
           d     v
0 2015-01-01    30
1        NaT    40
2 2015-01-03  None"><pre class="notranslate"><span class="pl-v">In</span> [<span class="pl-c1">26</span>]: <span class="pl-s1">pd</span>.<span class="pl-s1">__version__</span>
<span class="pl-v">Out</span>[<span class="pl-c1">26</span>]: <span class="pl-s">'0.19.2'</span>

<span class="pl-v">In</span> [<span class="pl-c1">27</span>]: <span class="pl-s1">df</span>
<span class="pl-v">Out</span>[<span class="pl-c1">27</span>]: 
           <span class="pl-s1">d</span>     <span class="pl-s1">v</span>
<span class="pl-c1">0</span> <span class="pl-c1">2015</span><span class="pl-c1">-</span><span class="pl-c1">01</span><span class="pl-c1">-</span><span class="pl-c1">01</span>  <span class="pl-c1">30.0</span>
<span class="pl-c1">1</span>        <span class="pl-v">NaT</span>  <span class="pl-c1">40.0</span>
<span class="pl-c1">2</span> <span class="pl-c1">2015</span><span class="pl-c1">-</span><span class="pl-c1">01</span><span class="pl-c1">-</span><span class="pl-c1">03</span>   <span class="pl-v">NaN</span>

<span class="pl-v">In</span> [<span class="pl-c1">28</span>]: <span class="pl-s1">pd</span>.<span class="pl-en">notnull</span>(<span class="pl-s1">df</span>)
<span class="pl-v">Out</span>[<span class="pl-c1">28</span>]: 
       <span class="pl-s1">d</span>      <span class="pl-s1">v</span>
<span class="pl-c1">0</span>   <span class="pl-v">True</span>   <span class="pl-c1">True</span>
<span class="pl-c1">1</span>  <span class="pl-v">False</span>   <span class="pl-c1">True</span>
<span class="pl-c1">2</span>   <span class="pl-v">True</span>  <span class="pl-c1">False</span>

<span class="pl-v">In</span> [<span class="pl-c1">29</span>]: <span class="pl-s1">df</span>.<span class="pl-en">where</span>((<span class="pl-s1">pd</span>.<span class="pl-en">notnull</span>(<span class="pl-s1">df</span>)), <span class="pl-c1">None</span>)
<span class="pl-v">Out</span>[<span class="pl-c1">29</span>]: 
           <span class="pl-s1">d</span>     <span class="pl-s1">v</span>
<span class="pl-c1">0</span> <span class="pl-c1">2015</span><span class="pl-c1">-</span><span class="pl-c1">01</span><span class="pl-c1">-</span><span class="pl-c1">01</span>    <span class="pl-c1">30</span>
<span class="pl-c1">1</span>        <span class="pl-v">NaT</span>    <span class="pl-c1">40</span>
<span class="pl-c1">2</span> <span class="pl-c1">2015</span><span class="pl-c1">-</span><span class="pl-c1">01</span><span class="pl-c1">-</span><span class="pl-c1">03</span>  <span class="pl-c1">None</span></pre></div>
<details>
In [30]: pd.show_versions()
<h2 dir="auto">INSTALLED VERSIONS</h2>
<p dir="auto">commit: None<br>
python: 3.6.0.final.0<br>
python-bits: 64<br>
OS: Darwin<br>
OS-release: 16.0.0<br>
machine: x86_64<br>
processor: i386<br>
byteorder: little<br>
LC_ALL: None<br>
LANG: en_US.UTF-8<br>
LOCALE: en_US.UTF-8</p>
<p dir="auto">pandas: 0.19.2<br>
nose: None<br>
pip: 9.0.1<br>
setuptools: 34.3.1<br>
Cython: None<br>
numpy: 1.12.0<br>
scipy: 0.18.1<br>
statsmodels: None<br>
xarray: None<br>
IPython: 5.3.0<br>
sphinx: None<br>
patsy: None<br>
dateutil: 2.6.0<br>
pytz: 2016.10<br>
blosc: None<br>
bottleneck: None<br>
tables: None<br>
numexpr: None<br>
matplotlib: 2.0.0<br>
openpyxl: None<br>
xlrd: None<br>
xlwt: None<br>
xlsxwriter: None<br>
lxml: None<br>
bs4: None<br>
html5lib: 0.9999999<br>
httplib2: None<br>
apiclient: None<br>
sqlalchemy: None<br>
pymysql: None<br>
psycopg2: None<br>
jinja2: 2.9.5<br>
boto: None<br>
pandas_datareader: None</p>
</details>