Skip to content

RecursionError when passing long to fillna #18316

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
jbrockmendel opened this issue Nov 16, 2017 · 4 comments
Closed

RecursionError when passing long to fillna #18316

jbrockmendel opened this issue Nov 16, 2017 · 4 comments
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

Comments

@jbrockmendel
Copy link
Member

>>> ser = pd.Series([1, np.nan])
>>> ser.fillna(2L)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/pandas/core/series.py", line 2648, in fillna
    **kwargs)
  File "/usr/local/lib/python2.7/site-packages/pandas/core/generic.py", line 4329, in fillna
    downcast=downcast)
  File "/usr/local/lib/python2.7/site-packages/pandas/core/internals.py", line 3451, in fillna
    return self.apply('fillna', **kwargs)
  File "/usr/local/lib/python2.7/site-packages/pandas/core/internals.py", line 3324, in apply
[...]
  File "/usr/local/lib/python2.7/site-packages/pandas/core/internals.py", line 422, in fillna
    return self.split_and_operate(mask, f, inplace)
  File "/usr/local/lib/python2.7/site-packages/pandas/core/internals.py", line 464, in split_and_operate
    nv = f(mask, new_values, None)
  File "/usr/local/lib/python2.7/site-packages/pandas/core/internals.py", line 420, in f
    downcast=None)
  File "/usr/local/lib/python2.7/site-packages/pandas/core/internals.py", line 399, in fillna
    values, _, _, _ = self._try_coerce_args(self.values, value)
  File "/usr/local/lib/python2.7/site-packages/pandas/core/internals.py", line 696, in _try_coerce_args
    if np.any(notna(other)) and not self._can_hold_element(other):
  File "/usr/local/lib/python2.7/site-packages/pandas/core/internals.py", line 1836, in _can_hold_element
    tipo = maybe_infer_dtype_type(element)
  File "/usr/local/lib/python2.7/site-packages/pandas/core/dtypes/cast.py", line 513, in maybe_infer_dtype_type
    elif is_list_like(element):
  File "/usr/local/lib/python2.7/site-packages/pandas/core/dtypes/inference.py", line 266, in is_list_like
    return (isinstance(obj, Iterable) and
  File "/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/lib/python2.7/abc.py", line 132, in __instancecheck__
    if subclass is not None and subclass in cls._abc_cache:
RuntimeError: maximum recursion depth exceeded
@gfyoung gfyoung added Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Dtype Conversions Unexpected or buggy dtype conversions Bug 2/3 Compat labels Nov 16, 2017
@gfyoung
Copy link
Member

gfyoung commented Nov 16, 2017

A Python 2-only issue. "2L" is invalid syntax for Python 3.

Most unusual indeed. Investigation and PR is welcome!

@Scorpil
Copy link
Contributor

Scorpil commented Nov 19, 2017

I did a small investigation and problem seams to start here. _try_coerce_args eventually throws exception for 2L because _can_hold_element does not check for long type.

I couldn't find tests for Block.fillna, and it might be tricky to set them up since Block is such an internal class. I will not have enough time to complete it, feel free to pick it up.

@Licht-T
Copy link
Contributor

Licht-T commented Nov 20, 2017

I am working on this, and the fixing is almost done.

@Licht-T
Copy link
Contributor

Licht-T commented Dec 9, 2017

@gfyoung This issue was fixed.
#18385

@jreback jreback closed this as completed Dec 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants