You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Pandas4Warning emitted when converting a query result or table with a timestamp-with-timezone (or date with date_as_object=True) column to a Pandas v3.1 dataframe #708
The following warning is emitted when converting to a pandas v3.1 dataframe:
Pandas4Warning: The inplace keyword in DataFrame.drop is deprecated and will be removed in a future version (PDEP-8).
See https://pandas.pydata.org/docs/dev/whatsnew/v3.1.0.html#deprecation-inplace for more details.
I could reproduce this on Linux with Python 3.13.5, duckdb 2.0.0 and pandas 3.1.0. With pandas 3.0.6 and the same duckdb wheel, there is no warning, so it starts with the 3.1 inplace deprecation (PDEP-8).
importwarnings, duckdbwarnings.simplefilter("error")
duckdb.sql("select timestamptz '2020-01-01 00:00:00+00' as tz").df()
# pandas.errors.Pandas4Warning: The inplace keyword in DataFrame.drop is deprecated ...
Two things that might help scope the fix:
It's not only TIMESTAMPTZ. ConvertDateTimeTypes goes through the same ReplaceDFColumn helper for the date_as_object path, so duckdb.sql("select date '2020-01-01' d").df(date_as_object=True) raises the same warning under simplefilter("error"). .fetchdf() and .fetch_df_chunk() hit it too.
The warning gets attributed to duckdb/_relation.py and not to the caller's line. A filterwarnings entry keyed on the user's module won't match it, which makes this awkward to silence in test suites.
ReplaceDFColumn (src/pyresult.cpp, still at L304 on main 4154efc) only needs to drop the column in place. del df[col_name] does that without the deprecated keyword. I checked this in plain pandas 3.1.0 on a frame shaped like the one this function sees, a tz-naive column re-localized to UTC and converted. del df["tz"] followed by the existing df.insert(idx, "tz", new_value, allow_duplicates=False) gives a frame that passes pd.testing.assert_frame_equal against the current drop(inplace=True) + insert result: same column order and the same datetime64[us, <tz>] dtype, with no warning. Plain df[col_name] = new_value also gave an identical frame, since it replaces the column at its existing position. In C++ that would be something like df.attr("__delitem__")(col_name); in place of the drop(...) call. I haven't built the extension with that change, so I've only verified it at the pandas level.
changed the title [-]`Pandas4Warning` emitted when converting a query result or table with a timestamp-with-timezone to a pandas dataframe[/-][+]`Pandas4Warning` emitted when converting a query result or table with a timestamp-with-timezone to a Pandas v3.1+ dataframe[/+]on Oct 23, 2026
changed the title [-]`Pandas4Warning` emitted when converting a query result or table with a timestamp-with-timezone to a Pandas v3.1+ dataframe[/-][+]`Pandas4Warning` emitted when converting a query result or table with a timestamp-with-timezone to a Pandas v3.1 dataframe[/+]on Oct 23, 2026
changed the title [-]`Pandas4Warning` emitted when converting a query result or table with a timestamp-with-timezone to a Pandas v3.1 dataframe[/-][+]`Pandas4Warning` emitted when converting a query result or table with a timestamp-with-timezone or date column to a Pandas v3.1 dataframe[/+]on Oct 23, 2026
changed the title [-]`Pandas4Warning` emitted when converting a query result or table with a timestamp-with-timezone or date column to a Pandas v3.1 dataframe[/-][+]`Pandas4Warning` emitted when converting a query result or table with a timestamp-with-timezone (or date with `date_as_object=True`) column to a Pandas v3.1 dataframe[/+]on Oct 23, 2026
The warning gets attributed to duckdb/_relation.py and not to the caller's line. A filterwarnings entry keyed on the user's module won't match it, which makes this awkward to silence in test suites.
Yeah, I don't think it's easy to surface warnings coming from extension-level code.
It's not only TIMESTAMPTZ
Yeah, the cpp code I linked to already reflected that, but I've updated the MRE and the title to include that.
Activity
mohamd764 commentedon Oct 23, 2026
I could reproduce this on Linux with Python 3.13.5, duckdb 2.0.0 and pandas 3.1.0. With pandas 3.0.6 and the same duckdb wheel, there is no warning, so it starts with the 3.1
inplacedeprecation (PDEP-8).Two things that might help scope the fix:
ConvertDateTimeTypesgoes through the sameReplaceDFColumnhelper for thedate_as_objectpath, soduckdb.sql("select date '2020-01-01' d").df(date_as_object=True)raises the same warning undersimplefilter("error")..fetchdf()and.fetch_df_chunk()hit it too.duckdb/_relation.pyand not to the caller's line. Afilterwarningsentry keyed on the user's module won't match it, which makes this awkward to silence in test suites.ReplaceDFColumn(src/pyresult.cpp, still at L304 on main 4154efc) only needs to drop the column in place.del df[col_name]does that without the deprecated keyword. I checked this in plain pandas 3.1.0 on a frame shaped like the one this function sees, a tz-naive column re-localized to UTC and converted.del df["tz"]followed by the existingdf.insert(idx, "tz", new_value, allow_duplicates=False)gives a frame that passespd.testing.assert_frame_equalagainst the currentdrop(inplace=True)+insertresult: same column order and the samedatetime64[us, <tz>]dtype, with no warning. Plaindf[col_name] = new_valuealso gave an identical frame, since it replaces the column at its existing position. In C++ that would be something likedf.attr("__delitem__")(col_name);in place of thedrop(...)call. I haven't built the extension with that change, so I've only verified it at the pandas level.[-]`Pandas4Warning` emitted when converting a query result or table with a timestamp-with-timezone to a pandas dataframe[/-][+]`Pandas4Warning` emitted when converting a query result or table with a timestamp-with-timezone to a Pandas v3.1+ dataframe[/+][-]`Pandas4Warning` emitted when converting a query result or table with a timestamp-with-timezone to a Pandas v3.1+ dataframe[/-][+]`Pandas4Warning` emitted when converting a query result or table with a timestamp-with-timezone to a Pandas v3.1 dataframe[/+][-]`Pandas4Warning` emitted when converting a query result or table with a timestamp-with-timezone to a Pandas v3.1 dataframe[/-][+]`Pandas4Warning` emitted when converting a query result or table with a timestamp-with-timezone or date column to a Pandas v3.1 dataframe[/+][-]`Pandas4Warning` emitted when converting a query result or table with a timestamp-with-timezone or date column to a Pandas v3.1 dataframe[/-][+]`Pandas4Warning` emitted when converting a query result or table with a timestamp-with-timezone (or date with `date_as_object=True`) column to a Pandas v3.1 dataframe[/+]edgarrmondragon commentedon Oct 23, 2026
Yeah, I don't think it's easy to surface warnings coming from extension-level code.
Yeah, the cpp code I linked to already reflected that, but I've updated the MRE and the title to include that.
edgarrmondragon commentedon Oct 23, 2026
a897283 fixed this, but I'll let the maintainer close this issue when they deem it appropriate