<p dir="auto">Using pandas 0.13.1</p>
<p dir="auto">I have a dataframe with three columns. The first two contain datetimes and the third floats (the entire data frame originates from df = pandas.io.sql.frame_query(...,...) ).</p>
<p dir="auto">I need to remove rows for which dates in the first two columns are duplicated. So something like the following would seem to be appropriate:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="df = df.groupby(['col1','col2']).first() 
df.reset_index(inplace = True)    "><pre class="notranslate"><code class="notranslate">df = df.groupby(['col1','col2']).first() 
df.reset_index(inplace = True)    
</code></pre></div>
<p dir="auto">However, this doesn't work: it executes without error, but returns df unmodified.</p>
<p dir="auto">I can get the functionality I need by first converting the datetimes to strings:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="df['col1'] = [date.strftime('%Y-%m-%d') for date in df['col1']]
df['col2'] = [date.strftime('%Y-%m-%d') for date in df['col2']]"><pre class="notranslate"><code class="notranslate">df['col1'] = [date.strftime('%Y-%m-%d') for date in df['col1']]
df['col2'] = [date.strftime('%Y-%m-%d') for date in df['col2']]
</code></pre></div>
<p dir="auto">Only after this, it seems, do the original commands work:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="df = df.groupby(['col1','col2']).first() 
df.reset_index(inplace = True)   "><pre class="notranslate"><code class="notranslate">df = df.groupby(['col1','col2']).first() 
df.reset_index(inplace = True)   
</code></pre></div>
<p dir="auto">Then to get back to the dataframe format I need, I have to revert back to datetimes:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="df['col1'] = to_datetime(df['col1'])
df['col2'] = to_datetime(df['col2'])"><pre class="notranslate"><code class="notranslate">df['col1'] = to_datetime(df['col1'])
df['col2'] = to_datetime(df['col2'])
</code></pre></div>
<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="from StringIO import StringIO
import pandas as pd
import numpy as np

data = &quot;some_id,other_id,some_int\n1,234,0\n2,324,1&quot;
dtypes = {'some_id': np.uint32, 'other_id': np.uint32, 'some_int': np.int8}
train = pd.read_csv(StringIO(data), dtype=dtypes)

print(train.dtypes) # dtypes is respected
grouped = train.groupby('some_id').some_int.agg(['sum'])
print(grouped.index.dtype) # dtype('int64')"><pre class="notranslate"><span class="pl-k">from</span> <span class="pl-v">StringIO</span> <span class="pl-k">import</span> <span class="pl-v">StringIO</span>
<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-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>

<span class="pl-s1">data</span> <span class="pl-c1">=</span> <span class="pl-s">"some_id,other_id,some_int<span class="pl-cce">\n</span>1,234,0<span class="pl-cce">\n</span>2,324,1"</span>
<span class="pl-s1">dtypes</span> <span class="pl-c1">=</span> {<span class="pl-s">'some_id'</span>: <span class="pl-s1">np</span>.<span class="pl-s1">uint32</span>, <span class="pl-s">'other_id'</span>: <span class="pl-s1">np</span>.<span class="pl-s1">uint32</span>, <span class="pl-s">'some_int'</span>: <span class="pl-s1">np</span>.<span class="pl-s1">int8</span>}
<span class="pl-s1">train</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-en">read_csv</span>(<span class="pl-v">StringIO</span>(<span class="pl-s1">data</span>), <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s1">dtypes</span>)

<span class="pl-en">print</span>(<span class="pl-s1">train</span>.<span class="pl-s1">dtypes</span>) <span class="pl-c"># dtypes is respected</span>
<span class="pl-s1">grouped</span> <span class="pl-c1">=</span> <span class="pl-s1">train</span>.<span class="pl-en">groupby</span>(<span class="pl-s">'some_id'</span>).<span class="pl-s1">some_int</span>.<span class="pl-en">agg</span>([<span class="pl-s">'sum'</span>])
<span class="pl-en">print</span>(<span class="pl-s1">grouped</span>.<span class="pl-s1">index</span>.<span class="pl-s1">dtype</span>) <span class="pl-c"># dtype('int64')</span></pre></div>
<h4 dir="auto">Problem description</h4>
<p dir="auto">I am explicitly asking for uint32 but pandas coerces "some_id" column to int64 after using groupby. Is this intended? Possible duplicate of <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="182959741" data-permission-text="Title is private" data-url="https://github.com/pandas-dev/pandas/issues/14423" data-hovercard-type="issue" data-hovercard-url="/pandas-dev/pandas/issues/14423/hovercard" href="https://github.com/pandas-dev/pandas/issues/14423">#14423</a> ?</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: Linux
OS-release: 4.4.0-57-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
<p dir="auto">pandas: 0.18.1<br>
nose: 1.3.7<br>
pip: 8.1.2<br>
setuptools: 27.2.0<br>
Cython: 0.24.1<br>
numpy: 1.11.1<br>
scipy: 0.18.1<br>
statsmodels: 0.6.1<br>
xarray: None<br>
IPython: 5.1.0<br>
sphinx: 1.4.6<br>
patsy: 0.4.1<br>
dateutil: 2.5.3<br>
pytz: 2016.6.1<br>
blosc: None<br>
bottleneck: 1.1.0<br>
tables: 3.2.3.1<br>
numexpr: 2.6.1<br>
matplotlib: 1.5.3<br>
openpyxl: 2.3.2<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.13<br>
pymysql: None<br>
psycopg2: None<br>
jinja2: 2.8<br>
boto: 2.42.0<br>
pandas_datareader: None</p>
</details>