<p dir="auto">See repro below:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import pandas as pd
df_with_ts = pd.DataFrame(data=[['BL', pd.Timestamp('2015-02-01')], ['TH', pd.Timestamp('2015-02-02')]], columns=['item', 'date'])
res = df_with_ts.groupby(['date']).apply(lambda x: pd.Series(x['item'].unique()[0]))
In []: res                                                                                                                                                            
Out[]:                                                                                                                                                                
                    0                                                                                                                                                   
date                                                                                                                                                                    
2015-02-01        NaT                                                                                                                                                   
2015-02-02 2015-02-17                                                                                                                                                   

In []: res.dtypes                                                                                                                                                     
Out[]:                                                                                                                                                                
0    datetime64[ns]                                                                                                                                                     
dtype: object              "><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">df_with_ts</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>(<span class="pl-s1">data</span><span class="pl-c1">=</span>[[<span class="pl-s">'BL'</span>, <span class="pl-s1">pd</span>.<span class="pl-v">Timestamp</span>(<span class="pl-s">'2015-02-01'</span>)], [<span class="pl-s">'TH'</span>, <span class="pl-s1">pd</span>.<span class="pl-v">Timestamp</span>(<span class="pl-s">'2015-02-02'</span>)]], <span class="pl-s1">columns</span><span class="pl-c1">=</span>[<span class="pl-s">'item'</span>, <span class="pl-s">'date'</span>])
<span class="pl-s1">res</span> <span class="pl-c1">=</span> <span class="pl-s1">df_with_ts</span>.<span class="pl-en">groupby</span>([<span class="pl-s">'date'</span>]).<span class="pl-en">apply</span>(<span class="pl-k">lambda</span> <span class="pl-s1">x</span>: <span class="pl-s1">pd</span>.<span class="pl-v">Series</span>(<span class="pl-s1">x</span>[<span class="pl-s">'item'</span>].<span class="pl-en">unique</span>()[<span class="pl-c1">0</span>]))
<span class="pl-v">In</span> [<span class="pl-s1"></span>]: <span class="pl-s1">res</span>                                                                                                                                                            
<span class="pl-v">Out</span>[<span class="pl-s1"></span>]:                                                                                                                                                                
                    <span class="pl-c1">0</span>                                                                                                                                                   
<span class="pl-s1">date</span>                                                                                                                                                                    
<span class="pl-c1">2015</span><span class="pl-c1">-</span><span class="pl-c1">02</span><span class="pl-c1">-</span><span class="pl-c1">01</span>        <span class="pl-v">NaT</span>                                                                                                                                                   
<span class="pl-c1">2015</span><span class="pl-c1">-</span><span class="pl-c1">02</span><span class="pl-c1">-</span><span class="pl-c1">02</span> <span class="pl-c1">2015</span><span class="pl-c1">-</span><span class="pl-c1">02</span><span class="pl-c1">-</span><span class="pl-c1">17</span>                                                                                                                                                   

<span class="pl-v">In</span> [<span class="pl-s1"></span>]: <span class="pl-s1">res</span>.<span class="pl-s1">dtypes</span>                                                                                                                                                     
<span class="pl-v">Out</span>[]:                                                                                                                                                                
<span class="pl-c1">0</span>    <span class="pl-s1">datetime64</span>[<span class="pl-s1">ns</span>]                                                                                                                                                     
<span class="pl-s1">dtype</span>: <span class="pl-s1">object</span>              </pre></div>
<p dir="auto">It looks like this is happening because pd.Timestamp('TH') is valid and results in no exceptions. If you replace the string 'TH' with something else then the resulting column's dtype is object, as expected. The order of columns in the above example does not matter.</p>
<p dir="auto">For comparison, this case works as expected:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="df = pd.DataFrame(data=[['BL', '2015-02-01'], ['TH', '2015-02-02']], columns=['item', 'date'])
res = df.groupby(['date']).apply(lambda x: pd.Series(x['item'].unique()[0]))                                                                                                                                            

In []: res                                                                                                                                                            
Out[]:                                                                                                                                                                
             0                                                                                                                                                          
date                                                                                                                                                                    
2015-02-01  BL                                                                                                                                                          
2015-02-02  TH                                                                                          

