Skip to content

UnboundLocalError: local variable 'mask' referenced before assignment #12726

Closed
@TurnaevEvgeny

Description

@TurnaevEvgeny

Code Sample, a copy-pastable example if possible

pd.to_datetime(pd.Series(['Jul 31, 2009', '2010-01-10', None])).to_frame().replace('', np.nan)

File "/var/www/envs/fring_internal/local/lib/python2.7/site-packages/pandas/core/generic.py", line 3110, in replace
    inplace=inplace, regex=regex)
  File "/var/www/envs/fring_internal/local/lib/python2.7/site-packages/pandas/core/internals.py", line 2870, in replace
    return self.apply('replace', **kwargs)
  File "/var/www/envs/fring_internal/local/lib/python2.7/site-packages/pandas/core/internals.py", line 2823, in apply
    applied = getattr(b, f)(**kwargs)
  File "/var/www/envs/fring_internal/local/lib/python2.7/site-packages/pandas/core/internals.py", line 607, in replace
    if not mask.any():
UnboundLocalError: local variable 'mask' referenced before assignment

Expected Output

Not sure, raise a TypeError("datetime64[ns] is not coercible to string") probably.

output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 2.7.6.final.0
python-bits: 64
OS: Darwin
OS-release: 14.3.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.17.1
nose: 1.3.7
pip: 7.0.3
setuptools: 17.0
Cython: 0.23.4
numpy: 1.8.2
scipy: 0.16.0
statsmodels: None
IPython: 3.2.0
sphinx: 1.3.1
patsy: None
dateutil: 1.5
pytz: 2013.7
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.3.1
openpyxl: 2.3.0
xlrd: 0.9.4
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.8
pymysql: None
psycopg2: 2.6.1 (dt dec pq3 ext lo64)
Jinja2: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDuplicate ReportDuplicate issue or pull requestIndexingRelated to indexing on series/frames, not to indexes themselves

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions