0
votes

i am trying to import a dataset in jupyter notebook and i wrote the following code following a tutorial i was following on youtube but i couldn't run the dataset. here is the code;

df = pandas.read_csv('C:\\Users\\CMuasya\\downloads\\data_wrangling_datasets\\data\\gapminder.tsv', sep='\t')
df = head()

the error being displayed is as follows;

--------------------------------------------------------------------------- NameError Traceback (most recent call last) in ----> 1 df = head()

NameError: name 'head' is not defined

what could be the problem and what is the solution to the error? kind regards

1
df = df.head() - Barmar
The problem is that head() is undefined within the scope. The solution depends on the steps you were supposed to follow in order to get here, likely a missed import. Please post a link to the video so that prospective answerers know what you're trying to do. - Michael Ruth

1 Answers

0
votes

individual head() is nothing if you want get 5 rows of data then

df = pd.read_csv('xyz.csv')
print(df.head())

head is a method called on dataframe