⌘K ctrl+k
Search Shortcut cmd + k | ctrl + k
DuckDB 2.0 ドキュメント 全文検索
per page, with , order by , clip by
Results of 1 - 10 of about 14 for dict (0.005 sec.)
Conversion between DuckDB and Python 14004
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 ... ( con.execute() ) Python tuples fetchall() , iter_rows(batch_size=1024) fetchone() , fetchmany(size=1) , fetchall() Python dicts to_dicts() NumPy fetchnumpy() fetchnumpy() Pandas df() df() , fetch_df_chunk() Apache Arrow to_arrow_table() , to_arrow_r ... print(df) item value count 0 jeans 20.0 1 1 hammer 42.2 2 2 laptop 2000.0 1 3 chainsaw 500.0 10 4 iphone 300.0 2 Fetch as dictionary of NumPy arrays: arr = con.execute("SELECT * FROM items").fetchnumpy() print(arr) {'item': array(['jeans', 'hammer', ... 0.00 1 1 hammer 42.20 2 2 laptop 2000.00 1 3 chainsaw 500.00 10 4 iphone 300.00 2 NumPy fetchnumpy() fetches the data as a dictionary of NumPy arrays. A column without NULL values is a plain array. A column with NULL values is a masked array. Pandas ...
https://man.mtool.work/duckdb/2.0/clients/python/conversion.html
Types API 10835
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 ... the child type, which can itself be nested. import duckdb.sqltypes print(duckdb.sqltypes.DuckDBPyType(list[int])) BIGINT[] dict[key_type, value_type] dict type objects map to a MAP type of the key type and the value type. import duckdb.sqltypes print ... (duckdb.sqltypes.DuckDBPyType(dict[str, int])) MAP(VARCHAR, BIGINT) {'a': field_one, 'b': field_two, ..., 'n': field_n} dict objects map to a STRUCT composed ... of the keys and values of the dict. import duckdb.sqltypes print(duckdb.sqltypes.DuckDBPyType({'a': str, 'b': int})) STRUCT(a VARCHAR, b BIGINT) Union[type_1 ...
https://man.mtool.work/duckdb/2.0/clients/python/types.html
Python Client API 10082
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 ... etchmany ( self , size : int = 1 ) → list Fetch the next set of rows from a result following execute fetchnumpy ( self ) → dict Fetch a result as list of NumPy arrays following execute fetchone ( self ) → object Fetch a single row from a result follo ... ation over what it returned. Statements before the last one run immediately. query_appender ( self , dml : str , columns : dict , * , source : str | None = None ) → _duckdb.Appender Create an appender that buffers rows of the declared columns and run ... ct = None ) → DuckDBPyRelation Create a relation object from the named table function with given parameters. tf ( self ) → dict Fetch a result as dict of TensorFlow Tensors following execute() to_arrow_reader ( batch_size : int = 131072 ) → Any A rea ...
https://man.mtool.work/duckdb/2.0/clients/python/reference/
Relational API 8840
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 ... to sql() , such as CREATE TABLE or INSERT , runs at the call, and the relation holds what it returned. The params list or dict is copied when the relation is created, and its values are converted each time the relation runs. A column is also an attr ... 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 by pos ... escape text as written in Python; a string that holds the newline 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 n ...
https://man.mtool.work/duckdb/2.0/clients/python/relational_api.html
Data Ingestion 8664
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 ... ataFrame by the name of its variable, as if it were a table: import duckdb import pandas as pd test_df = pd.DataFrame.from_dict({"i": [1, 2, 3, 4], "j": ["one", "two", "three", "four"]}) print(duckdb.sql("SELECT * FROM test_df").fetchall()) [(1, 'one ... '), (3, 'three'), (4, 'four')] The same works for Pandas Series, Polars DataFrames, LazyFrames and Series, NumPy arrays, a dict of one-dimensional NumPy arrays, relations and Arrow objects. The masked elements in a NumPy masked array are NULL . In a ... columns a and A_1 . Use register() to give a DataFrame or Arrow object a SQL name. This also works for objects stored in a dictionary or class attribute. import duckdb import pandas as pd my_dictionary = {} my_dictionary["test_df"] = pd.DataFrame.fro ...
https://man.mtool.work/duckdb/2.0/clients/python/data_ingestion.html
SQL on Pandas 8157
Pandas DataFrames stored in local variables can be queried as if they are regular tables within DuckDB. import duckdb import pandas # Create a Pandas dataframe my_df = pandas.DataFrame.from_dict({'a': [42]}) # query the Pandas DataFrame "my ...
https://man.mtool.work/duckdb/2.0/guides/python/sql_on_pandas.html
Migrating Python Code to DuckDB 2.0 8034
This page lists what Python code written for DuckDB 1.x must change to run on DuckDB 2.0. Each item gives the 1.x form, the 2.0 form and the page that explains it. For changes outside the Python client, see Migrating to DuckDB v2.0 . Python ... n name, and a query without a column of that name raises a BinderException . Write col("t", "x") . See Column Expression . Dicts with keys that are not strings. 1.x: con.values({1: "a"}) made a STRUCT with a field named 1 . 2.0: in values() and in ex ... pressions, such a dict becomes a MAP , here MAP(INTEGER, VARCHAR) . Use string keys for a STRUCT . See dict . Columns named like new relation met ...
https://man.mtool.work/duckdb/2.0/clients/python/migration.html
Import from Pandas 7982
CREATE TABLE ... AS and INSERT INTO can be used to create a table from any query. We can then create tables or insert into existing tables by referring to the Pandas DataFrame in the query. There is no need to register the DataFrames manual ... y name thanks to replacement scans . import duckdb import pandas # Create a Pandas dataframe my_df = pandas.DataFrame.from_dict({'a': [42]}) # create the table "my_table" from the DataFrame "my_df" # Note: duckdb.sql connects to the default in-memory ...
https://man.mtool.work/duckdb/2.0/guides/python/import_pandas.html
Relational API on Pandas 7912
DuckDB offers a relational API that can be used to chain together query operations. These are lazily evaluated so that DuckDB can optimize their execution. These operators can act on Pandas DataFrames, DuckDB tables or views (which can poin ... me. import duckdb import pandas # connect to an in-memory database con = duckdb.connect() input_df = pandas.DataFrame.from_dict({'i': [1, 2, 3, 4], 'j': ["one", "two", "three", "four"]}) # create a DuckDB relation from a dataframe rel = con.from_df(i ...
https://man.mtool.work/duckdb/2.0/guides/python/relational_api_pandas.html
Expression API 7719
The Expression class represents an instance of an expression . Why Would I Use the Expression API? Use expressions to build filters and computed columns in Python. They are useful when column names or conditions depend on your code. import ... be an expression of its own, as in a select list. Values convert as described in Conversion between DuckDB and Python ; a dict with string keys is a STRUCT , and a dict with other keys is a MAP . import duckdb import pandas as pd df = pd.DataFrame({ ...
https://man.mtool.work/duckdb/2.0/clients/python/expression.html
PREV 1 2 NEXT
DuckDB 2.0 Documentation / man.mtool.work