groupby looses dtype on empty columns · Issue #6733 · pandas-dev/pandas (original) (raw)
In this snippet:
import pandas as pd
import numpy as np
print 'numpy', np.__version__
print 'pandas', pd.__version__
df = pd.DataFrame({'x': [],'range': np.arange(0)})
t = df.sort('x').groupby('x').first()
print 'types', df['range'].dtype, t['range'].dtype
it is shown that after the groupby, an empty "int" column becomes an empty "float". This is the output on my machine:
numpy 1.6.2
pandas 0.13.1
types int32 float64