Skip to content

BUG: Indexing bugs with reordered indexes (GH6252, GH6254) #6256

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

Merged
merged 1 commit into from
Feb 4, 2014

Conversation

jreback
Copy link
Contributor

@jreback jreback commented Feb 4, 2014

closes #6252
closes #6254

In [1]:  df = DataFrame(index=[3, 5, 4], columns=['A'])

In [2]: df.loc[[4, 3, 5], 'A'] = [1, 2, 3]

In [3]: df
Out[3]: 
   A
3  2
5  3
4  1

[3 rows x 1 columns]
In [4]: keys1 = ['@' + str(i) for i in range(5)]

In [5]: val1 = np.arange(5)

In [6]: keys2 = ['@' + str(i) for i in range(4)]

In [7]: val2 = np.arange(4)

In [8]: index = list(set(keys1).union(keys2))

In [9]: df = DataFrame(index = index)

In [10]: df['A'] = nan

In [11]: df.loc[keys1, 'A'] = val1

In [12]: df['B'] = nan

In [13]: df.loc[keys2, 'B'] = val2

In [14]: df
Out[14]: 
    A   B
@2  2   2
@3  3   3
@0  0   0
@1  1   1
@4  4 NaN

[5 rows x 2 columns]

jreback added a commit that referenced this pull request Feb 4, 2014
BUG: Indexing bugs with reordered indexes (GH6252, GH6254)
@jreback jreback merged commit 8e08686 into pandas-dev:master Feb 4, 2014
jreback added a commit that referenced this pull request Feb 4, 2014
yarikoptic added a commit to neurodebian/pandas that referenced this pull request Feb 10, 2014
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
1 participant