npconv.py 316 B

123456789
  1. from clickhouse_connect.driver.options import np
  2. from clickhouse_connect.driver.types import ByteSource
  3. def read_numpy_array(source: ByteSource, np_type: str, num_rows: int):
  4. dtype = np.dtype(np_type)
  5. buffer = source.read_bytes(dtype.itemsize * num_rows)
  6. return np.frombuffer(buffer, dtype, num_rows)