BUG: pd.DataFrame.transform recursively loops in some cases
See original GitHub issue-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
(optional) I have confirmed this bug exists on the master branch of pandas.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
pd.DataFrame({"a":[None]}).transform({"a":int})
Problem description
Executing the above causes recursion depth limit exception. This is confusing and it is harder to pinpoint/debug than the expected exception.
Expected Output
Something akin to the output of int(None)
Output of pd.show_versions()
pandas : 1.0.3 numpy : 1.18.4 pytz : 2020.1 dateutil : 2.8.1 pip : 19.2.3 setuptools : 41.2.0 Cython : None pytest : 3.10.1 hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : None jinja2 : None IPython : None pandas_datareader: None bs4 : None bottleneck : None fastparquet : None gcsfs : None lxml.etree : None matplotlib : None numexpr : None odfpy : None openpyxl : None pandas_gbq : None pyarrow : None pytables : None pytest : 3.10.1 pyxlsb : None s3fs : None scipy : None sqlalchemy : None tables : None tabulate : None xarray : None xlrd : None xlwt : None xlsxwriter : None numba : None
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
I’ve looked into the try / except you mentioned(within aggregate of frame.py), and the recurssion occurs because the except is not doing anything with the error:
I’ve managed to fix it raising an error printing what went wrong, as in the following code:
I am now just making sure this fix doesn’t break anything else.
@pedrooa Looks like the problem is the the try / except within aggregate of frame.py, would be interesting to look into why that’s needed and if there’s a better way to handle things