Python - KeyError in Pandas DataFrame -


when import dataset:

dataset = pd.read_csv('lyrics.csv', delimiter = '\t', quoting = 2) 

it prints so:

                                 lyrics,classification 0    should have known better girl yo... 1    can shake apple off apple tree\nshak... 2    it's been hard day's night\nand i've been wo... 3    michelle, ma belle\nthese words go to... 4    can't buy me love, love\ncan't buy me love\ni'... 5    love you\ncause tell me things want to... 6    dig pygmy charles hawtrey , deaf ... 7    song robin sings,\nthrough years of endl... 8    love me tender, love me sweet,\nnever let me g... 9    well, it's 1 money,\ntwo sho... 10   words let know\nstill could... 

and if print (dataset.columns), get:

index([u'lyrics,classification'], dtype='object') 

but if try prints lyrics, so:

for in range(0, len(dataset)):     lyrics=dataset['lyrics'][i]     print lyrics 

i following error:

keyerror: 'lyrics' 

what missing here?

since set delimiter tab (\t), header isn't parsed think. 'lyrics,classification' 1 column name. if want keep delimiter tab, between lyrics , classification there should tab rather comma.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -