Reputation: 3
I tried to load data from a csv file but i can't seem to be able to re-align the column headers to the respective rows for a clearer data frame.
Below is the output of
df.head()
bookID,title,authors,average_rating,isbn,isbn13,language_code,# num_pages,ratings_count,text_reviews_count
0 1,Harry Potter and the Half-Blood Prince (Harr... 1 2,Harry Potter and the Order of the Phoenix (H... 2 3,Harry Potter and the Sorcerer's Stone (Harry... 3 4,Harry Potter and the Chamber of Secrets (Har... 4 5,Harry Potter and the Prisoner of Azkaban (Ha...
import pandas as pd
file = 'C:/Users/user/Documents/Temporary data sets for practise only/books.csv'
df = pd.read_csv(file, sep ='/t')
df.head()
Upvotes: 0
Views: 39
Reputation: 81
You've set '\t' as your delimiter value while your document extract shows commas between the columns. Try
df = pd.read_csv(file, sep =',')
or just
pd.read_csv(file)
since ',' is the standard delimiter.
Upvotes: 1