Guided Project: Exploring Hacker News Posts-Not able to remove headers from dataset

Screen Link: Replace this text with the URL to the screen you’re working on

hn=pandas.read_csv('hacker_news.csv')
print(hn[:5])
headers=hn[:1]
hn=hn[1:]```

In code , 'hn' is list of list ,So it should contain first row as headers but it does not,first row itself contains data,so i am not able remove headers from data set.

Hi,

Headers are the first row of list hn so its index should be 0. Therefore headers = hn[0]. It works for me.

Hope it helps.

1 Like

Hi satinder.ss017
I know a year has passed since the question was asked, hope this helps someone else in future. I encountered the same. Change the way the csv was read instead of using pandas try :

import csv
open_file = open(‘hacker_news.csv’)
hn = list(csv.reader(open_file))

:smile: