Skip to content

BUG: Segfault in DataFrame.pivot with complex #12666

@ycopin

Description

@ycopin

With attached CSV-file test_csv.txt, the following code will segfault if the input dataframe has more than 17 entries:

import pandas as PD

df = PD.read_csv('test_csv.txt',
                 index_col=0,
                 converters={'xyinrad': complex,
                             'xyoutm': complex})

# Pivot works fine with 17 entries
df[:-1].info()
pivot = df[:-1].pivot('wave', 'xyinrad', 'xyoutm')
print("Still alive".center(50, '!'))

# Pivot segfaults with 18 entries
df.info()
print("Dave, my mind is going.".center(50, '.'))
pivot = df.pivot('wave', 'xyinrad', 'xyoutm')

Result

<class 'pandas.core.frame.DataFrame'>
Int64Index: 16 entries, 0 to 15
Data columns (total 3 columns):
wave       16 non-null float64
xyinrad    16 non-null complex128
xyoutm     16 non-null complex128
dtypes: complex128(2), float64(1)
memory usage: 768.0 bytes
!!!!!!!!!!!!!!!!!!!Still alive!!!!!!!!!!!!!!!!!!!!
<class 'pandas.core.frame.DataFrame'>
Int64Index: 17 entries, 0 to 16
Data columns (total 3 columns):
wave       17 non-null float64
xyinrad    17 non-null complex128
xyoutm     17 non-null complex128
dtypes: complex128(2), float64(1)
memory usage: 816.0 bytes
.............Dave, my mind is going...............
Segmentation fault (core dumped)

Expected Output

  • No segfault!
  • Return the pivot table

Output of pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.6.final.0
python-bits: 32
OS: Linux
OS-release: 3.16.0-38-generic
machine: i686
processor: i686
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.18.0
nose: 1.3.4
pip: 8.1.1
setuptools: 20.3
Cython: 0.21.1
numpy: 1.10.4
scipy: 0.16.1
statsmodels: None
xarray: None
IPython: 4.1.2
sphinx: 1.3.5
patsy: None
dateutil: 2.5.0
pytz: 2016.1
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.5.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: 0.8
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: 2.4.5 (dt dec mx pq3 ext)
jinja2: 2.8
boto: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugComplexComplex NumbersReshapingConcat, Merge/Join, Stack/Unstack, ExplodeTestingpandas testing functions or related to the test suite

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions