<h4 dir="auto">Code Sample, a copy-pastable example if possible</h4>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="pd.DataFrame(index=pd.MultiIndex.from_product([range(3), range(3)])).drop(5) # Raises
pd.DataFrame(index=pd.MultiIndex.from_product([range(3), range(3)])).drop(5, level=0) # Same operation, does nothing, but silently"><pre class="notranslate"><span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>(<span class="pl-s1">index</span><span class="pl-c1">=</span><span class="pl-s1">pd</span>.<span class="pl-v">MultiIndex</span>.<span class="pl-en">from_product</span>([<span class="pl-en">range</span>(<span class="pl-c1">3</span>), <span class="pl-en">range</span>(<span class="pl-c1">3</span>)])).<span class="pl-en">drop</span>(<span class="pl-c1">5</span>) <span class="pl-c"># Raises</span>
<span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>(<span class="pl-s1">index</span><span class="pl-c1">=</span><span class="pl-s1">pd</span>.<span class="pl-v">MultiIndex</span>.<span class="pl-en">from_product</span>([<span class="pl-en">range</span>(<span class="pl-c1">3</span>), <span class="pl-en">range</span>(<span class="pl-c1">3</span>)])).<span class="pl-en">drop</span>(<span class="pl-c1">5</span>, <span class="pl-s1">level</span><span class="pl-c1">=</span><span class="pl-c1">0</span>) <span class="pl-c"># Same operation, does nothing, but silently</span></pre></div>
<h4 dir="auto">Problem description</h4>
<p dir="auto">Since one expects <code class="notranslate">drop()</code> to always raise an error if the requested label is not found, this can be misleading.</p>
<p dir="auto">It is not even a matter of partial vs. full labels, since the first example above has a partial label.</p>
<h4 dir="auto">Expected Output</h4>
<p dir="auto">The same.</p>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<details>
<h2 dir="auto">INSTALLED VERSIONS</h2>
<p dir="auto">commit: <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/pandas-dev/pandas/commit/2a0e54bc841f27164b116135ebda4b74bae2fc4a/hovercard" href="https://github.com/pandas-dev/pandas/commit/2a0e54bc841f27164b116135ebda4b74bae2fc4a"><tt>2a0e54b</tt></a><br>
python: 3.5.3.final.0<br>
python-bits: 64<br>
OS: Linux<br>
OS-release: 4.9.0-4-amd64<br>
machine: x86_64<br>
processor:<br>
byteorder: little<br>
LC_ALL: None<br>
LANG: it_IT.UTF-8<br>
LOCALE: it_IT.UTF-8</p>
<p dir="auto">pandas: 0.22.0.dev0+251.g2a0e54bc8.dirty<br>
pytest: 3.2.3<br>
pip: 9.0.1<br>
setuptools: 36.7.0<br>
Cython: 0.25.2<br>
numpy: 1.12.1<br>
scipy: 0.19.0<br>
pyarrow: None<br>
xarray: None<br>
IPython: 6.2.1<br>
sphinx: 1.5.6<br>
patsy: 0.4.1<br>
dateutil: 2.6.1<br>
pytz: 2017.2<br>
blosc: None<br>
bottleneck: 1.2.0dev<br>
tables: 3.3.0<br>
numexpr: 2.6.1<br>
feather: 0.3.1<br>
matplotlib: 2.0.0<br>
openpyxl: None<br>
xlrd: 1.0.0<br>
xlwt: 1.1.2<br>
xlsxwriter: 0.9.6<br>
lxml: None<br>
bs4: 4.5.3<br>
html5lib: 0.999999999<br>
sqlalchemy: 1.0.15<br>
pymysql: None<br>
psycopg2: None<br>
jinja2: 2.10<br>
s3fs: None<br>
fastparquet: None<br>
pandas_gbq: None<br>
pandas_datareader: 0.2.1</p>
</details>
<h4 dir="auto">Code Sample, a copy-pastable example if possible</h4>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import pandas as pd

s = pd.Series(
    [1, 2, 3, 4],
    index=['a', 'a', 'b', 'b'],
    dtype=object
)
print(s.groupby(lambda x: x).sum())  # Works fine.
print(s.groupby(lambda x: x).mean())  # Raises `DataError`."><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">pandas</span> <span class="pl-k">as</span> <span class="pl-s1">pd</span>

