<p dir="auto">Here are 2 ways to drop rows from a pandas data-frame based on a condition:</p>
<ol dir="auto">
<li>
<p dir="auto"><code class="notranslate">df = df[condition]</code></p>
</li>
<li>
<p dir="auto"><code class="notranslate">df.drop(df[condition].index, axis=0, inplace=True)</code></p>
</li>
</ol>
<p dir="auto">The first one does not do it <em>inplace</em>, right?</p>
<p dir="auto">The second one does not work as expected when the index is not unique, so the user would need to <code class="notranslate">reset_index()</code> then <code class="notranslate">set_index()</code> back.</p>
<p dir="auto"><strong>Question</strong><br>
Would it be possible to have column dropping based directly on the condition?<br>
e.g.<br>
<code class="notranslate">df.drop(condition, axis=0, inplace=True)</code></p>
<p dir="auto">sum() is giving 0.0 as the total, rather than NaN, when the entire row/column is NaN.</p>
<p dir="auto">Note that this bug does not arise in pandas 17.1 with numpy 1.11.0, running on Ubuntu.</p>
<h4 dir="auto">Code Sample, a copy-pastable example if possible</h4>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import numpy as np
df = pd.DataFrame([[np.nan,np.nan,np.nan,np.nan],
              [1,np.nan,np.nan,np.nan],[2,2,2,np.nan]],columns=['a','b','c','d'])
df.sum(skipna=True)   # should be true by default. Same result if argument is omitted"><pre class="notranslate"><code class="notranslate">import numpy as np
df = pd.DataFrame([[np.nan,np.nan,np.nan,np.nan],
              [1,np.nan,np.nan,np.nan],[2,2,2,np.nan]],columns=['a','b','c','d'])
df.sum(skipna=True)   # should be true by default. Same result if argument is omitted
</code></pre></div>
<h4 dir="auto">Actual Output</h4>
<p dir="auto">a    3.0<br>
b    2.0<br>
c    2.0<br>
d    0.0</p>
<h4 dir="auto">Expected Output</h4>
<p dir="auto">a    3.0<br>
b    2.0<br>
c    2.0<br>
d    NaN</p>
<h4 dir="auto">output of <code class="notranslate">pd.show_versions()</code></h4>
<h2 dir="auto">INSTALLED VERSIONS</h2>
<p dir="auto">commit: None<br>
python: 2.7.6.final.0<br>
python-bits: 64<br>
OS: Darwin<br>
OS-release: 15.6.0<br>
machine: x86_64<br>
processor: i386<br>
byteorder: little<br>
LC_ALL: None<br>
LANG: en_US.UTF-8</p>
<p dir="auto">pandas: 0.18.1<br>
nose: 1.3.7<br>
pip: 8.1.2<br>
setuptools: 23.1.0<br>
Cython: 0.24<br>
numpy: 1.11.1<br>
scipy: 0.17.1<br>
statsmodels: 0.6.1<br>
xarray: None<br>
IPython: 4.1.2<br>
sphinx: None<br>
patsy: 0.4.1<br>
dateutil: 2.2<br>
pytz: 2014.7<br>
blosc: None<br>
bottleneck: 1.1.0<br>
tables: 3.2.2<br>
numexpr: 2.6.0<br>
matplotlib: 1.5.1<br>
openpyxl: 2.3.4<br>
xlrd: 0.9.4<br>
xlwt: None<br>
xlsxwriter: None<br>
lxml: 3.6.0<br>
bs4: 4.4.1<br>
html5lib: 0.999<br>
httplib2: 0.8<br>
apiclient: 1.2<br>
sqlalchemy: 1.0.12<br>
pymysql: None<br>
psycopg2: 2.5.4 (dt dec pq3 ext)<br>
jinja2: 2.7.2<br>
boto: 2.40.0<br>
pandas_datareader: None</p>