I have the following txt file, I give few lines of it below. I want to make a dataframe using pandas having three columns. The first column titled 'Unique_id$ given 00001, 00002 etc, 2nd column titled as 'Labels' and third column titled as 'doc_id'.
I ran the following pandas command
df_text = pd.read_csv('trainset.txt', names = ['Unique_id','Lables', 'doc_id'],delim_whitespace=True)
and output is as follows
Unique_id Labels doc_id
1 C 9149180 3781329.0
2 B 4396080 9207819.0
3 B 1519858 11734712.0
4 A 15547167 NaN
5 C 11392916 NaN
So the label got shifted and it's treating the last column where element represent the bunch of documents id as separate columns. How can I rectify this? Make the last column with where each element is a list of document id?
The txt file is given below.
The txt file
00001 C 9149180 3781329
00002 B 4396080 9207819 9757979 344087 361152 2099731
00003 B 1519858 11734712
00004 A 15547167
00005 C 11392916
00006 A 8942774 8942775 8036464 7497161
00007 A 15547167
00008 C 12913777