Unexpected behavior with binary operators and fill_value · Issue #12723 · pandas-dev/pandas (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Description
From dask/dask#1063. fill_value
doesn't seem to apply if the argument to a binary operator is a constant, but works fine for other arguments:
In [1]: import pandas as pd
In [2]: df = pd.DataFrame(range(10), columns=['foo'])
In [3]: df2 = df.copy()
In [4]: df2.iloc[0] = None
In [5]: df2.add(2, fill_value=0) Out[5]: foo 0 NaN 1 3.0 2 4.0 3 5.0 4 6.0 5 7.0 6 8.0 7 9.0 8 10.0 9 11.0
In [6]: df2.add(df, fill_value=0) Out[6]: foo 0 0.0 1 2.0 2 4.0 3 6.0 4 8.0 5 10.0 6 12.0 7 14.0 8 16.0 9 18.0
In [7]: pd.version Out[7]: u'0.18.0rc2+2.g19e40a0'
From the docstring I'd expect it to be equivalent to df2.fillna(0).add(2)
. If this is intended behavior, then the docstring should be updated to clarify this.