Skip to content

to_numeric crashes python on empty dataframe column #16604

Closed
@linar-jether

Description

@linar-jether

Crash sample

In[2]: df = pd.DataFrame(columns=['maybe_empty_column'])
  ...: pd.to_numeric(df['maybe_empty_column'], errors='ignore')

Process finished with exit code -1073741819 (0xC0000005)

Problem description

When calling to_numeric on an empty DataFrame column, python crashes with an access violation exit code (0xC0000005).

Expected Output

Should return an empty series with default dtype for empty series (int64)

for some reason, some empty Series objects work and some don't:

empty_that_works = pd.Series(['blabla',])[1:]
pd.to_numeric(empty_that_works)

empty_that_doesnt_work = pd.Series(dtype=object)
pd.to_numeric(empty_that_doesnt_work)

Output of pd.show_versions()

# Paste the output here pd.show_versions() here INSTALLED VERSIONS ------------------ commit: None python: 2.7.12.final.0 python-bits: 64 OS: Windows OS-release: 8.1 machine: AMD64 processor: Intel64 Family 6 Model 60 Stepping 3, GenuineIntel byteorder: little LC_ALL: None LANG: None LOCALE: None.None pandas: 0.20.1 pytest: 3.0.7 pip: 9.0.1 setuptools: 34.3.1 Cython: None numpy: 1.12.1 scipy: 0.18.1 xarray: None IPython: 5.3.0 sphinx: None patsy: 0.4.1 dateutil: 2.6.0 pytz: 2016.10 blosc: None bottleneck: None tables: None numexpr: 2.6.2 feather: None matplotlib: 1.5.3 openpyxl: None xlrd: 1.0.0 xlwt: None xlsxwriter: None lxml: None bs4: 4.5.1 html5lib: 0.9999999 sqlalchemy: None pymysql: None psycopg2: None jinja2: 2.9.6 s3fs: None pandas_gbq: None pandas_datareader: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions