Skip to content

Commit 4324a06

Browse files
apacheGH-45296: [Python] Only enable the string dtype on pandas export for pandas>=2.3 (apache#45383)
### Rationale for this change The option already exists in pandas 2.2, but for that version our code does not work, so restricting it to pandas >= 2.3 * GitHub Issue: apache#45296 Authored-by: Joris Van den Bossche <[email protected]> Signed-off-by: Raúl Cumplido <[email protected]>
1 parent aaa88e9 commit 4324a06

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

python/pyarrow/pandas-shim.pxi

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ cdef class _PandasAPIShim(object):
3838
object _array_like_types, _is_extension_array_dtype, _lock
3939
bint has_sparse
4040
bint _pd024
41-
bint _is_v1, _is_ge_v21, _is_ge_v3, _is_ge_v3_strict
41+
bint _is_v1, _is_ge_v21, _is_ge_v23, _is_ge_v3, _is_ge_v3_strict
4242

4343
def __init__(self):
4444
self._lock = Lock()
@@ -79,6 +79,7 @@ cdef class _PandasAPIShim(object):
7979

8080
self._is_v1 = self._loose_version < Version('2.0.0')
8181
self._is_ge_v21 = self._loose_version >= Version('2.1.0')
82+
self._is_ge_v23 = self._loose_version >= Version('2.3.0')
8283
self._is_ge_v3 = self._loose_version >= Version('3.0.0.dev0')
8384
self._is_ge_v3_strict = self._loose_version >= Version('3.0.0')
8485

@@ -171,6 +172,10 @@ cdef class _PandasAPIShim(object):
171172
self._check_import()
172173
return self._is_ge_v21
173174

175+
def is_ge_v23(self):
176+
self._check_import()
177+
return self._is_ge_v23
178+
174179
def is_ge_v3(self):
175180
self._check_import()
176181
return self._is_ge_v3
@@ -183,7 +188,7 @@ cdef class _PandasAPIShim(object):
183188
if self.is_ge_v3_strict():
184189
return True
185190
try:
186-
if self.pd.options.future.infer_string:
191+
if self.is_ge_v23() and self.pd.options.future.infer_string:
187192
return True
188193
except:
189194
pass

0 commit comments

Comments
 (0)