In []: res.dtypes                                                                                                                                                     
Out[]:                                                                                                                                                                
0    object                                                                                                                                                             
dtype: object                                                                              "><pre class="notranslate"><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">data</span><span class="pl-c1">=</span>[[<span class="pl-s">'BL'</span>, <span class="pl-s">'2015-02-01'</span>], [<span class="pl-s">'TH'</span>, <span class="pl-s">'2015-02-02'</span>]], <span class="pl-s1">columns</span><span class="pl-c1">=</span>[<span class="pl-s">'item'</span>, <span class="pl-s">'date'</span>])
<span class="pl-s1">res</span> <span class="pl-c1">=</span> <span class="pl-s1">df</span>.<span class="pl-en">groupby</span>([<span class="pl-s">'date'</span>]).<span class="pl-en">apply</span>(<span class="pl-k">lambda</span> <span class="pl-s1">x</span>: <span class="pl-s1">pd</span>.<span class="pl-v">Series</span>(<span class="pl-s1">x</span>[<span class="pl-s">'item'</span>].<span class="pl-en">unique</span>()[<span class="pl-c1">0</span>]))                                                                                                                                            

<span class="pl-v">In</span> [<span class="pl-s1"></span>]: <span class="pl-s1">res</span>                                                                                                                                                            
<span class="pl-v">Out</span>[<span class="pl-s1"></span>]:                                                                                                                                                                
             <span class="pl-c1">0</span>                                                                                                                                                          
<span class="pl-s1">date</span>                                                                                                                                                                    
<span class="pl-c1">2015</span><span class="pl-c1">-</span><span class="pl-c1">02</span><span class="pl-c1">-</span><span class="pl-c1">01</span>  <span class="pl-v">BL</span>                                                                                                                                                          
<span class="pl-c1">2015</span><span class="pl-c1">-</span><span class="pl-c1">02</span><span class="pl-c1">-</span><span class="pl-c1">02</span>  <span class="pl-v">TH</span>                                                                                          

<span class="pl-v">In</span> [<span class="pl-s1"></span>]: <span class="pl-s1">res</span>.<span class="pl-s1">dtypes</span>                                                                                                                                                     
<span class="pl-v">Out</span>[]:                                                                                                                                                                
<span class="pl-c1">0</span>    <span class="pl-s1">object</span>                                                                                                                                                             
<span class="pl-s1">dtype</span>: <span class="pl-s1">object</span>                                                                              </pre></div>
<p dir="auto">output of show_versions() below (using Miniconda):</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="In []: from pandas.util.print_versions import show_versions                                                                                                            

In []: show_versions()                                                                                                                                                 

INSTALLED VERSIONS                                                                                                                                                      
------------------                                                                                                                                                      
commit: None                                                                                                                                                            
python: 2.7.9.final.0                                                                                                                                                   
python-bits: 64                                                                                                                                                         
OS: Windows                                                                                                                                                             
OS-release: 7                                                                                                                                                           
machine: AMD64                                                                                                                                                          
processor: Intel64 Family 6 Model 60 Stepping 3, GenuineIntel                                                                                                           
byteorder: little                                                                                                                                                       
LC_ALL: None                                                                                                                                                            
LANG: None                                                                                                                                                              

pandas: 0.15.2                                                                                                                                                          
nose: 1.3.4                                                                                                                                                             
Cython: 0.21.2                                                                                                                                                          
numpy: 1.8.2                                                                                                                                                            
scipy: 0.14.0                                                                                                                                                           
statsmodels: 0.5.0                                                                                                                                                      
IPython: 2.3.0                                                                                                                                                          
sphinx: 1.2.3                                                                                                                                                           
patsy: 0.2.1                                                                                                                                                            
dateutil: 2.2                                                                                                                                                           
pytz: 2014.9                                                                                                                                                            
bottleneck: 0.8.0                                                                                                                                                       
tables: 3.1.1                                                                                                                                                           
numexpr: 2.3.1                                                                                                                                                          
matplotlib: 1.4.0                                                                                                                                                       
openpyxl: 2.0.2                                                                                                                                                         
xlrd: 0.9.3                                                                                                                                                             
xlwt: 0.7.5                                                                                                                                                             
xlsxwriter: 0.6.6                                                                                                                                                       
lxml: 3.4.1                                                                                                                                                             
bs4: 4.3.2                                                                                                                                                              
html5lib: 0.999                                                                                                                                                         
httplib2: None                                                                                                                                                          
apiclient: None                                                                                                                                                         
rpy2: None                                                                                                                                                              
sqlalchemy: 0.9.8                                                                                                                                                       
pymysql: None                                                                                                                                                           
psycopg2: None "><pre class="notranslate"><span class="pl-v">In</span> []: <span class="pl-s1">from</span> <span class="pl-s1">pandas</span>.<span class="pl-s1">util</span>.<span class="pl-s1">print_versions</span> <span class="pl-s1">import</span> <span class="pl-s1">show_versions</span>                                                                                                            

