From b4061a55bf0fb1c6e7393dc3918ed815354c54a7 Mon Sep 17 00:00:00 2001 From: Linus <95619282+linus-md@users.noreply.github.com> Date: Wed, 6 Dec 2023 18:26:16 +0100 Subject: [PATCH] DOC: add example for map without lambda --- pandas/core/frame.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 3edfea4480e47..1630c2c31920d 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -10339,6 +10339,14 @@ def map( 0 NaN 4 1 5.0 5 + It is also possible to use `map` with functions that are not + `lambda` functions: + + >>> df.map(round, ndigits=1) + 0 1 + 0 1.0 2.1 + 1 3.4 4.6 + Note that a vectorized version of `func` often exists, which will be much faster. You could square each number elementwise.