Reputation: 592
I have a text file with text and numerical data in the format shown in the following picture:
I am importing this file using pandas
using the following command:
df = pd.read_csv('dum.txt',sep='\t', header=[0,1], index_col=0)
In this file, I want to find the unique texts in the row called Tag
(['Tag1', 'Tag1', 'Tag1', Tag1, 'Tag5']
) as a python list. How can I do it?
When I use df.columns
, I get this:
>>> df.columns
MultiIndex(levels=[[u'T1', u'T2', u'T3', u'T4', u'T5'],
[u'Tag1', u'Tag5']], labels=[[0, 1, 2, 3, 4], [0, 0,
0, 0, 1]], names=[u'Type', u'Tag'])
In the aforesaid example, how can I get the unique texts in the row called Tag
? Thanks.
Upvotes: 2
Views: 112