<span class="pl-v">In</span> []: <span class="pl-en">show_versions</span>()                                                                                                                                                 

<span class="pl-v">INSTALLED</span> <span class="pl-v">VERSIONS</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-s1">commit</span>: <span class="pl-c1">None</span>                                                                                                                                                            
<span class="pl-s1">python</span>: <span class="pl-c1">2.7</span>.<span class="pl-c1">9.</span><span class="pl-s1">final</span>.<span class="pl-c1">0</span>                                                                                                                                                   
<span class="pl-s1">python</span><span class="pl-c1">-</span><span class="pl-s1">bits</span>: <span class="pl-c1">64</span>                                                                                                                                                         
<span class="pl-v">OS</span>: <span class="pl-v">Windows</span>                                                                                                                                                             
<span class="pl-v">OS</span><span class="pl-c1">-</span><span class="pl-s1">release</span>: <span class="pl-c1">7</span>                                                                                                                                                           
<span class="pl-s1">machine</span>: <span class="pl-v">AMD64</span>                                                                                                                                                          
<span class="pl-s1">processor</span>: <span class="pl-v">Intel64</span> <span class="pl-v">Family</span> <span class="pl-c1">6</span> <span class="pl-v">Model</span> <span class="pl-c1">60</span> <span class="pl-v">Stepping</span> <span class="pl-c1">3</span>, <span class="pl-v">GenuineIntel</span>                                                                                                           
<span class="pl-s1">byteorder</span>: <span class="pl-s1">little</span>                                                                                                                                                       
<span class="pl-v">LC_ALL</span>: <span class="pl-c1">None</span>                                                                                                                                                            
<span class="pl-v">LANG</span>: <span class="pl-c1">None</span>                                                                                                                                                              

