Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
98 views
in Technique[技术] by (71.8m points)

python - Wrong rows and columns imported into a data frame from Excel

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...