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

Index names lost when calling sort_index #262

Closed
wesm opened this issue Oct 20, 2011 · 0 comments
Closed

Index names lost when calling sort_index #262

wesm opened this issue Oct 20, 2011 · 0 comments
Labels
Milestone

Comments

@wesm
Copy link
Member

wesm commented Oct 20, 2011

MultiIndex names get lost in the returned dataframe after sort_index is used.
Here is an example:

In [1]: import pandas

In [2]: pandas.__version__
Out[2]: '0.4.3'

In [3]: index = pandas.MultiIndex.from_tuples([('x','y','z'), ('a','b','c'), ('p','q','r')], names=['one','two','three'])

In [4]: df = pandas.DataFrame(randn(3, 5), index=index)

In [5]: df
Out[5]:
         0       1       2       3       4
x  y  z -1.098  -0.3314 -0.5526  0.3791  1.12
a  b  c  1.141   0.3309 -0.6509 -0.561  -1.086
p  q  r  0.3399 -0.3135  1.677   0.533   0.1158


In [6]: df.index.names
Out[6]: ['one', 'two', 'three']

In [7]: dfs = df.sort_index()

In [8]: dfs
Out[8]:
         0       1       2       3       4
a  b  c  1.141   0.3309 -0.6509 -0.561  -1.086
p  q  r  0.3399 -0.3135  1.677   0.533   0.1158
x  y  z -1.098  -0.3314 -0.5526  0.3791  1.12


In [9]: dfs.index.names
Out[9]: [None, None, None]
@wesm wesm closed this as completed Oct 20, 2011
dan-nadler pushed a commit to dan-nadler/pandas that referenced this issue Sep 23, 2019
Mdp 1293 VersionStore.append safety

A few changes here to ensure that append doesn't corrupt data in cases were find returns an incomplete set of chunks.

This might occur if a concurrent writer is updating / pruning the chunks, or during a failover if we're unlucky enough to query the new primary before all oplog entries have been applied to the indexes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant