get symbol from a pandas dataframe
本问题已经有最佳答案,请猛点这里访问。
我可以打印我的数据框并看到标签
1 2 3 4 5 6 7 8 9 10 11 | >>> 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.index.get_level_values(0).unique()[0] |