-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
QST: FutureWarning: Defining usecols with out of bounds indices is deprecated and will raise a ParserError in a future version. #48127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I don’t really understand your problem/question. Do you have a problem with the warning itself or are you confused why it shows up with your data? if you define Usecols with higher indices than your file has columns, then this warning is raised |
@phofl my issue is actually both. First, I do not understand why the warning at all as my "usecols" as I have not defined Usecols with higher indices than my file has columns. And second, I am not sure why id shows up with my data. If I call the function, read_files - and hard code the file name/path individually, and give it the second parameter list " like this: I have shared an excerpt of my code on the Stackoverflow link prior to being provided, but please let me know if you need me to share it here as well. |
Hm, can you check if we inadvertently modify usecols? I don't think so, but does not hurt to be sure. Just print your usecols argument after every call. Can you create a simple reproducer for us to debug? |
@phofl certainly, I can create a simple reproducer code here for review. |
@phofl kindly see below.
|
Your code is buggy, you are trying to read ex_10 with 12 usecols |
@phofl thanks for the feedback, but |
It runs into both if blocks. Just use a debugger and step through |
Got it! |
I've same issue heres with pandas==2.0.2 when I try hanlde all sheets with on function. My excel workbook has 3 sheets: I use pd.read_excel(file, sheet_name=v_sheets, usecols="A:M",...) to process the 3 sheets together, with the latest pandas lib, it raise error now for sheet3: pandas.errors.ParserError: Defining usecols without of bounds indices is not allowed. [4, 5, 6, 7, 8, 9, 10, 11, 12] are out of bounds. (sheet: 3) with previous version of pandas, this is just a warning and the code can run successfully. but now the same code crash. I feel this changes make more CONS than PROS |
Research
I have searched the [pandas] tag on StackOverflow for similar questions.
I have asked my usage related question on StackOverflow.
Link to question on StackOverflow
https://stackoverflow.com/questions/73263189/pandas-excel-data-read-with-incorrect-output-no-getting-all-the-tabular-data-fr?noredirect=1#comment129454561_73263189
Question about pandas
I have a similar issue in this conversation where I have a function - "read_files()" - which takes 2 arguments (a file_name & a list). I then traverse my project directory using a "For loop" to fetch the target files and feed them to the "read_files()" function. But I am constantly getting this error:
FutureWarning: Defining usecols with out of bounds indices is deprecated and will raise a ParserError in a future version.
I have posted an excerpt of my code StackOverflow with the same data file at - https://stackoverflow.com/questions/73263189/pandas-excel-data-read-with-incorrect-output-no-getting-all-the-tabular-data-fr?noredirect=1#comment129454561_73263189. However, I have not gotten any workable solution thus far. I have even tried the suggestion by @ghost from March 2019 at - #25623 - but I still can't get my code to work.
I, therefore, welcome any further ideas/suggestions from this forum on what I may be missing.
The text was updated successfully, but these errors were encountered: