<p dir="auto">When the returned dataframe(or series) have the same length of the original dataframe. The index for grouped keys are missing. For example:<br>
a = pd.DataFrame({'l':['a','a','b','b','c'],'x':[1,2,3,4,5]})<br>
a.groupby('l')['x'].apply(lambda r: r)</p>
<p dir="auto">output:<br>
0    1<br>
1    2<br>
2    3<br>
3    4<br>
4    5</p>
<p dir="auto">Notice the key 'l' is missing in the output.</p>
<p dir="auto">This cause some problem if one is not sure whether the returned dataframe or sereires will have the same length.</p>
<p dir="auto">Best regards</p>
<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
"><pre class="notranslate"><span class="pl-c"># Your code here</span></pre></div>
<h4 dir="auto">Expected Output</h4>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<details>
# Paste the output here pd.show_versions() here
</details>
<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="import pandas as pd
df1 = pd.DataFrame.from_items([('A', [1,2,3]), ('B', [4, 5, 6])])
df2 = pd.DataFrame.from_items([('A', [pd.datetime(1970,1,1), pd.datetime(1970,1,1), pd.datetime(1970,1,1)]), ('B', [4, 5, 6])])
f = lambda row: [row.B + 3]
r1 = df1.apply(f, axis=1)
r2 = df2.apply(f, axis=1)
# bug: r1 and r2 are different and different in shape.
# expect: r1 and r2 to be the same values and shape.
r1
r2
# a clue to the difference:
(df1._is_mixed_type,df1._is_datelike_mixed_type)
(df2._is_mixed_type,df2._is_datelike_mixed_type)
"><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">df1</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>.<span class="pl-en">from_items</span>([(<span class="pl-s">'A'</span>, [<span class="pl-c1">1</span>,<span class="pl-c1">2</span>,<span class="pl-c1">3</span>]), (<span class="pl-s">'B'</span>, [<span class="pl-c1">4</span>, <span class="pl-c1">5</span>, <span class="pl-c1">6</span>])])
<span class="pl-s1">df2</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>.<span class="pl-en">from_items</span>([(<span class="pl-s">'A'</span>, [<span class="pl-s1">pd</span>.<span class="pl-en">datetime</span>(<span class="pl-c1">1970</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</span>), <span class="pl-s1">pd</span>.<span class="pl-en">datetime</span>(<span class="pl-c1">1970</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</span>), <span class="pl-s1">pd</span>.<span class="pl-en">datetime</span>(<span class="pl-c1">1970</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</span>)]), (<span class="pl-s">'B'</span>, [<span class="pl-c1">4</span>, <span class="pl-c1">5</span>, <span class="pl-c1">6</span>])])
<span class="pl-s1">f</span> <span class="pl-c1">=</span> <span class="pl-k">lambda</span> <span class="pl-s1">row</span>: [<span class="pl-s1">row</span>.<span class="pl-v">B</span> <span class="pl-c1">+</span> <span class="pl-c1">3</span>]
<span class="pl-s1">r1</span> <span class="pl-c1">=</span> <span class="pl-s1">df1</span>.<span class="pl-en">apply</span>(<span class="pl-s1">f</span>, <span class="pl-s1">axis</span><span class="pl-c1">=</span><span class="pl-c1">1</span>)
<span class="pl-s1">r2</span> <span class="pl-c1">=</span> <span class="pl-s1">df2</span>.<span class="pl-en">apply</span>(<span class="pl-s1">f</span>, <span class="pl-s1">axis</span><span class="pl-c1">=</span><span class="pl-c1">1</span>)
<span class="pl-c"># bug: r1 and r2 are different and different in shape.</span>
<span class="pl-c"># expect: r1 and r2 to be the same values and shape.</span>
<span class="pl-s1">r1</span>
<span class="pl-s1">r2</span>
<span class="pl-c"># a clue to the difference:</span>
(<span class="pl-s1">df1</span>.<span class="pl-s1">_is_mixed_type</span>,<span class="pl-s1">df1</span>.<span class="pl-s1">_is_datelike_mixed_type</span>)
(<span class="pl-s1">df2</span>.<span class="pl-s1">_is_mixed_type</span>,<span class="pl-s1">df2</span>.<span class="pl-s1">_is_datelike_mixed_type</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    [7]
1    [8]
2    [9]"><pre class="notranslate"><span class="pl-c1">0</span>    [<span class="pl-c1">7</span>]
<span class="pl-c1">1</span>    [<span class="pl-c1">8</span>]
<span class="pl-c1">2</span>    [<span class="pl-c1">9</span>]</pre></div>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<details>
## INSTALLED VERSIONS
<p dir="auto">commit: None<br>
python: 3.5.1.final.0<br>
python-bits: 64<br>
OS: Windows<br>
OS-release: 10<br>
machine: AMD64<br>
processor: Intel64 Family 6 Model 58 Stepping 9, GenuineIntel<br>
byteorder: little<br>
LC_ALL: None<br>
LANG: None</p>
<p dir="auto">pandas: 0.18.1<br>
nose: None<br>
pip: 8.1.2<br>
setuptools: 20.3<br>
Cython: None<br>
numpy: 1.11.1<br>
scipy: None<br>
statsmodels: None<br>
xarray: None<br>
IPython: None<br>
sphinx: None<br>
patsy: None<br>
dateutil: 2.5.3<br>
pytz: 2016.6.1<br>
blosc: None<br>
bottleneck: None<br>
tables: None<br>
numexpr: None<br>
matplotlib: None<br>
openpyxl: None<br>
xlrd: None<br>
xlwt: None<br>
xlsxwriter: None<br>
lxml: None<br>
bs4: None<br>
html5lib: None<br>
httplib2: None<br>
apiclient: None<br>
sqlalchemy: None<br>
pymysql: None<br>
psycopg2: None<br>
jinja2: None<br>
boto: None<br>
pandas_datareader: None</p>
</details>