Skip to content

Regression: python type signature for df is wrong #5379

@zenazn

Description

@zenazn

What happens?

In https://github.com/duckdb/duckdb/blob/5abc6983ed92847310219ab112db969ebd12d733/tools/pythonpkg/duckdb-stubs/__init__.pyi, the df method on DuckDBPyConnection is listed as taking a pandas.DataFrame and returning a DuckDBPyRelation. However this doesn't match the runtime behavior or the historical behavior of the duckdb python bindings:

Python 3.9.9 (main, Dec 13 2021, 11:20:38)
[Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import duckdb
>>> import pandas
>>> con = duckdb.connect()
>>> results = con.execute("SELECT 42").df()
>>> type(results)
<class 'pandas.core.frame.DataFrame'>

(adapted from https://duckdb.org/docs/guides/python/execute_sql)

It looks like the type signatures may have slowly broken over the course of a few commits:

  • 04b38a8 — the date_as_datetime parameter should be optional
  • da7a2f1 — the df overload is important

To Reproduce

See above

OS:

OSX, apple silicon

DuckDB Version:

0.6.0

DuckDB Client:

Python

Full Name:

Carl Jackson

Affiliation:

Watershed

Have you tried this on the latest master branch?

  • I agree

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?

  • I agree

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions