Zum Inhalt springen

Import aus Numpy

Numpy-Arrays lassen sich aus DuckDB heraus abfragen. Die Arrays müssen nicht manuell registriert werden – DuckDB findet sie im Python-Prozess anhand des Namens dank Replacement Scans. Zum Beispiel:

import duckdb
import numpy as np
my_arr = np.array([(1, 9.0), (2, 8.0), (3, 7.0)])
duckdb.sql("SELECT * FROM my_arr")
┌─────────┬─────────┬─────────┐
│ column0 │ column1 │ column2 │
│ double │ double │ double │
├─────────┼─────────┼─────────┤
│ 1.0 │ 2.0 │ 3.0 │
│ 9.0 │ 8.0 │ 7.0 │
└─────────┴─────────┴─────────┘

Siehe auch

DuckDB unterstützt auch den Export nach Numpy.