Skip to content

Commit

Permalink
Backport PR pandas-dev#54498: Speed up string inference in maybe_conv…
Browse files Browse the repository at this point in the history
…ert_objects
  • Loading branch information
phofl authored and meeseeksmachine committed Aug 12, 2023
1 parent 1b2d39c commit f3391a4
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions pandas/_libs/lib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2681,14 +2681,13 @@ def maybe_convert_objects(ndarray[object] objects,
seen.object_ = True

elif seen.str_:
if is_string_array(objects, skipna=True):
if using_pyarrow_string_dtype():
import pyarrow as pa
if using_pyarrow_string_dtype() and is_string_array(objects, skipna=True):
import pyarrow as pa

from pandas.core.dtypes.dtypes import ArrowDtype
from pandas.core.dtypes.dtypes import ArrowDtype

dtype = ArrowDtype(pa.string())
return dtype.construct_array_type()._from_sequence(objects, dtype=dtype)
dtype = ArrowDtype(pa.string())
return dtype.construct_array_type()._from_sequence(objects, dtype=dtype)

seen.object_ = True
elif seen.interval_:
Expand Down

0 comments on commit f3391a4

Please sign in to comment.