Skip to content

Commit d957726

Browse files
Backport PR pandas-dev#51674 on branch 2.0.x (BUG: ArrowDtype().type raising for fixed size pa binary) (pandas-dev#51776)
Backport PR pandas-dev#51674: BUG: ArrowDtype().type raising for fixed size pa binary Co-authored-by: Patrick Hoefler <[email protected]>
1 parent a255a00 commit d957726

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

pandas/core/arrays/arrow/dtype.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@ def type(self):
108108
return float
109109
elif pa.types.is_string(pa_type):
110110
return str
111-
elif pa.types.is_binary(pa_type):
111+
elif (
112+
pa.types.is_binary(pa_type)
113+
or pa.types.is_fixed_size_binary(pa_type)
114+
or pa.types.is_large_binary(pa_type)
115+
):
112116
return bytes
113117
elif pa.types.is_boolean(pa_type):
114118
return bool

pandas/tests/extension/test_arrow.py

+5
Original file line numberDiff line numberDiff line change
@@ -1399,6 +1399,11 @@ def test_mode_dropna_false_mode_na(data):
13991399
tm.assert_series_equal(result, expected)
14001400

14011401

1402+
@pytest.mark.parametrize("arrow_dtype", [pa.binary(), pa.binary(16), pa.large_binary()])
1403+
def test_arrow_dtype_type(arrow_dtype):
1404+
assert ArrowDtype(arrow_dtype).type == bytes
1405+
1406+
14021407
def test_is_bool_dtype():
14031408
# GH 22667
14041409
data = ArrowExtensionArray(pa.array([True, False, True]))

0 commit comments

Comments
 (0)