I want to load the population data csv file downloaded from resas into pandas, but
The following error message occurred:
df File "<ipython-input-13-5abd 90abec 15>", line 4
df=pd.read_csv(url, encoding="SHIFT-JIS")
^
SyntaxError: invalid character identifier
I thought it was an elementary mistake, so I tried typing "", "."
import pandas as pd
url='https://drive.google.com/file/d/e/view?usp=sharing'
df=pd.read_csv(url, encoding="SHIFT-JIS")
# display df
df=pd.read_csv(url, encoding="SHIFT-JIS")
appears to be followed by a full-width blank.
If you copied it from the source, that's probably the reason.Try removing the full-width blank.
The next commented issue is probably related to this article.
What to note when having Pandas read the csv in excel output
This can be found in test2.csv in
"·Hashigodaka "" """
"
·Tachisaki "Saki"
This is due to a mixture of Windows extension strings such as .
To read such characters, the character code must be cp932.
encoding='cp932'
Try encoding='cp932'
.
© 2024 OneMinuteCode. All rights reserved.