Skip to content

Commit 0fc4b60

Browse files
committed
Add convert_non_numeric as map_infer_mask parameter
1 parent 247e9d8 commit 0fc4b60

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

pandas/_libs/lib.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ def map_infer_mask(
190190
na_value: Any = ...,
191191
dtype: np.dtype = ...,
192192
convert_to_nullable_dtype: bool = ...,
193+
convert_non_numeric: bool = ...,
193194
storage: str | None = ...,
194195
) -> np.ndarray: ...
195196
@overload
@@ -202,6 +203,7 @@ def map_infer_mask(
202203
na_value: Any = ...,
203204
dtype: np.dtype = ...,
204205
convert_to_nullable_dtype: bool = ...,
206+
convert_non_numeric: bool = ...,
205207
storage: str | None = ...,
206208
) -> ArrayLike: ...
207209
def indices_fast(

pandas/_libs/lib.pyx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2945,6 +2945,7 @@ def map_infer_mask(
29452945
bint convert=True,
29462946
object na_value=no_default,
29472947
bint convert_to_nullable_dtype=False,
2948+
convert_non_numeric=False,
29482949
cnp.dtype dtype=np.dtype(object),
29492950
str storage=None,
29502951
) -> "ArrayLike":
@@ -2962,6 +2963,8 @@ def map_infer_mask(
29622963
na_value : Any, optional
29632964
The result value to use for masked values. By default, the
29642965
input value is used.
2966+
convert_non_numeric : bool, default False
2967+
Whether to convert datetime, timedelta, period, interval types.
29652968
dtype : numpy.dtype
29662969
The numpy dtype to use for the result ndarray.
29672970
storage : {None, "python", "pyarrow", "pyarrow_numpy"}, default None
@@ -3001,7 +3004,7 @@ def map_infer_mask(
30013004
return maybe_convert_objects(
30023005
result,
30033006
convert_to_nullable_dtype=convert_to_nullable_dtype,
3004-
convert_non_numeric=True,
3007+
convert_non_numeric=convert_non_numeric,
30053008
storage=storage,
30063009
)
30073010
else:

pandas/core/algorithms.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,6 +1727,7 @@ def map_array(
17271727
mask=mask,
17281728
na_value=na_value,
17291729
convert_to_nullable_dtype=na_value is NA,
1730+
convert_non_numeric=True,
17301731
storage=storage,
17311732
)
17321733

0 commit comments

Comments
 (0)