-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: SEGFAULT when assigning nan via iloc #6056
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
assign with a multi-axis using loc or ix df.ix[5,'foo'] = np.nan using a chained assignment can cause aliasing issue under certain versions of numpy so pandas will handle this on 0.13.1 however you should always assign via loc or ix to avoid any issues (see the above link) |
@jreback Thanks for explanation. However, it's not just the iloc, this also fails:
There are no errors, no warnings, the first line passes, yet then it segfaults on head(). |
it's the same problem - |
it's a view getting corrupted don't assign that way - it's specifically warned not to do it (not actually for this reason) but because the results can be unpredictable depending on whether u have a view or not (eg it may not change because it's actually a copy) |
Alright then, what's a direct (correct) replacement for doing something like Btw also: in the above segfault case, why is there no warning/error thrown (SettingWIthCopyException?) if it's known to get corrupted? |
ix will work it handles both positional and labels the warning is very tricky to have happen and is not guaranteed - this heuristic has a gazillion cases - most of which you don't want to warn and a very small subset which u do want to try to figure it out????? the issue is a python syntax issue doing a repeated getattr then a getitem is impossible to detect if u do df['calumn''].iloc[0] will warn iIIRC |
So, let's say if my labels are integers and then using .ix introduces another ambiguity -> one would have to do something like Btw just tested, both I think it was discussed in another issue, so that stuff like |
ok...this is the same bug as #6026 here's some short-term work arounds:
you won't be gettng a warning on thanks for reporting though! |
You're welcome! Fair enough, that kinda explains it; will upgrade to numpy 1.8.0 and look forward to pandas 0.13.1. UPD: Confirming, no warning/no segfault in all cases on numpy 1.8.0 |
I have a DataFrame that looks like this:
Now, this segfaults:
This also segfaults, but not right away:
And this:
However this doesn't:
I tried recreating the error with a minimal case but couldn't since small trivial examples don't seem to segfault; debugging is also kinda hard cause it goes deep into pandas guts..
This happened right after I updated to 0.13, never happened before.
Any ideas?
The text was updated successfully, but these errors were encountered: