I am relatively new to Python and pandas and struggling with (hierarchical) indexes. I have the basics, but I'm lost with a more advanced cut and cross split.
For example, with the following data framework
import pandas as pd
import numpy as np
data = pd.DataFrame(np.arange(9).reshape((3, 3)),
index=pd.Index(['Ohio', 'Colorado', 'New York'], name='state'), columns=pd.Index(['one', 'two', 'three'], name='number'))
I want to highlight everything except the line with the index 'Colorado'. For a small dataset, I could do:
data.ix[['Ohio','New York']]
But if the number of unique index values is large, it is impractical. Naively, I would expect a syntax like
data.ix[['state' != 'Colorado']]
However, this only returns the first Ohio record and does not return New York. It works, but cumbersome
filter = list(set(data.index.get_level_values(0).unique()) - set(['Colorado']))
data[filter]
Surely there is a more Pythonic, verbose way to do this?