52722/unicodedecodeerror-codec-decode-position-invalid-start-byte
While I importing the file it shows
UnicodeDecodeError: "utf-8" codec can"t decode byte 0xa0 in position 10: invalid start byte
Code:
import pandas as pd a = pd.read_csv("filename.csv")
You have to use the encoding as latin1 to read this file as there are some special character in this file, use the below code snippet to read the file,
import pandas as pd data=pd.read_csv("C:\\Users\\akashkumar\\Downloads\\Customers.csv",encoding='latin1') print(data.head())
Also Read: What does the error message utf-8 codec can't decode byte 0xa0 in position 10: invalid start byte indicate?
Hey, @Brij Mohan,
"encoding ='latin1' " mean means that dev tools are sourcing the files as latin1 instead of the UTF-8 files that they are. This happens irrespective of the Encoding: UTF-8.
Try using :
pd.read_csv(“Your filename", encoding="ISO-8859-1”)
The code that I parsed from some website was converted in this encoding instead of default UTF-8 encoding which is standard.
Thanks, This answer was helpful. READ MORE
Hi, @hala, Regarding your query, you can go ...READ MORE
Hey, @Himanshu. It's still most likely gzipped data. ...READ MORE
my code import wordcloud import numpy as np from matplotlib ...READ MORE
You can also use the random library's ...READ MORE
Syntax : list. count(value) Code: colors = ['red', 'green', ...READ MORE
Enumerate() method adds a counter to an ...READ MORE
You can simply the built-in function in ...READ MORE
You have to use the encoding as latin1 ...READ MORE
To read this dataset use encoding as ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.