0

My xor.csv is:

x1,x2,x3,x4,y
0,0,0,0,0
0,0,0,1,1
0,0,1,0,1
0,0,1,1,0
0,1,0,0,1
0,1,0,1,0
0,1,1,0,0
0,1,1,1,1

Code to fetch this file using pandas is:

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

testing_data = pd.read_csv('..\Data_Set\xor.csv')

And it gives me this error:

  File "C:\Users\harmee\Desktop\python_tut\ML\NN\toy_nn.py", line 11
     testing_data = pd.read_csv('..\Data_Set\xor.csv')
                          ^
  SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 11-12: truncated \xXX escape

Tried using the encoding attribute using encoding = 'utf-8' and encoding = 'ISO-8859-1' but still it doesn't work.

1 Answers1

1

Pass dataset path as either by single forward slash(/) or by double backward slash(\\).

Try this:

testing_data = pd.read_csv('../Data_Set/xor.csv')

or

testing_data = pd.read_csv('..\\Data_Set\\xor.csv')

or

testing_data = pd.read_csv(r'..\Data_Set\xor.csv')

Both will work the same.

Kyle Gunn
  • 23
  • 7