Reputation: 23
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
Reputation: 316
Try checking the pandas version you are using. 'na_action' is available with the latest version.
Upvotes: 3