<h4 dir="auto">A small, complete example of the issue</h4>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# Your code here
df = pd.DataFrame(columns=['a','b','c'])    
df.groupby('a',as_index=False).agg({'b':'nunique'})"><pre class="notranslate"><span class="pl-c"># Your code here</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-s1">columns</span><span class="pl-c1">=</span>[<span class="pl-s">'a'</span>,<span class="pl-s">'b'</span>,<span class="pl-s">'c'</span>])    
<span class="pl-s1">df</span>.<span class="pl-en">groupby</span>(<span class="pl-s">'a'</span>,<span class="pl-s1">as_index</span><span class="pl-c1">=</span><span class="pl-c1">False</span>).<span class="pl-en">agg</span>({<span class="pl-s">'b'</span>:<span class="pl-s">'nunique'</span>})</pre></div>
<h4 dir="auto">Expected Output</h4>
<p dir="auto">We shouldn't get an Exception</p>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<details>
INSTALLED VERSIONS
------------------
commit: None
python: 2.7.12.final.0
python-bits: 64
OS: Darwin
OS-release: 16.0.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: None.None
<p dir="auto">pandas: 0.19.0<br>
nose: 1.3.7<br>
pip: 8.1.2<br>
setuptools: 27.2.0<br>
Cython: 0.25.1<br>
numpy: 1.11.2<br>
scipy: 0.18.1<br>
statsmodels: 0.6.1<br>
xarray: None<br>
IPython: 5.1.0<br>
sphinx: 1.4.8<br>
patsy: 0.4.1<br>
dateutil: 2.5.3<br>
pytz: 2016.7<br>
blosc: None<br>
bottleneck: 1.1.0<br>
tables: 3.3.0<br>
numexpr: 2.6.1<br>
matplotlib: 1.5.3<br>
openpyxl: 2.4.0<br>
xlrd: 1.0.0<br>
xlwt: 1.1.2<br>
xlsxwriter: 0.9.3<br>
lxml: 3.6.4<br>
bs4: 4.5.1<br>
html5lib: None<br>
httplib2: None<br>
apiclient: None<br>
sqlalchemy: 1.0.9<br>
pymysql: None<br>
psycopg2: None<br>
jinja2: 2.8<br>
boto: 2.43.0<br>
pandas_datareader: None</p>
</details>
i get the following output 
<p dir="auto">Traceback (most recent call last):<br>
File "/Users/ilangadassi/Documents/workspace/python/MyTests/test1.py", line 75, in <br>
testDfGroup()<br>
File "/Users/ilangadassi/Documents/workspace/python/MyTests/test1.py", line 71, in testDfGroup<br>
df.groupby('a',as_index=False).agg({'b':'nunique'})<br>
File "/Users/ilangadassi/anaconda/lib/python2.7/site-packages/pandas/core/groupby.py", line 3774, in aggregate<br>
return super(DataFrameGroupBy, self).aggregate(arg, *args, **kwargs)<br>
File "/Users/ilangadassi/anaconda/lib/python2.7/site-packages/pandas/core/groupby.py", line 3272, in aggregate<br>
result, how = self._aggregate(arg, _level=_level, *args, **kwargs)<br>
File "/Users/ilangadassi/anaconda/lib/python2.7/site-packages/pandas/core/base.py", line 549, in _aggregate<br>
result = _agg(arg, _agg_1dim)<br>
File "/Users/ilangadassi/anaconda/lib/python2.7/site-packages/pandas/core/base.py", line 500, in _agg<br>
result[fname] = func(fname, agg_how)<br>
File "/Users/ilangadassi/anaconda/lib/python2.7/site-packages/pandas/core/base.py", line 483, in _agg_1dim<br>
return colg.aggregate(how, _level=(_level or 0) + 1)<br>
File "/Users/ilangadassi/anaconda/lib/python2.7/site-packages/pandas/core/groupby.py", line 2660, in aggregate<br>
return getattr(self, func_or_funcs)(*args, **kwargs)<br>
File "/Users/ilangadassi/anaconda/lib/python2.7/site-packages/pandas/core/groupby.py", line 3023, in nunique<br>
res = out if ids[0] != -1 else out[1:]<br>
IndexError: index 0 is out of bounds for axis 0 with size 0</p>
<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="In [18]: b = pandas.Series()

In [19]: g = b.groupby(level = 0)

In [20]: g.nunique()
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
&lt;ipython-input-20-fbbfc3108eac&gt; in &lt;module&gt;()
----&gt; 1 g.nunique()

/usr/local/lib/python2.7/dist-packages/pandas/core/groupby.pyc in nunique(self, dropna)
   2693 
   2694         out = np.add.reduceat(inc, idx).astype('int64', copy=False)
-&gt; 2695         return Series(out if ids[0] != -1 else out[1:],
   2696                       index=self.grouper.result_index,
   2697                       name=self.name)

IndexError: index 0 is out of bounds for axis 0 with size 0"><pre class="notranslate"><span class="pl-v">In</span> [<span class="pl-c1">18</span>]: <span class="pl-s1">b</span> <span class="pl-c1">=</span> <span class="pl-s1">pandas</span>.<span class="pl-v">Series</span>()

<span class="pl-v">In</span> [<span class="pl-c1">19</span>]: <span class="pl-s1">g</span> <span class="pl-c1">=</span> <span class="pl-s1">b</span>.<span class="pl-en">groupby</span>(<span class="pl-s1">level</span> <span class="pl-c1">=</span> <span class="pl-c1">0</span>)

