How to solve the error report when pandas reads excel? ? ?

Error 1

When the input is:
df = pd.read_excel(io='D:\XunleiDownload\002\people.xlsx')
error prompt:

OSError: [Errno 22] Invalid argument: 'D:\\XunleiDownload\x02\\people.xlsx' 

The reason for the error : Because the '\' has the function of escaping characters, this is the path identifier by default on the windows computer, but the compiler does not recognize this path.
Solution : Need to use'\' to indicate the path, or use'/' instead of the default under windows system''

Error 2

Error 2 is a bit strange. First, let me explain why it is strange. It is not very good for beginners to learn the pandas library, especially for people like me who teach themselves the pandas library. The code typed according to the official document also reported an error inexplicably, and almost persuaded a student who learned the pandas library.
For example, I enter the code: df = pd.read_excel(io='D:\\XunleiDownload\\002\\people.xlsx')
as a completely conforming code, I also start to report errors! ! ! There are a import xlrdlot of critical error lines, and there are many error prompts. It seems that the head is really big, and then I think it may be necessary to import this package, but the error is still reported. Then I thought that the pandas library that came with my conda was too old, and then I updated to the latest version and still got the same error! !
Pass the error message in the last line:

print “EXTERNSHEET(b7-):”
SyntaxError: invalid syntax

After querying, it was found that the pandas library still called the xlrd library when reading excel. Just updating the pandas library still did not work, so the solution only needs to update the xlrd library: the
pip install --upgrade xlrd
problem is over.

Guess you like

Origin blog.csdn.net/weixin_45915507/article/details/108270257