1

I can print my data frame and see label TSLA but I don't know how to get that string from my variable...enter image description here

>>> t.axes
[MultiIndex(levels=[['TSLA'], [2018-07-02 00:00:00, 2018-07-03 00:00:00, 2018-07
-04 00:00:00, 2018-07-05 00:00:00, 2018-07-06 00:00:00, 2018-07-09 00:00:00, 201
8-07-10 00:00:00, 2018-07-11 00:00:00, 2018-07-12 00:00:00, 2018-07-13 00:00:00,
 2018-07-16 00:00:00, 2018-07-17 00:00:00, 2018-07-18 00:00:00, 2018-07-19 00:00
:00, 2018-07-20 00:00:00]],
           labels=[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 3, 4
, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]],
           names=['Symbol', 'Date']), Index(['Close', 'High', 'Low', 'Open', 'Vo
lume'], dtype='object')]
>>>
1
  • t.get_level_values(0) or t.get_level_values(1) Commented Jul 21, 2018 at 9:35

1 Answer 1

2

Use pandas.index.get_level_values

In your case, probably

t.index.get_level_values(0).unique()[0]
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.