Closed patmok closed 8 years ago
By default qPython
represents temporal vectors as instances of qcollection.QTemporalList
class. This class wraps the raw q representation of temporal data and provides accessors which allow to convert raw data to qcollection.QTemporal
instances in a lazy fashion. (Read more...)
>>> v = q.sync('2#.z.d')
>>> print '%s dtype: %s qtype: %d: %s' % (type(v), v.dtype, v.meta.qtype, v)
<class 'qpython.qcollection.QTemporalList'> dtype: int32 qtype: -14: [2015-08-03 [metadata(qtype=-14)] 2015-08-03 [metadata(qtype=-14)]]
If a temporal vector is part of the kdb+ table, the lazy conversion to the numpy datetime objects is not available.
>>> v = q.sync('([]2#.z.d)')
>>> print '%s dtype: %s qtype: %d: %s' % (type(v), v.dtype, v.meta.qtype, v)
<class 'qpython.qcollection.QTable'> dtype: [('d', '<i4')] qtype: 98: [(5693,) (5693,)]
qPython
can be instructed (Read more...) to represent temporal vectors as numpy arrays of numpy.datetime64
or numpy.timedelta64
. This also works for tables with temporal columns:
>>> v = q.sync('([]2#.z.d)', numpy_temporals = True)
>>> print '%s dtype: %s qtype: %d: %s' % (type(v), v.dtype, v.meta.qtype, v)
<class 'qpython.qcollection.QTable'> dtype: [('d', '<M8[D]')] qtype: 98: [(datetime.date(2015, 8, 3),) (datetime.date(2015, 8, 3),)]
Came across the following using Python 2.7.10 |Anaconda 2.2.0 (64-bit) querying kdb 3.1 l64
It seems the type remains an integer from date columns?