Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Ctrl+K

pandas.DataFrame.applymap#

DataFrame.applymap(func,na_action=None,**kwargs)[source]#

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 scalarto every element of a DataFrame.

Parameters:
funccallable

Python function, returns a single value from a single value.

na_action{None, ‘ignore’}, default None

If ‘ignore’, propagate NaN values, without passing them to func.

**kwargs

Additional keyword arguments to pass as keywords arguments tofunc.

Returns:
DataFrame

Transformed DataFrame.

See also

DataFrame.apply

Apply a function along input axis of DataFrame.

DataFrame.map

Apply a function along input axis of DataFrame.

DataFrame.replace

Replace values given into_replace withvalue.

Examples

>>>df=pd.DataFrame([[1,2.12],[3.356,4.567]])>>>df       0      10  1.000  2.1201  3.356  4.567
>>>df.map(lambdax:len(str(x)))   0  10  3  41  5  5

[8]ページ先頭

©2009-2025 Movatter.jp