Skip to content

Commit 50910f9

Browse files
authored
Speed up string inference in maybe_convert_objects (#54498)
1 parent 6222789 commit 50910f9

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

pandas/_libs/lib.pyx

+5-6
Original file line numberDiff line numberDiff line change
@@ -2681,14 +2681,13 @@ def maybe_convert_objects(ndarray[object] objects,
26812681
seen.object_ = True
26822682

26832683
elif seen.str_:
2684-
if is_string_array(objects, skipna=True):
2685-
if using_pyarrow_string_dtype():
2686-
import pyarrow as pa
2684+
if using_pyarrow_string_dtype() and is_string_array(objects, skipna=True):
2685+
import pyarrow as pa
26872686

2688-
from pandas.core.dtypes.dtypes import ArrowDtype
2687+
from pandas.core.dtypes.dtypes import ArrowDtype
26892688

2690-
dtype = ArrowDtype(pa.string())
2691-
return dtype.construct_array_type()._from_sequence(objects, dtype=dtype)
2689+
dtype = ArrowDtype(pa.string())
2690+
return dtype.construct_array_type()._from_sequence(objects, dtype=dtype)
26922691

26932692
seen.object_ = True
26942693
elif seen.interval_:

0 commit comments

Comments
 (0)