Skip to content

replace function broken for Series with dtype: datetime64 #11868

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
shanmuga-cv opened this issue Dec 19, 2015 · 2 comments
Closed

replace function broken for Series with dtype: datetime64 #11868

shanmuga-cv opened this issue Dec 19, 2015 · 2 comments
Labels
Datetime Datetime data dtype Duplicate Report Duplicate issue or pull request Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

Comments

@shanmuga-cv
Copy link

This bug was introduced in v0.17.1

from datetime import datetime
import pandas as pd
ser = pd.Series([datetime.now()]*4, index=range(4))
ser.replace('a', 10)

This throws the following exception.

Traceback (most recent call last):  
  File "/home/xxxx/anaconda/envs/py3/lib/python3.4/site-packages/pandas/core/internals.py", line 2061, in _try_coerce_args  
    other = other.astype('i8',copy=False).view('i8')  
ValueError: invalid literal for int() with base 10: 'a'  
  
During handling of the above exception, another exception occurred:  
  
Traceback (most recent call last):  
  File "/home/xxxx/anaconda/envs/py3/lib/python3.4/site-packages/pandas/core/internals.py", line 594, in replace  
    values, _, to_replace, _ = self._try_coerce_args(self.values, to_replace)  
  File "/home/xxxx/anaconda/envs/py3/lib/python3.4/site-packages/pandas/core/internals.py", line 2066, in _try_coerce_args  
    raise TypeError  
TypeError  
  
During handling of the above exception, another exception occurred:  
  
Traceback (most recent call last):  
  File "", line 1, in   
  File "/home/xxxx/anaconda/envs/py3/lib/python3.4/site-packages/pandas/core/generic.py", line 3110, in replace  
    inplace=inplace, regex=regex)  
  File "/home/xxxx/anaconda/envs/py3/lib/python3.4/site-packages/pandas/core/internals.py", line 2870, in replace  
    return self.apply('replace', **kwargs)  
  File "/home/xxxx/anaconda/envs/py3/lib/python3.4/site-packages/pandas/core/internals.py", line 2823, in apply  
    applied = getattr(b, f)(**kwargs)  
  File "/home/xxxx/anaconda/envs/py3/lib/python3.4/site-packages/pandas/core/internals.py", line 607, in replace  
    if not mask.any():  
UnboundLocalError: local variable 'mask' referenced before assignment  
@shanmuga-cv
Copy link
Author

related StackOverflow question

@jreback
Copy link
Contributor

jreback commented Dec 19, 2015

this is a dupe of #11698

and was closed by #11715 in master

@jreback jreback closed this as completed Dec 19, 2015
@jreback jreback added Datetime Datetime data dtype Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Duplicate Report Duplicate issue or pull request labels Dec 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Duplicate Report Duplicate issue or pull request Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Projects
None yet
Development

No branches or pull requests

2 participants