Error while reading a csv file in pandas

pandas
python
#1

Whenever i compiled the code above i get the following result :

SyntaxError: (unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3:
truncated \UXXXXXXXX escape.

import numpy as np
import pandas as pd
import matplotlib as plt
df = pd.read_csv('C:\Users\ebene\Downloads\train_u6lujuX_CVtuZ9i.csv')
df.head(10)

What can i do to solve the issue?

0 Likes

#2

You can use your path as raw string, by defining r before URL:

pd.read_csv(r‘C:\Users\ebene\Downloads\train_u6lujuX_CVtuZ9i.csv’)

It should work.

1 Like

#3

James please try below code and let me know if this works -
import numpy as np
import pandas as pd
import matplotlib as plt
df = pd.read_csv(‘C:/Users/ebene/Downloads/train_u6lujuX_CVtuZ9i.csv’)
df.head(10)

and make sure the file is present in the right path . :slight_smile:

1 Like

#4

While loading the dataset, use forward slash("/") instead of back slash("")…

Correct syntax
df = pd.read_csv(‘C:/Users/ebene/Downloads/train_u6lujuX_CVtuZ9i.csv’)

1 Like

#5

Send ME a copy of the dataset (the csv file ) at goel.samarth18@gmail.com. Let me try the import.

0 Likes