Skip to content

Commit 9c267bf

Browse files
committed
BUG: Fix ArrowDtype.itemsize for fixed-width types
1 parent c8286fb commit 9c267bf

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pandas/core/dtypes/dtypes.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,8 +1642,11 @@ def kind(self) -> str:
16421642
@cache_readonly
16431643
def itemsize(self) -> int:
16441644
"""Return the number of bytes in this dtype"""
1645+
if hasattr(self.pyarrow_dtype, "bit_width"):
1646+
return self.pyarrow_dtype.bit_width // 8
16451647
return self.numpy_dtype.itemsize
16461648

1649+
16471650
def construct_array_type(self) -> type_t[BaseMaskedArray]:
16481651
"""
16491652
Return the array type associated with this dtype.
@@ -2307,8 +2310,11 @@ def kind(self) -> str:
23072310
@cache_readonly
23082311
def itemsize(self) -> int:
23092312
"""Return the number of bytes in this dtype"""
2313+
if hasattr(self.pyarrow_dtype, "bit_width"):
2314+
return self.pyarrow_dtype.bit_width // 8
23102315
return self.numpy_dtype.itemsize
23112316

2317+
23122318
def construct_array_type(self) -> type_t[ArrowExtensionArray]:
23132319
"""
23142320
Return the array type associated with this dtype.

0 commit comments

Comments
 (0)