Skip to content
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

BUG: series update #4080

Closed
midfield opened this issue Jun 29, 2013 · 15 comments
Closed

BUG: series update #4080

midfield opened this issue Jun 29, 2013 · 15 comments
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@midfield
Copy link

import pandas as pd

df = pd.DataFrame(dict((c, [1,2,3]) for c in ['a', 'b', 'c']))
df.set_index(['a', 'b', 'c'], inplace=True)
s = pd.Series([1], index=[(2,2,2)])
df['val'] = 0
df
df['val'].update(s)
df

on my machine (pandas 0.11.1.dev-45d298d, linux) i get the rather unexpected output


                       val
a b c
1 1 1                    0
2 2 2  4607182418800017408
3 3 3                    0


@midfield
Copy link
Author

sorry i'm having trouble reproducing right now, let me double check.

@midfield
Copy link
Author

i had a typo in the code, try it now.

@jtratner
Copy link
Contributor

Yep - I see this on master. Hmmm...

@jtratner
Copy link
Contributor

Now I'm only seeing it intermittently :(

@jtratner
Copy link
Contributor

nvm, I see it consistently now...

@cpcloud
Copy link
Member

cpcloud commented Jun 29, 2013

figured out the issue...it's in common._maybe_upcast_putmask.

ipdb> p r
array([ 0.,  1.,  0.])
ipdb> result
array([0, 0, 0])
ipdb> result.view(float)
array([ 0.,  0.,  0.])
ipdb> p r.view(int)
array([                  0, 4607182418800017408,                   0])

@jreback
Copy link
Contributor

jreback commented Jun 29, 2013

yep...had this bug elsewhere...pr soon

@cpcloud
Copy link
Member

cpcloud commented Jun 29, 2013

i think this is the problem

                change.dtype = r.dtype
                change[:] = r

@cpcloud
Copy link
Member

cpcloud commented Jun 29, 2013

@jreback do u mind if i take this one?

@cpcloud
Copy link
Member

cpcloud commented Jun 29, 2013

oh darn

@jreback
Copy link
Contributor

jreback commented Jun 29, 2013

this is actually quite non-trivial. The existing code works fine, but the parent DataFrame needs a way to update the blocks, related to #3970 (though that had more to do with a bug in consolidation)

@cpcloud
Copy link
Member

cpcloud commented Jun 29, 2013

reback-fu is what we should start calling ur prs

@wesm
Copy link
Member

wesm commented Jul 5, 2013

In place dtype changes are a nono. We need to find a better way

@jreback
Copy link
Contributor

jreback commented Jul 5, 2013

Inplace dtype changes are required on an int series (though pretty rare), when converting to floats (or it simply doesn't change).....this can be fixed (I think) when Series is inhertited from NDFrame; then its the same as dtype changes in Frame, just replace the innarrds and return, the top-level object is unchanged.

currently the dtype HAS to change inplace because the user has a reference to the Series

not saying that this is a great solution, but only one currently

@jreback
Copy link
Contributor

jreback commented Aug 16, 2013

closed by #3482

@jreback jreback closed this as completed Aug 16, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
5 participants