How to resolve Google Colab Data Table error?

Question:

When I import the dataset I want to operate on to Google Colab, a random view is created. As you can see from the image, I want it to have the view below. I couldn’t find any solution. I would be glad if you help.

thanks
enter image description here

I couldn’t try anything specific as I couldn’t understand the problem.

Asked By: Kaan Tiftikci

||

Answers:

Solution:

data = pd.read_csv("filename.csv")
data.head()

Explaination:

The sep parameters takes a str, default ‘,’ it specifies the delimiter to use. In our case the delimited is ‘,’ which is the default option hence there is not need to specify any delimiter.

The header parameter specifies row numbers to use as the column names, at the start of the dataset. Default behavior is to infer the column names, if no names are passed the behavior is identical to header=0 and column names are inferred from the first line of the file, if column names are passed explicitly then the behavior is identical to header=None. In our case we do not need to specify the header parameter value as we already have the column names on the first line of the dataset.

Refer pandas documentation for more information on pandas.read_csv()

data.head() gives us the first n rows of the data which is loaded, default n=5. Refer pandas documentation for more information on pandas.DataFrame.head()

Answered By: Rayster Fernandes
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.