3

I have a DataFrame object with 16 rows and 14671872 columns. I cannot for the life of me figure out how to slice this array in any reasonable amount of time on a quad core Dell T410 with 24GB of RAM.

I would just use the transpose of the array because that's much faster, but then I would have a MultiIndex on the columns, and I haven't yet found any documentation in Pandas showing how to use MultiIndexs as columns.

I thought about opening up an issue on the Github tracker, but I wanted to post here before I did that just in case I missed something totally obvious.

1
  • Could you be more specific about what you mean by "how to use MultiIndex as columns"? What do you need to do? Commented Sep 25, 2012 at 23:19

1 Answer 1

5

I think .xs might do what you want.

To get all shank 1's (i.e. where the first level of the MultiIndex is equal to 1).

df.xs(1, axis=1, level=0)

This is pretty flexible if you need to cross-section by a different level of the MultiIndex as well.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.