0

I used the codes below

import pandas as pd
import numpy as np
data = pd.read_csv('C:\Users\Admin\Downloads\pims-indians-diabetes',header=None, names=['Prognancies','Glucose','BloodPressure','SkinThickness','Insulin','BMI','Pedigree','Age','Outcome'])
print(data.head())

The error I got is below. I also tried suggestions for similar questions to no avail

File "<ipython-input-11-dd1ac43370f9>", line 3
    data = pd.read_csv('C:\Users\Admin\Downloads\pims-indians-diabetes',header=None,names=['Prognancies','Glucose','BloodPressure','SkinThickness','Insulin','BMI','Pedigree','Age','Outcome'])
                                                                       ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

I tried to resolve the problem using response to similar questions.

I expect some one to look at the codes and error massage and assist me

Brian61354270
  • 8,690
  • 4
  • 21
  • 43
  • 1
    Write it as `'C:\\Users\\Admin\\Downloads\\pims-indians-diabetes'`, with double backslashes. – tevemadar Apr 02 '23 at 17:01
  • TL;DR: the `\U` in `'C:\Users...'` is a unicode escape sequence, not the literal characters ``\`` and `U`. Per the dupe, you need to escape the ``\`` or use a raw string. – Brian61354270 Apr 02 '23 at 17:03

1 Answers1

0

you have to pass exactly the full path of the .csv file like: data = pd.read_csv("data/data.csv")