2

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?

1
  • you should update to pandas 1.2 Commented Jan 8, 2021 at 21:13

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

2 Comments

Now I see. The argument 'na_action' starts with version 1.2.0 (December 26, 2020).
I have version 1.5.0 and still not working

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.