⌘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 28 for Pandas (0.002 sec.)
Jupyter Notebooks 12896
DuckDB's Python client can be used directly in Jupyter notebooks with no additional configuration, as the first section shows. Additional libraries can simplify SQL query development; the rest of this guide uses the JupySQL package. See oth ... w to use DuckDB and Python together. Querying in a Python Cell In a plain Python cell, duckdb.sql runs a query and finds a pandas DataFrame by its variable name: import duckdb import pandas as pd sales = pd.DataFrame({"item": ["jeans", "hammer"], "pric ... CT * FROM sales WHERE price > 30") The last expression displays a table in the notebook. Add .df() to keep the result as a pandas DataFrame. Library Installation This JupySQL workflow is also available as a Google Colab notebook . Four additional libra ... ries improve the DuckDB experience in Jupyter notebooks. jupysql : Convert a Jupyter code cell into a SQL cell Pandas : Clean table visualizations and compatibility with other analysis matplotlib : Plotting with Python duckdb-engine (DuckDB ...
https://man.mtool.work/duckdb/2.0/guides/python/jupyter.html
SQL on Pandas 12453
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 ... to the default in-memory database connection results = duckdb.sql("SELECT * FROM my_df").df() The seamless integration of Pandas DataFrames into DuckDB SQL queries is allowed by replacement scans , which replace instances of accessing the my_df table ...
https://man.mtool.work/duckdb/2.0/guides/python/sql_on_pandas.html
Import from Pandas 10421
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 ... ly – DuckDB can find them in the Python process by 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 DataFra ... ct() con.sql("CREATE TABLE my_table (a INTEGER)") con.append("my_table", my_df) See Also DuckDB also supports exporting to Pandas . ...
https://man.mtool.work/duckdb/2.0/guides/python/import_pandas.html
Export to Pandas 10044
The result of a query can be converted to a Pandas DataFrame using the df() function. import duckdb # read the result of an arbitrary SQL query to a Pandas DataFrame results = duckdb.sql("SELECT 42").df() results 42 0 42 See Also DuckDB als ... o supports importing from Pandas . ...
https://man.mtool.work/duckdb/2.0/guides/python/export_pandas.html
Data Ingestion 9487
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 ... : duckdb.sql("SELECT * FROM read_json('example.json')") Directly Accessing DataFrames and Arrow Objects DuckDB can query a Pandas DataFrame by the name of its variable, as if it were a table: import duckdb import pandas as pd test_df = pd.DataFrame.fro ... int(duckdb.sql("SELECT * FROM test_df").fetchall()) [(1, 'one'), (2, 'two'), (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 Arro ... me 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.from_dict({"i": [1, 2, 3, 4], "j": ["one", "two", "three" ...
https://man.mtool.work/duckdb/2.0/clients/python/data_ingestion.html
Relational API on Pandas 9487
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 ... storage format that DuckDB can read, such as CSV or Parquet files, etc.). Here we show a simple example of reading from a Pandas DataFrame and returning a DataFrame. 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 ...
https://man.mtool.work/duckdb/2.0/guides/python/relational_api_pandas.html
Guides 9061
The guides section contains compact how-to guides that are focused on achieving a single goal. For API references and examples, see the rest of the documentation. Note that there are many tools using DuckDB, which are not covered in the off ... query DuckDB in marimo Notebooks How to use Multiple Python Threads with DuckDB How to use fsspec filesystems with DuckDB Pandas How to execute SQL on a Pandas DataFrame How to create a table from a Pandas DataFrame How to export data to a Pandas Data ... Apache Arrow How to create a DuckDB table from Apache Arrow How to export data to Apache Arrow Relational API How to query Pandas DataFrames with the Relational API Python Library Integrations How to use Ibis to query DuckDB with or without SQL How to ...
https://man.mtool.work/duckdb/2.0/guides/overview.html
Python API 8930
Installation To use the DuckDB Python client, visit the Python installation page . The latest stable version of the DuckDB Python client is 2.0.0. Installation The DuckDB Python API can be installed using pip : pip install duckdb . Please s ... Parquet file duckdb.sql("SELECT * FROM 'example.json'") # directly query a JSON file DataFrames DuckDB can directly query Pandas DataFrames, Polars DataFrames and Arrow tables. Note that these are read-only, i.e., editing these tables via INSERT or UP ... DATE statements is not possible. Pandas To directly query a Pandas DataFrame, run: import duckdb import pandas as pd pandas_df = pd.DataFrame({"a": [42]}) duckdb. ... sql("SELECT * FROM pandas_df") ┌───────┐ │ a │ │ int64 │ ├───────┤ │ 42 │ └───────┘ Polars To directly query a Polars DataFrame, run: import duckdb ...
https://man.mtool.work/duckdb/2.0/clients/python/overview.html
Integration with Ibis 8881
Ibis is a Python dataframe library that supports 20+ backends, with DuckDB as the default. Ibis with DuckDB provides a Pythonic interface for SQL with great performance. Warning Ibis 12.0.0 and earlier do not support DuckDB 2.0. The example ... valuated, so instead of seeing the data, we see the schema of the table. To peek at the data, we can call head and then to_pandas to get the first few rows of the table as a pandas DataFrame. penguins.head().to_pandas() species island bill_length_mm bi ... .0 3250.0 female 2007 3 Adelie Torgersen NaN NaN NaN NaN NaN 2007 4 Adelie Torgersen 36.7 19.3 193.0 3450.0 female 2007 to_pandas takes the existing lazy table expression and evaluates it. If we leave it off, you'll see the Ibis representation of the t ... able expression that to_pandas will evaluate (when you're ready!). penguins.head() r0 := DatabaseTable: penguins species string island string bill_length ...
https://man.mtool.work/duckdb/2.0/guides/python/ibis.html
Conversion between DuckDB and Python 8439
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 ... _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_reader() to_arrow_table() , to_arrow_reader() , both ... 'jeans', 20.0, 1), ('hammer', 42.2, 2), ('laptop', 2000.0, 1), ('chainsaw', 500.0, 10), ('iphone', 300.0, 2) """) Fetch as Pandas DataFrame: df = con.execute("SELECT * FROM items").df() print(df) item value count 0 jeans 20.0 1 1 hammer 42.2 2 2 laptop ... 20. , 42.2, 2000. , 500. , 300. ]), 'count': array([ 1, 2, 1, 10, 2], dtype=int32)} Fetch as an Arrow table. Converting to Pandas afterwards just for pretty printing: tbl = con.sql("SELECT * FROM items").to_arrow_table() print(tbl.to_pandas()) item val ...
https://man.mtool.work/duckdb/2.0/clients/python/conversion.html
PREV 1 2 3 NEXT
DuckDB 2.0 Documentation / man.mtool.work