My error relates to datetime conversion on constructing a Pandas DataFrame after I upgraded to pandas 0.81. Specifically, the .from_records() method passing a Django Queryset with timezone aware datetimes throws a datetime64 conversion error:
type(data)
> django.db.models.query.QuerySet
dv = data.values('begin_time', 'datum')
dv[0]
> {'begin_time': datetime.datetime(2006, 4, 27, 12, 40, tzinfo=<UTC>),
'datum': Decimal('13.3097500')}
df = pd.DataFrame.from_records( dv, index='begin_time' )
> ValueError: Tz-aware datetime.datetime cannot be converted to datetime64
unless utc=True
The Django datetime is timezone aware and looks to me that it is set to UTC, so I find the error message a little cryptic, but that is probably my failing. I’m relatively knew to Python.
So, I’m thinking that either I need to:
1. Somewhere set utc=true as the error says but I don’t know where to exactly or
2. Switch off conversion to datetime64 in .from_records, but I also don’t know where.
Thanks for your help!
I’ve created an issue here: http://github.com/pydata/pandas/issues/1825. I was just working on this stuff recently and apparently broke it (unless it works on git master now).