While importing data from an Excel file into a data frame via
df = pd.read_excel('df.xlsx', skiprows = 8, usecols = 'B:AX')
,
the number of skipped rows is actually 9 (therefore columns' names from row 8 are not imported) and the data frame starts with data from column C instead of B (looks like rows and columns are somehow "indexed" from 0, making 0-8 ignored while importing). Also, a column which contains "+" in its name ("Name + Code") is imported into pandas
with a minus sign instead ("Name - Code"). What could be causing this kind of behavior (if there's only one cause for these)?
The computer I'm working on has Python (3.8.6) freshly installed, together with pandas
and openpyxl
(via pip install
). The same code on my other computer works perfectly fine (8 rows are skipped, data from columns B:AX is imported correctly, "+" stays "+" in all df.columns
).
question from:
https://stackoverflow.com/questions/65901806/wrong-rows-and-columns-imported-into-a-data-frame-from-excel 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…