Skip to content

Commit 44c8f20

Browse files
authored
Enh arrow json extension (#61103)
* WIP: Support PyArrow JSON type in ArrowDtype.type * ENH: Added support for PyArrow JSON type in ArrowDtype.type * ENH: Support PyArrow JSON type in ArrowDtype.type Added support for PyArrow's JSON extension type in ArrowDtype.type by mapping JsonType to str. Fixes #60958. * ENH: Support for PyArrow JSON type in ArrowDtype.type Improved extension type handling by using BaseExtensionType for consistent storage type resolution across all PyArrow extension types, including JSON. Fixes #60958
1 parent 9537cf4 commit 44c8f20

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

doc/source/whatsnew/v3.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ Other enhancements
6161
- :meth:`Series.cummin` and :meth:`Series.cummax` now supports :class:`CategoricalDtype` (:issue:`52335`)
6262
- :meth:`Series.plot` now correctly handle the ``ylabel`` parameter for pie charts, allowing for explicit control over the y-axis label (:issue:`58239`)
6363
- :meth:`DataFrame.plot.scatter` argument ``c`` now accepts a column of strings, where rows with the same string are colored identically (:issue:`16827` and :issue:`16485`)
64+
- :class:`ArrowDtype` now supports ``pyarrow.JsonType`` (:issue:`60958`)
6465
- :class:`DataFrameGroupBy` and :class:`SeriesGroupBy` methods ``sum``, ``mean``, ``median``, ``prod``, ``min``, ``max``, ``std``, ``var`` and ``sem`` now accept ``skipna`` parameter (:issue:`15675`)
6566
- :class:`Rolling` and :class:`Expanding` now support ``nunique`` (:issue:`26958`)
6667
- :class:`Rolling` and :class:`Expanding` now support aggregations ``first`` and ``last`` (:issue:`33155`)

pandas/core/dtypes/dtypes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2265,7 +2265,7 @@ def type(self):
22652265
elif pa.types.is_null(pa_type):
22662266
# TODO: None? pd.NA? pa.null?
22672267
return type(pa_type)
2268-
elif isinstance(pa_type, pa.ExtensionType):
2268+
elif isinstance(pa_type, pa.BaseExtensionType):
22692269
return type(self)(pa_type.storage_type).type
22702270
raise NotImplementedError(pa_type)
22712271

pandas/tests/extension/test_arrow.py

+11
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
pa_version_under11p0,
4343
pa_version_under13p0,
4444
pa_version_under14p0,
45+
pa_version_under19p0,
4546
pa_version_under20p0,
4647
)
4748

@@ -3553,3 +3554,13 @@ def test_categorical_from_arrow_dictionary():
35533554
dtype="int64",
35543555
)
35553556
tm.assert_series_equal(result, expected)
3557+
3558+
3559+
@pytest.mark.skipif(
3560+
pa_version_under19p0, reason="pa.json_ was introduced in pyarrow v19.0"
3561+
)
3562+
def test_arrow_json_type():
3563+
# GH 60958
3564+
dtype = ArrowDtype(pa.json_(pa.string()))
3565+
result = dtype.type
3566+
assert result == str

0 commit comments

Comments
 (0)