[Solved] raise KeyError(key) from err KeyError: ‘Dates‘

Description of error reporting:

Today, when reading Excel data and processing the data, an error is reported as follows:

Error reason:

The Excel table data read in by pandas is not aligned. Please check the Excel table data read in
I print out the dataframe after reading it into Excel

Solution:

Delete Sheet2 and Sheet3 in the Excel table, so that Pandas will align after reading the Excel table data

The root cause of such problems is that the data is not aligned

Debug method: 1. Print out the dataframe data and check the format of the data after it is read in. 2. Then adjust the read data

Read More: