unpackAI / DL201

Deep learning 201
6 stars 6 forks source link

SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape #12

Open RalfGermany opened 2 years ago

RalfGermany commented 2 years ago

Code: import pandas as pd

encoding='iso-8859-1'

personalLoans = pd.read_excel('C:\Users\Ralf\Downloads\DL201\Bank_Personal_Loan_Modelling.xlsx',sheet_name=1)

personalLoans.sample(5)

Error: File "/tmp/ipykernel_33/1416280869.py", line 3 personalLoans = pd.read_excel('C:\Users\Ralf\Downloads\DL201\Bank_Personal_Loan_Modelling.xlsx',sheet_name=1) ^ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

Attention: Copy the file Bank_Personal_Loan_Modelling.xlsx here on unpackAI/DL201 to your local computer into Downloads

Philanoe commented 2 years ago

Hi Ralf,

I just tried your code after downoading the file on my own computer (Windows 10) Here is my code

import pandas as pd personalLoans = pd.read_excel('C:\DataBase_for_AI\Bank_Personal_Loan_Modelling.xlsx',sheet_name=1) print(personalLoans.sample(5))

He worked for me after I installed openpyxl on my computer. I am using python 3.9.7 on Spyder

I had no error for the following code too : print("test 3") personalLoans = pd.read_excel(u"E:\DataBase_for_AI\Bank_Personal_Loan_Modelling.xlsx",sheet_name=1) print(personalLoans.shape)

print("test 4") personalLoans = pd.read_excel(r"E:\DataBase_for_AI\Bank_Personal_Loan_Modelling.xlsx",sheet_name=1) print(personalLoans.shap

My script was saved into a python file, encoded as UTF-8. Is it the case for yours ?