Skip to content

Inappropriate/inconsistent behavior in data assignment (v. 0.13) #6043

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

Closed
cyrusmaher opened this issue Jan 23, 2014 · 2 comments · Fixed by #6044
Closed

Inappropriate/inconsistent behavior in data assignment (v. 0.13) #6043

cyrusmaher opened this issue Jan 23, 2014 · 2 comments · Fixed by #6044
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@cyrusmaher
Copy link
Contributor

I find it convenient to store lists or series as elements in a dataframe. However, it seems panda gets confused if the iterable is the same length as the number of rows in the dataframe. Here's a minimal example:

matchmat_test = pd.DataFrame(index=[0,1], 
                             columns=[1], dtype=list)
matchmat_test.ix[0,0] = [1,2,3]

Returns:

           0
0  [1, 2, 3]
1        NaN

If we then assign to the same element again:

matchmat_test.ix[0,0] = [1,2]

we get:

 0
0  1
1  2
@jreback
Copy link
Contributor

jreback commented Jan 23, 2014

@cyrusmaher I fixed this, but keep in mind that storing anything object-like a list (or you can see my example, I created an object that is really a wrapped scalar). is very inefficient as the resultant dtype is object. You are basically losing all of the power of vectorized computation.

Furthermore you can only do very limited setting operations, e.g. only set via a single indexer, anything else won't work.

You should look at using Panels / Multi-indexed frames or multiple structures (e.g. frames) to avoid using lists at all costs.

@cyrusmaher
Copy link
Contributor Author

Thank you! For what I'm working on, the lists (really np arrays) are all of
different sizes and all operations are elementwise. The dataframe indexing
is useful and applymap is nice too. Thanks again for your hard work!

On Jan 22, 2014, at 5:18 PM, jreback [email protected] wrote:

@cyrusmaher https://github.com/cyrusmaher I fixed this, but keep in mind
that storing anything object-like a list (or you can see my example, I
created an object that is really a wrapped scalar). is very inefficient as
the resultant dtype is object. You are basically losing all of the power of
vectorized computation.

Furthermore you can only do very limited setting operations, e.g. only set
via a single indexer, anything else won't work.

You should look at using Panels / Multi-indexed frames or multiple
structures (e.g. frames) to avoid using lists at all costs.


Reply to this email directly or view it on
GitHubhttps://github.com//issues/6043#issuecomment-33088291
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
2 participants