groupby.apply datetime bug affecting 0.17 · Issue #11324 · pandas-dev/pandas (original) (raw)
Exception is raised when
a) the original dataframe has a datetime column
b) the groupby.apply function returns a series object with a new datetime column
Code to reproduce:
import pandas as pd
import datetime
df = pd.DataFrame([['1', datetime.datetime.today()],
['2', datetime.datetime.today()],
['2', datetime.datetime(2010, 1, 1)]],
columns=['record', 'date'])
dd = df.groupby('record').apply(lambda x: pd.Series({'max_date': x['date'].max()}))
This is a new issue affecting 0.17