Skip to content

Conversation

jreback
Copy link
Contributor

@jreback jreback commented Sep 6, 2013

closes #4758

In [2]: df = DataFrame({'ACCOUNT':["ACCT1", "ACCT1", "ACCT1", "ACCT2"],
   ...:                         'TICKER':["ABC", "MNP", "XYZ", "XYZ"],
   ...:                         'val':[1,2,3,4]},
   ...:                        index=date_range("2013-06-19 09:30:00", periods=4, freq='5T'))

In [3]: df_multi = df.set_index(['ACCOUNT', 'TICKER'], append=True)

In [4]: df_multi.loc[(pd.Timestamp('2013-06-19 09:30:00', tz=None), 'ACCT1', 'ABC')]
Out[4]: 
val    1
Name: (2013-06-19 09:30:00, ACCT1, ABC), dtype: int64

In [5]: df_multi.loc[('2013-06-19 09:30:00', 'ACCT1', 'ABC')]
Out[5]: 
val    1
Name: (2013-06-19 09:30:00, ACCT1, ABC), dtype: int64

This is quite difficult to do, a partial selection on a single indexer, so KeyError for now

In [6]: df_multi.loc[('2013-06-19', 'ACCT1', 'ABC')]
KeyError: 'the label [ACCT1] is not in the [columns]'

hayd added a commit that referenced this pull request Sep 6, 2013
BUG: in multi-indexing with a partial string selection (GH4758)
@hayd hayd merged commit b15a376 into pandas-dev:master Sep 6, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Datetime as string in indexing a MultiIndex not always working

2 participants