Hi all,
I'm trying to get my datetime64 astyped into a format that can be written to sqlite. If I try to write them as is I get
InterfaceError: Error binding parameter 2 - probably unsupported type.
The sql output has this string in it which is obviously not going to work: Timestamp('2013-07-15 00:00:03.374863', tz=None)
So, I tried converting to str:
In [96]: msgtbl['timestamp']=msgtbl.timestamp.astype(str)
TypeError: cannot astype a datetimelike from [datetime64[ns]] to [|S0]
> /home/aaron/pandas/pandas/core/common.py(1824)_astype_nansafe()
1823 raise TypeError(
-> 1824 "cannot astype a datetimelike from [%s] to [%s]" % (arr.dtype, dtype))
1825 return arr.astype(_NS_DTYPE)
And then I tried converting to object. This was the weird one, it didn't change at all, just stayed a datetime64:
In [99]: msgtbl
Out[99]:
<class 'pandas.core.frame.DataFrame'>
Int64Index: 3519 entries, 0 to 3518
Data columns (total 3 columns):
msgType 3519 non-null values
flight_id 3519 non-null values
timestamp 3519 non-null values
dtypes: datetime64[ns](1), object(2)
In [100]: msgtbl['timestamp']=msgtbl.timestamp.astype(object)
In [101]: msgtbl
Out[101]:
<class 'pandas.core.frame.DataFrame'>
Int64Index: 3519 entries, 0 to 3518
Data columns (total 3 columns):
msgType 3519 non-null values
flight_id 3519 non-null values
timestamp 3519 non-null values
dtypes: datetime64[ns](1), object(2)
What's going on? The only astype that seems to work is int, and I can't find an easy way to make that go in as an sqlite date type column.
Aaron