File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,9 @@ from cython cimport (
3939
4040from pandas._config import using_pyarrow_string_dtype
4141
42- from pandas._libs.missing import check_na_tuples_nonequal
42+ from pandas._libs.missing import check_na_tuples_nonequal, NA
43+
44+ from pandas.compat.numpy import np_version_gt2
4345
4446import_datetime()
4547
@@ -2625,7 +2627,7 @@ def maybe_convert_objects(ndarray[object] objects,
26252627 seen.object_ = True
26262628 break
26272629 elif isinstance (val, str ):
2628- if convert_non_numeric:
2630+ if convert_non_numeric or np_version_gt2 :
26292631 seen.str_ = True
26302632 break
26312633 else :
@@ -2704,6 +2706,9 @@ def maybe_convert_objects(ndarray[object] objects,
27042706
27052707 dtype = StringDtype()
27062708 return dtype.construct_array_type()._from_sequence(objects, dtype = dtype)
2709+ elif np_version_gt2:
2710+ dtype = np.dtypes.StringDType(na_object = NA, coerce = False )
2711+ return np.array(objects, dtype = dtype)
27072712
27082713 seen.object_ = True
27092714 elif seen.interval_:
Original file line number Diff line number Diff line change 3535from pandas .util ._decorators import doc
3636from pandas .util ._exceptions import find_stack_level
3737
38+ from pandas .compat .numpy import np_version_gt2
39+
3840from pandas .core .dtypes .cast import (
3941 construct_1d_object_array_from_listlike ,
4042 np_find_common_type ,
@@ -1645,6 +1647,7 @@ def map_array(
16451647 If the function returns a tuple with more than one element
16461648 a MultiIndex will be returned.
16471649 """
1650+ from pandas .core .arrays .string_ import StringArray
16481651 if na_action not in (None , "ignore" ):
16491652 msg = f"na_action must either be 'ignore' or None, { na_action } was passed"
16501653 raise ValueError (msg )
@@ -1693,6 +1696,7 @@ def map_array(
16931696
16941697 # we must convert to python types
16951698 values = arr .astype (object , copy = False )
1699+
16961700 if na_action is None :
16971701 return lib .map_infer (values , mapper )
16981702 else :
You can’t perform that action at this time.
0 commit comments