diff --git a/pandas/core/frame.py b/pandas/core/frame.py index b63929079abeb..4e61e9b24e720 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -10365,7 +10365,29 @@ def map( 0 1 0 3 4 1 5 5 - +<<<<<<< HEAD + + >>> df.map(round, digits=2) + 0 1 + 0 1.00 2.12 + 1 3.36 4.57 +======= + + >>> def foo(x): + if x > 2.5: + x = 2 + + elif x <= 2.5: + x = 1 + + return x + + >>> df.map(foo) + 0 1 + 0 1 1 + 1 2 2 +>>>>>>> parent of 6f40da17ba (Updated Documentation for the map method) + Like Series.map, NA values can be ignored: >>> df_copy = df.copy() diff --git a/pandas/core/generic.py b/pandas/core/generic.py index e46a0aa044b6d..e5ebfbec75401 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -10683,11 +10683,11 @@ def _where( if not isinstance(cond, ABCDataFrame): # This is a single-dimensional object. if not is_bool_dtype(cond): - raise ValueError(msg.format(dtype=cond.dtype)) + raise TypeError(msg.format(dtype=cond.dtype)) else: for _dt in cond.dtypes: if not is_bool_dtype(_dt): - raise ValueError(msg.format(dtype=_dt)) + raise TypeError(msg.format(dtype=_dt)) if cond._mgr.any_extension_types: # GH51574: avoid object ndarray conversion later on cond = cond._constructor(