<span class="pl-v">In</span> [<span class="pl-c1">20</span>]: <span class="pl-s1">g</span>.<span class="pl-en">nunique</span>()
<span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span>
<span class="pl-v">IndexError</span>                                <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-c1">&lt;</span><span class="pl-s1">ipython</span><span class="pl-c1">-</span><span class="pl-s1">input</span><span class="pl-c1">-</span><span class="pl-c1">20</span><span class="pl-c1">-</span><span class="pl-s1">fbbfc3108eac</span><span class="pl-c1">&gt;</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-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">1</span> <span class="pl-s1">g</span>.<span class="pl-en">nunique</span>()

<span class="pl-c1">/</span><span class="pl-s1">usr</span><span class="pl-c1">/</span><span class="pl-s1">local</span><span class="pl-c1">/</span><span class="pl-s1">lib</span><span class="pl-c1">/</span><span class="pl-s1">python2</span>.<span class="pl-c1">7</span><span class="pl-c1">/</span><span class="pl-s1">dist</span><span class="pl-c1">-</span><span class="pl-s1">packages</span><span class="pl-c1">/</span><span class="pl-s1">pandas</span><span class="pl-c1">/</span><span class="pl-s1">core</span><span class="pl-c1">/</span><span class="pl-s1">groupby</span>.<span class="pl-s1">pyc</span> <span class="pl-c1">in</span> <span class="pl-en">nunique</span>(<span class="pl-s1">self</span>, <span class="pl-s1">dropna</span>)
   <span class="pl-c1">2693</span> 
   <span class="pl-c1">2694</span>         <span class="pl-s1">out</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-s1">add</span>.<span class="pl-en">reduceat</span>(<span class="pl-s1">inc</span>, <span class="pl-s1">idx</span>).<span class="pl-en">astype</span>(<span class="pl-s">'int64'</span>, <span class="pl-s1">copy</span><span class="pl-c1">=</span><span class="pl-c1">False</span>)
<span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">2695</span>         <span class="pl-s1">return</span> <span class="pl-v">Series</span>(<span class="pl-s1">out</span> <span class="pl-k">if</span> <span class="pl-s1">ids</span>[<span class="pl-c1">0</span>] <span class="pl-c1">!=</span> <span class="pl-c1">-</span><span class="pl-c1">1</span> <span class="pl-k">else</span> <span class="pl-s1">out</span>[<span class="pl-c1">1</span>:],
   <span class="pl-c1">2696</span>                       <span class="pl-s1">index</span><span class="pl-c1">=</span><span class="pl-s1">self</span>.<span class="pl-s1">grouper</span>.<span class="pl-s1">result_index</span>,
   <span class="pl-c1">2697</span>                       <span class="pl-s1">name</span><span class="pl-c1">=</span><span class="pl-s1">self</span>.<span class="pl-s1">name</span>)

<span class="pl-v">IndexError</span>: <span class="pl-s1">index</span> <span class="pl-c1">0</span> <span class="pl-c1">is</span> <span class="pl-s1">out</span> <span class="pl-s1">of</span> <span class="pl-s1">bounds</span> <span class="pl-s1">for</span> <span class="pl-s1">axis</span> <span class="pl-c1">0</span> <span class="pl-k">with</span> <span class="pl-s1">size</span> <span class="pl-c1">0</span></pre></div>
<h4 dir="auto">Expected Output</h4>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="0"><pre class="notranslate"><span class="pl-c1">0</span></pre></div>
<h4 dir="auto">output of <code class="notranslate">pd.show_versions()</code></h4>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="INSTALLED VERSIONS
------------------
commit: None
python: 2.7.6.final.0
python-bits: 64
OS: Linux
OS-release: 3.13.0-79-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.17.1
nose: 1.3.1
pip: 8.0.2
setuptools: 20.1.1
Cython: None
numpy: 1.10.4
scipy: 0.13.3
statsmodels: 0.5.0
IPython: 4.1.1
sphinx: None
patsy: 0.2.1
dateutil: 2.4.2
pytz: 2015.7
blosc: None
bottleneck: None
tables: 3.1.1
numexpr: 2.2.2
matplotlib: 1.3.1
openpyxl: 1.7.0
xlrd: 0.9.2
xlwt: 0.7.5
xlsxwriter: None
lxml: None
bs4: 4.2.1
html5lib: 0.999
httplib2: 0.8
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
Jinja2: None"><pre class="notranslate"><code class="notranslate">INSTALLED VERSIONS
------------------
commit: None
python: 2.7.6.final.0
python-bits: 64
OS: Linux
OS-release: 3.13.0-79-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.17.1
nose: 1.3.1
pip: 8.0.2
setuptools: 20.1.1
Cython: None
numpy: 1.10.4
scipy: 0.13.3
statsmodels: 0.5.0
IPython: 4.1.1
sphinx: None
patsy: 0.2.1
dateutil: 2.4.2
pytz: 2015.7
blosc: None
bottleneck: None
tables: 3.1.1
numexpr: 2.2.2
matplotlib: 1.3.1
openpyxl: 1.7.0
xlrd: 0.9.2
xlwt: 0.7.5
xlsxwriter: None
lxml: None
bs4: 4.2.1
html5lib: 0.999
httplib2: 0.8
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
Jinja2: None
</code></pre></div>