File: datecolumn.py

package info (click to toggle)
python-clickhouse-driver 0.2.5-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,516 kB
  • sloc: python: 10,950; pascal: 42; makefile: 29; sh: 3
file content (19 lines) | stat: -rw-r--r-- 482 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import numpy as np

from .base import NumpyColumn


class NumpyDateColumn(NumpyColumn):
    dtype = np.dtype(np.uint16)
    ch_type = 'Date'

    null_value = np.datetime64(0, 'Y')

    def read_items(self, n_items, buf):
        data = super(NumpyDateColumn, self).read_items(n_items, buf)
        return data.astype('datetime64[D]')

    def write_items(self, items, buf):
        super(NumpyDateColumn, self).write_items(
            items.astype('datetime64[D]'), buf
        )