-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Segfault in DataFrame.pivot with complex #12666
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
Comments
can you show a reproducible example that is copy-pastable. e.g either include the data in-line or create a sample frame. You are pivoting on complex numbers, you mean to do that? |
Sorry, here is a copy-pastable example: from io import StringIO
import pandas as PD
csv = StringIO(u"""
,wave,xyinrad,xyoutm
0,1.55e-06,(0.00523598775598+0.0200712863979j),(-0.06421774-0.06848953j)
1,1.55e-06,(0.00523598775598+0.0209439510239j),(-0.06422449-0.07932723j)
2,1.55e-06,(0.00610865238198+0.00872664625997j),(-0.07546985+0.07215781j)
3,1.55e-06,(0.00610865238198+0.00959931088597j),(-0.07540574+0.06128717j)
4,1.55e-06,(0.00610865238198+0.010471975512j),(-0.07534734+0.05043315j)
5,1.55e-06,(0.00610865238198+0.011344640138j),(-0.07529464+0.03959332j)
6,1.55e-06,(0.00610865238198+0.012217304764j),(-0.07524759+0.02876524j)
7,1.55e-06,(0.00610865238198+0.01308996939j),(-0.07520614+0.01794649j)
8,1.55e-06,(0.00610865238198+0.013962634016j),(-0.07517025+0.007134677j)
9,1.55e-06,(0.00610865238198+0.014835298642j),(-0.07513988-0.003672601j)
10,1.55e-06,(0.00610865238198+0.0157079632679j),(-0.07511502-0.01447775j)
11,1.55e-06,(0.00610865238198+0.0165806278939j),(-0.07509567-0.02528313j)
12,1.55e-06,(0.00610865238198+0.0174532925199j),(-0.0750818-0.03609117j)
13,1.55e-06,(0.00610865238198+0.0183259571459j),(-0.07507343-0.04690428j)
14,1.55e-06,(0.00610865238198+0.0191986217719j),(-0.07507053-0.05772485j)
15,1.55e-06,(0.00610865238198+0.0200712863979j),(-0.07507306-0.06855524j)
16,1.55e-06,(0.00610865238198+0.0209439510239j),(-0.07508092-0.07939773j)
""")
df = PD.read_csv(csv,
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') Yes I want to pivot on complex numbers, which are coordinates. It does not sound very clever to index/column on float-likes, but this was working fine until now. |
hmm, seems odd that that core dumps. |
For what it's worth,
|
hmm, easiest is simply to step thru this (until it borks). |
The segfault originates in The issue is surely coming from the fact that complex array is converted to 'object', by lack of complex-case in Could a |
Here is the shortest segfault case:
This does not crash with This raises 2 naive questions:
|
So this is a numpy bug, pls open an issue there.
We use
This should report |
No more segfault and things are working fine when using master numpy (now 1.12.0.dev0+41ec9fc), as well as numpy 1.11.rc2. Next release of numpy (1.11) should therefore fix the issue. Please feel free to close the issue, and thanks for your support. |
hmm, can you put in a test for this. we'll need to skip obviously for < 1.11, but we do test against numpy master. |
I'll try to do my best (never did that). Should I write a test for |
I think the test_algos is most appropriate |
With attached CSV-file test_csv.txt, the following code will segfault if the input dataframe has more than 17 entries:
Result
Expected Output
Output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: