From 3efd8ec7e35a7c0aa1ba15ba2cf0766af99d3c21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hrn=C4=8Diar?= Date: Mon, 8 Jun 2026 15:24:18 +0200 Subject: [PATCH] Fix PandasColumns compatibility with pandas 3.0 StringDtype In pandas 3.0, string columns default to StringDtype instead of object dtype. PandasColumns.append() passes column .values to the Numpy backend, which calls serialize_dtype(dt) -> dt.str.encode(). StringDtype (an ExtensionDtype) does not have a .str attribute, causing AttributeError. Use .to_numpy() instead of .values to ensure extension arrays are converted to numpy arrays before serialization. Pandas 3.0 re-infers StringDtype when reconstructing DataFrames, preserving round-trip correctness. Fixes: https://github.com/dask/partd/issues/82 Assisted-by: Claude Opus 4.6 --- partd/pandas.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/partd/pandas.py b/partd/pandas.py index 36c1b01..e0fac96 100644 --- a/partd/pandas.py +++ b/partd/pandas.py @@ -47,10 +47,10 @@ def append(self, data, **kwargs): # TODO: don't use values, it does some work. Look at _blocks instead # pframe/cframe do this well - arrays = {extend(k, col): df[col].values + arrays = {extend(k, col): df[col].to_numpy() for k, df in data.items() for col in df.columns} - arrays.update({extend(k, '.index'): df.index.values + arrays.update({extend(k, '.index'): df.index.to_numpy() for k, df in data.items()}) # TODO: handle categoricals self.partd.append(arrays, **kwargs)