Skip to content

Crash when using align between a Series and a DataFrame and ffill (or bfill) method #31785

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
m-lal opened this issue Feb 7, 2020 · 3 comments · Fixed by #31788
Closed

Crash when using align between a Series and a DataFrame and ffill (or bfill) method #31785

m-lal opened this issue Feb 7, 2020 · 3 comments · Fixed by #31788
Labels
Regression Functionality that used to work in a prior pandas version
Milestone

Comments

@m-lal
Copy link

m-lal commented Feb 7, 2020

Code Sample, a copy-pastable example if possible

# Your code here
import pandas as pd

x = pd.Series(range(10), index=range(10))
y = pd.DataFrame(0.0, index=range(20), columns=range(12))

# works fine (no fill method)
x.align(y)

# crash
x.align(y, method='ffill')

# works fine if x is converted to a DataFrame
x.to_frame().align(y, method='ffill')

Problem description

This problem only occurs on pandas version >= 1.0.0
Pretty simple bug to reproduce... Quite a serious issue! It should probably shows elsewhere also.

**When using align between a Series and a DataFrame with a fill method the code hits this

assert isinstance(obj, type(self)), type(obj)
AssertionError: <class 'pandas.core.frame.DataFrame'>**

My guess is that isinstance(obj, type(self)) try to assert that a Series is a DataFrame which is not the case.

Expected Output

Similar to x.align(y), with forward filled values.

Output of pd.show_versions()

INSTALLED VERSIONS

commit : None
python : 3.7.4.final.0
python-bits : 64
OS : Windows
OS-release : 10
machine : AMD64
processor : Intel64 Family 6 Model 85 Stepping 4, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.None
pandas : 1.0.1
numpy : 1.18.1
pytz : 2019.3
dateutil : 2.8.1
pip : 19.0.3
setuptools : 40.8.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : 2.8.4 (dt dec pq3 ext lo64)
jinja2 : None
IPython : 7.12.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : 3.1.3
numexpr : 2.7.1
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pytest : None
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : None
tables : 3.6.1
tabulate : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None
numba : 0.48.0

@TomAugspurger
Copy link
Contributor

Thanks for the report. From #30613 I think. cc @topper-123

@TomAugspurger TomAugspurger added the Regression Functionality that used to work in a prior pandas version label Feb 7, 2020
@TomAugspurger TomAugspurger added this to the 1.0.2 milestone Feb 7, 2020
@topper-123
Copy link
Contributor

Yeah, this is caused by #30613. Looking into it.

@m-lal
Copy link
Author

m-lal commented Feb 7, 2020

You're welcome. Hope it helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants