In pandas, what does the na_action parameter to Series.map do -
when using series.map
, na_action
do? docs unclear , have not come example in results affected parameter.
although explanation in documentation pretty clear, it's hard see what's going on if you're using numeric functions take nans input , return them nan. else hasn't read docs, if na_action='ignore' na values not passed mapping function, if na_action=none (the default) will.
here's trivial example showing difference:
import pandas pd import numpy np s = pd.series([1, 2, 3, np.nan]) s2 = s.map(lambda x: 'this string {}'.format(x), na_action=none) 0 string 1.0 1 string 2.0 2 string 3.0 3 string nan dtype: object s3 = s.map(lambda x: 'this string {}'.format(x), na_action='ignore') 0 string 1.0 1 string 2.0 2 string 3.0 3 nan dtype: object
if have better example own analysis should consider creating issue on pandas repo, in order improve documentation , others understand.
Comments
Post a Comment