Apply a function to a Dataframe elementwise.
Deprecated since version 2.1.0: DataFrame.applymap has been deprecated. Use DataFrame.map instead.
This method applies a function that accepts and returns a scalar to every element of a DataFrame.
Python function, returns a single value from a single value.
If ‘ignore’, propagate NaN values, without passing them to func.
Additional keyword arguments to pass as keywords arguments to func.
Transformed DataFrame.
See also
DataFrame.applyApply a function along input axis of DataFrame.
DataFrame.mapApply a function along input axis of DataFrame.
DataFrame.replaceReplace values given in to_replace with value.
Examples
>>> df = pd.DataFrame([[1, 2.12], [3.356, 4.567]])
>>> df
0 1
0 1.000 2.120
1 3.356 4.567
>>> df.map(lambda x: len(str(x)))
0 1
0 3 4
1 5 5
© 2008–2011, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
© 2011–2025, Open source contributors
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/2.3.0/reference/api/pandas.DataFrame.applymap.html