| 1 |
Description: Be compatible with pandas 3 |
| 2 |
|
| 3 |
Origin: upstream eb27cf084a90e545c10f8a5435d7f17cf1d28ff9 (part) |
| 4 |
Bug-Debian: https://bugs.debian.org/1142518 |
| 5 |
Author: Theelx |
| 6 |
Forwarded: not-needed |
| 7 |
|
| 8 |
--- a/jsonpickle/ext/pandas.py |
| 9 |
+++ b/jsonpickle/ext/pandas.py |
| 10 |
@@ -247,7 +247,7 @@ class PandasDfHandler(BaseHandler): |
| 11 |
for col in df.columns: |
| 12 |
dtype_str = dtypes.get(col, "object") |
| 13 |
try: |
| 14 |
- dtype = np.dtype(dtype_str) |
| 15 |
+ dtype = pd.api.types.pandas_dtype(dtype_str) |
| 16 |
df[col] = df[col].astype(dtype) |
| 17 |
except Exception: |
| 18 |
msg = ( |
| 19 |
--- a/jsonpickle/tags_pd.py |
| 20 |
+++ b/jsonpickle/tags_pd.py |
| 21 |
@@ -213,6 +213,14 @@ def get_all_pandas_dtype_strings(): |
| 22 |
# use the class object for things that np.dtype can't reconstruct |
| 23 |
dtypes.extend([pd.Timestamp, pd.Timedelta, pd.Period, pd.Interval]) |
| 24 |
|
| 25 |
+ # include parameterized extension dtypes with storage-specific names |
| 26 |
+ # this is required for pandas 3.0.0 |
| 27 |
+ for storage in ["python", "pyarrow"]: |
| 28 |
+ try: |
| 29 |
+ dtypes.append(str(pd.StringDtype(storage=storage)).lower()) # type: ignore[call-overload] |
| 30 |
+ except Exception: |
| 31 |
+ pass |
| 32 |
+ |
| 33 |
return list(dict.fromkeys(dtypes)) |
| 34 |
|
| 35 |
|