<span class="pl-s1">pandas</span>: <span class="pl-c1">0.15</span>.<span class="pl-c1">2</span>                                                                                                                                                          
<span class="pl-s1">nose</span>: <span class="pl-c1">1.3</span>.<span class="pl-c1">4</span>                                                                                                                                                             
<span class="pl-v">Cython</span>: <span class="pl-c1">0.21</span>.<span class="pl-c1">2</span>                                                                                                                                                          
<span class="pl-s1">numpy</span>: <span class="pl-c1">1.8</span>.<span class="pl-c1">2</span>                                                                                                                                                            
<span class="pl-s1">scipy</span>: <span class="pl-c1">0.14</span>.<span class="pl-c1">0</span>                                                                                                                                                           
<span class="pl-s1">statsmodels</span>: <span class="pl-c1">0.5</span>.<span class="pl-c1">0</span>                                                                                                                                                      
<span class="pl-v">IPython</span>: <span class="pl-c1">2.3</span>.<span class="pl-c1">0</span>                                                                                                                                                          
<span class="pl-s1">sphinx</span>: <span class="pl-c1">1.2</span>.<span class="pl-c1">3</span>                                                                                                                                                           
<span class="pl-s1">patsy</span>: <span class="pl-c1">0.2</span>.<span class="pl-c1">1</span>                                                                                                                                                            
<span class="pl-s1">dateutil</span>: <span class="pl-c1">2.2</span>                                                                                                                                                           
<span class="pl-s1">pytz</span>: <span class="pl-c1">2014.9</span>                                                                                                                                                            
<span class="pl-s1">bottleneck</span>: <span class="pl-c1">0.8</span>.<span class="pl-c1">0</span>                                                                                                                                                       
<span class="pl-s1">tables</span>: <span class="pl-c1">3.1</span>.<span class="pl-c1">1</span>                                                                                                                                                           
<span class="pl-s1">numexpr</span>: <span class="pl-c1">2.3</span>.<span class="pl-c1">1</span>                                                                                                                                                          
<span class="pl-s1">matplotlib</span>: <span class="pl-c1">1.4</span>.<span class="pl-c1">0</span>                                                                                                                                                       
<span class="pl-s1">openpyxl</span>: <span class="pl-c1">2.0</span>.<span class="pl-c1">2</span>                                                                                                                                                         
<span class="pl-s1">xlrd</span>: <span class="pl-c1">0.9</span>.<span class="pl-c1">3</span>                                                                                                                                                             
<span class="pl-s1">xlwt</span>: <span class="pl-c1">0.7</span>.<span class="pl-c1">5</span>                                                                                                                                                             
<span class="pl-s1">xlsxwriter</span>: <span class="pl-c1">0.6</span>.<span class="pl-c1">6</span>                                                                                                                                                       
<span class="pl-s1">lxml</span>: <span class="pl-c1">3.4</span>.<span class="pl-c1">1</span>                                                                                                                                                             
<span class="pl-s1">bs4</span>: <span class="pl-c1">4.3</span>.<span class="pl-c1">2</span>                                                                                                                                                              
<span class="pl-s1">html5lib</span>: <span class="pl-c1">0.999</span>                                                                                                                                                         
<span class="pl-s1">httplib2</span>: <span class="pl-c1">None</span>                                                                                                                                                          
<span class="pl-s1">apiclient</span>: <span class="pl-c1">None</span>                                                                                                                                                         
<span class="pl-s1">rpy2</span>: <span class="pl-c1">None</span>                                                                                                                                                              
<span class="pl-s1">sqlalchemy</span>: <span class="pl-c1">0.9</span>.<span class="pl-c1">8</span>                                                                                                                                                       
<span class="pl-s1">pymysql</span>: <span class="pl-c1">None</span>                                                                                                                                                           
<span class="pl-s1">psycopg2</span>: <span class="pl-c1">None</span> </pre></div>
<p dir="auto">The .apply on DataFrame is converting my string to a date. I have posted this on StackOverflow:</p>
<p dir="auto"><a href="http://stackoverflow.com/questions/28487105/pandas-on-apply-passing-wrong-value" rel="nofollow">http://stackoverflow.com/questions/28487105/pandas-on-apply-passing-wrong-value</a></p>
<p dir="auto">I'm not sure if I'm doing something wrong or it is a bug, but it seems quite strange behavior.</p>
<p dir="auto">Example <a href="http://stackoverflow.com/questions/28550339/interesting-pandas-loc-behavior?noredirect=1#comment45415876_28550339" rel="nofollow">here</a></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="In [8]: df = pd.DataFrame({'wing1':wing1, 'wing2':wing2, 'mat':mat}, index=belly)

In [9]: df
Out[9]: 
            mat wing1 wing2
216  2016-01-22  2T15   416
3T19 2019-09-07  4H19  4T20

In [17]: df.loc['3T19']
Out[17]: 
mat     2019-09-07 00:00:00
wing1   2015-02-16 04:19:00
wing2   2015-04-20 00:00:00
Name: 3T19, dtype: datetime64[ns]

In [18]: df.loc['216']
Out[18]: 
mat      2016-01-22 00:00:00
wing1                   2T15
wing2                    416
Name: 216, dtype: object"><pre class="notranslate"><code class="notranslate">In [8]: df = pd.DataFrame({'wing1':wing1, 'wing2':wing2, 'mat':mat}, index=belly)

In [9]: df
Out[9]: 
            mat wing1 wing2
216  2016-01-22  2T15   416
3T19 2019-09-07  4H19  4T20

In [17]: df.loc['3T19']
Out[17]: 
mat     2019-09-07 00:00:00
wing1   2015-02-16 04:19:00
wing2   2015-04-20 00:00:00
Name: 3T19, dtype: datetime64[ns]

In [18]: df.loc['216']
Out[18]: 
mat      2016-01-22 00:00:00
wing1                   2T15
wing2                    416
Name: 216, dtype: object
</code></pre></div>