⌘K ctrl+k
Search Shortcut cmd + k | ctrl + k
DuckDB 2.0 ドキュメント 全文検索
per page, with , order by , clip by
Results of 1 - 7 of about 7 for dtype (0.004 sec.)
Integration with PyTorch 11996
PyTorch tensors can be built from DuckDB query results by exporting each result batch as Apache Arrow . This pattern is useful when training or serving models on Parquet data because DuckDB can filter and project the input before the batche ... batch in reader: features = torch.tensor( np.column_stack( [ batch.column(0).to_numpy(), batch.column(1).to_numpy(), ] ), dtype=torch.float32, ) labels = torch.tensor(batch.column(2).to_numpy(), dtype=torch.int64) print(features.shape, labels) torch. ...
https://man.mtool.work/duckdb/2.0/guides/python/pytorch.html
Export to Numpy 10451
The result of a query can be converted to Numpy arrays using the fetchnumpy() function, which returns a dictionary that maps each column name to a Numpy array. For example: import duckdb import numpy as np my_arr = duckdb.sql("SELECT unnest ... ([1, 2, 3]) AS x, 5.0 AS y").fetchnumpy() my_arr {'x': array([1, 2, 3], dtype=int32), 'y': array([5., 5., 5.])} Then, the array can be processed using Numpy functions, e.g.: np.sum(my_arr['x']) np.int ...
https://man.mtool.work/duckdb/2.0/guides/python/export_numpy.html
Types API 10142
The DuckDBPyType class, duckdb.sqltypes.DuckDBPyType , represents one of the data types . Use DuckDBPyType to describe SQL types when declaring function parameters, return types or casts. Python types such as int are accepted too: int descr ... int BIGINT str VARCHAR NumPy Scalar Types The table below shows the mapping of NumPy scalar types to DuckDB type. A NumPy dtype object does not convert: DuckDBPyType(numpy.dtype("int32")) raises a NotImplementedException . Type DuckDB type numpy.bool ... t() con.execute("CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy')") print(con.type("mood")) ENUM('sad', 'ok', 'happy') Nested Types list[child_type] list type objects map to a LIST type of the child type, which can itself be nested. import duckdb.sqlty ... Union[type_1, ... type_n] typing.Union objects, and unions written as type_1 | type_2 , map to a UNION type of the provided types. import duckdb.sqltypes from typing import Union print(duckdb.sqltypes.DuckDBPyType(Union[int, str, bool, bytearray])) p ...
https://man.mtool.work/duckdb/2.0/clients/python/types.html
Data Ingestion 9215
This page contains examples for data ingestion to Python using DuckDB. First, import the DuckDB package: import duckdb Then, proceed with any of the following sections. CSV Files CSV files can be read using the read_csv function, called eit ... read_csv("example.csv", header = False, sep = ",") Override types of the first two columns: duckdb.read_csv("example.csv", dtype = ["int", "varchar"]) Directly read a CSV file from within SQL: duckdb.sql("SELECT * FROM 'example.csv'") Call read_csv fr ... _arrow(obj).fetchall()) [(6,)] [(1,), (2,), (3,)] Pandas DataFrames – object Columns pandas.DataFrame columns of an object dtype require some special care, since this stores values of arbitrary type. To convert these columns to DuckDB, we first go thr ...
https://man.mtool.work/duckdb/2.0/clients/python/data_ingestion.html
Conversion between DuckDB and Python 8288
This page documents the rules for converting DuckDB results to Python and Python objects to DuckDB . Result Conversion: DuckDB Results to Python A result is read from a relation or, when using the DB-API / con.execute() , from the connectio ... execute("SELECT * FROM items").fetchnumpy() print(arr) {'item': array(['jeans', 'hammer', 'laptop', 'chainsaw', 'iphone'], dtype=object), 'value': array([ 20. , 42.2, 2000. , 500. , 300. ]), 'count': array([ 1, 2, 1, 10, 2], dtype=int32)} Fetch as an ... 5, "test"]]).fetchall()) [(['12345', 'test'],)] A NaN stays NaN inside a list, a struct, a map or a duckdb.Value of a nested type. A list that mixes datetime values with and without tzinfo becomes a TIMESTAMPTZ list as a query parameter and in values( ...
https://man.mtool.work/duckdb/2.0/clients/python/conversion.html
Python Client API 6743
Connection class duckdb. Appender Bases: object append_row ( self , * args ) → None Buffer one row, one value per column, each converted as an executemany parameter would be append_rows ( self , rows : object ) → None Buffer each row of an ... Fetch a result as DataFrame following execute() disable_profiling ( self ) → None Disable profiling for subsequent queries dtype ( self , type_str : str ) → _duckdb._sqltypes.DuckDBPyType Create a type object by parsing the ‘type_str' string duplicate ... e a relation object for the named view. class duckdb. Statement Bases: object property expected_result_type Get the expected type of result produced by this statement, actual type may vary depending on the statement. property named_parameters Get the ... page . drop ( * columns : str ) → DuckDBPyRelation Remove columns. Detailed examples can be found at Relational API page . dtypes Return a list containing the types of the columns of the relation. Detailed examples can be found at Relational API page ...
https://man.mtool.work/duckdb/2.0/clients/python/reference/
Relational API 6743
The Relational API builds a query one step at a time from Python. A relation, a DuckDBPyRelation , is a piece of SQL text: the methods of the Transformation and Functions sections return a new relation whose text extends the one they were c ... InvalidInputException . Most are the option of the same name of the SQL read_csv function ; sep and delimiter are delim , dtype is dtypes , na_values is nullstr , skiprows is skip , quotechar is quote , escapechar is escape , date_format is dateforma ... cannot be combined with delimiter . Detected when omitted. * delimiter : str, keyword-only, default: None Same as sep . * dtype : dict[str, str], list[str], keyword-only, default: None Column types, as a dict of column name to type or a list of types ... ewline character itself, such as '\n' , is refused. * columns : dict[str, str], keyword-only, default: None Column names and types, as a dict of column name to type name; the types are then not detected. * auto_type_candidates : list[str], keyword-onl ...
https://man.mtool.work/duckdb/2.0/clients/python/relational_api.html
PREV 1 NEXT
DuckDB 2.0 Documentation / man.mtool.work