Feature request: add na_action argument to applymap (original) (raw)

Code Sample, a copy-pastable example if possible

Desired method:

x = pd.DataFrame(...) x = x.applymap(foo, na_action='ignore')

Current method:

x = pd.DataFrame(...) x = x.apply(lambda y: y.map(foo, na_action='ignore'))

Problem description

The na_action='ignore' argument is extremely useful when processing messy data, and it would be nice to have on the DataFrame.applymap method as well.

DataFrame.applymap already uses very similar code, so ideally this shouldn't be too dramatic of a change.

DataFrame.applymap
Series.map (1), Series.map (2)

For that matter, is there any reason why DataFrame.applymap shouldn't just be a wrapper for .apply(lambda x: Series.map)? Seems like it would be beneficial for deduplicating logic in the codebase anyway.