marcostc
marcostc

Reputation: 23

Python Pandas applymap na_action argument is not being recognized

When I try to use the argument "na_action" in Pandas' applymap function I got this error:

TypeError: applymap() got an unexpected keyword argument 'na_action'

Example:

>>> df = pd.DataFrame([[1, 2.12], [3.356, 4.567]])  
>>> df.iloc[0, 0] = pd.NA  
>>> df.applymap(lambda x: len(str(x)), na_action='ignore')

TypeError . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Traceback (most recent call last)
in 1 display(df_copy)
2 df.iloc[0, 0] = pd.NA
----> 3 df.applymap(lambda x: len(str(x)), na_action = 'ignore')

TypeError: applymap() got an unexpected keyword argument 'na_action'

Could anyone help me?

Upvotes: 2

Views: 1861

Answers (1)

Anu
Anu

Reputation: 316

Try checking the pandas version you are using. 'na_action' is available with the latest version.

Upvotes: 3

Related Questions