<span class="pl-s1">s</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">Series</span>(
    [<span class="pl-c1">1</span>, <span class="pl-c1">2</span>, <span class="pl-c1">3</span>, <span class="pl-c1">4</span>],
    <span class="pl-s1">index</span><span class="pl-c1">=</span>[<span class="pl-s">'a'</span>, <span class="pl-s">'a'</span>, <span class="pl-s">'b'</span>, <span class="pl-s">'b'</span>],
    <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s1">object</span>
)
<span class="pl-en">print</span>(<span class="pl-s1">s</span>.<span class="pl-en">groupby</span>(<span class="pl-k">lambda</span> <span class="pl-s1">x</span>: <span class="pl-s1">x</span>).<span class="pl-en">sum</span>())  <span class="pl-c"># Works fine.</span>
<span class="pl-en">print</span>(<span class="pl-s1">s</span>.<span class="pl-en">groupby</span>(<span class="pl-k">lambda</span> <span class="pl-s1">x</span>: <span class="pl-s1">x</span>).<span class="pl-en">mean</span>())  <span class="pl-c"># Raises `DataError`.</span></pre></div>
<h4 dir="auto">Problem description</h4>
<p dir="auto"><code class="notranslate">GroupBy</code> objects behave differently for different aggregation functions when used on non-numeric data types. <a href="https://github.com/pandas-dev/pandas/blob/632204359249093d1305e71183be932ceceeee78/pandas/core/groupby/groupby.py#L1263"><code class="notranslate">mean</code></a> (amongst others) <a href="https://github.com/pandas-dev/pandas/blob/632204359249093d1305e71183be932ceceeee78/pandas/core/groupby/groupby.py#L1272">re-raises on <code class="notranslate">GroupByError</code></a> while <a href="https://github.com/pandas-dev/pandas/blob/632204359249093d1305e71183be932ceceeee78/pandas/core/groupby/groupby.py#L1431"><code class="notranslate">sum</code></a> (amongst others) <a href="https://github.com/pandas-dev/pandas/blob/632204359249093d1305e71183be932ceceeee78/pandas/core/groupby/groupby.py#L1391">falls back on <code class="notranslate">np.sum</code></a>.</p>
<p dir="auto">The expected behavior would be that <em>all</em> such functions either fall back on their <code class="notranslate">numpy</code> equivalent or re-raise on <code class="notranslate">DataError</code> for non-numeric data.</p>
<h4 dir="auto">Expected Output</h4>
<p dir="auto">All such functions should either fall back on their <code class="notranslate">numpy</code> equivalent or re-raise on <code class="notranslate">DataError</code> for non-numeric data.</p>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<details>
<h2 dir="auto">INSTALLED VERSIONS</h2>
<p dir="auto">commit: None<br>
python: 3.5.2.final.0<br>
python-bits: 64<br>
OS: Linux<br>
OS-release: 4.4.0-119-generic<br>
machine: x86_64<br>
processor: x86_64<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.22.0<br>
pytest: None<br>
pip: 9.0.1<br>
setuptools: 34.2.0<br>
Cython: None<br>
numpy: 1.14.0<br>
scipy: 1.0.0<br>
pyarrow: None<br>
xarray: None<br>
IPython: 5.2.2<br>
sphinx: None<br>
patsy: None<br>
dateutil: 2.6.1<br>
pytz: 2017.3<br>
blosc: None<br>
bottleneck: None<br>
tables: None<br>
numexpr: None<br>
feather: None<br>
matplotlib: 2.0.0<br>
openpyxl: None<br>
xlrd: None<br>
xlwt: None<br>
xlsxwriter: 0.7.3<br>
lxml: None<br>
bs4: 4.4.1<br>
html5lib: 0.9999999<br>
sqlalchemy: None<br>
pymysql: None<br>
psycopg2: None<br>
jinja2: 2.9.5<br>
s3fs: None<br>
fastparquet: None<br>
pandas_gbq: None<br>
pandas_datareader: None</p>
</details>