import pandas as pd
df = pd.read_csv('Pokemon1.csv',index_col = 0)
An error is reported after executing the code: Unicode decodeerror: ‘UTF-8’ codec can’t decode byte 0x89 in position 1538: invalid start byte
an error is still reported when trying to manually specify the encoding format [encoding = “UTF-8″/encoding = “GBK”):
df = pd.read_csv('Pokemon1.csv',index_col = 0,encoding="gbk")
Solution:
1 Find the CSV file used -> Right mouse button -> Opening method -> Select Notepad
2 Open the file and select File -> “Save as”, you can see that the default code is ANSI. Select UTF-8 to save a copy again, and then open it with PD.Read_csv(). There will be no error:
Read More:
- How to Solve Python Pandas Read or Import Files Error
- [Solved] jupyter notebook Error: ModuleNotFoundError: No module named jupyter_nbextensions_configurator
- [Solved] Jupyter Notebook Error: SparkException: Python worker failed to connect back
- Jupyter notebook Failed to Switch to the Virual Environment: DLL load failed python.exe could not find the entry
- [Solved] Jupyter notebook: TypeError: __init__() got an unexpected keyword argument ‘io_loop’
- [Solved] Jupyter Notebook Start Error: Fatal error in launcher: Unable to create process using
- Pandas read_csv pandas.errors.ParserError: Error tokenizing data
- [Solved] Jupyter notebook use pyLDAvis Error: modulenotfounderror: no module named ‘pyLDAvis’‘
- [Solved] jupyter notebook Error: 500 : Internal Server Error
- jupyter notebook Use pyLDAvis Error: AttributeError: module ‘pyLDAvis‘ has no attribute ‘gensim
- VScode: How to Solve Pylance Error (pip Library Files Installed)
- Pandas Read csv Error tokenizing data. C error: Expected 18 fields in line 173315, saw 20
- Django CSV file Error: UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xb5 in position 0: invalid start
- pd.to_csv Error: need to escape, but no escapechar set
- Python: How to Solve error While importing windpy
- How to Solve word2vec Module Error: AttributeError & UnicodeDecodeError
- [Solved] ParserError: NULL byte detected. This byte cannot be processed in Python‘s native csv library
- Python: How to Delete Empty Files or Folders in the Directory
- How to Solve Pytorch DataLoader Loading Error: UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xe5 in position 1023
- How to Solve wikiextractor Extract Wikipedia Corpus Error