ENH: make read_excel dtype parameter compatible with multiple sheets (e.g sheet_name =[0,"list_of_sheets"]) #55030
Labels
Enhancement
IO Excel
read_excel, to_excel
Needs Triage
Issue that has not been reviewed by a pandas team member
Feature Type
Adding new functionality to pandas
Changing existing functionality in pandas
Removing existing functionality in pandas
Problem Description
I would like the dtype parameter to be compatible with opening multiple sheets.
Feature Description
when a list of sheets is passed, dtype could be a dictionary with {elem_on_list: usual_dtype_parameter}
so if
sheet_name = [0,'Sheet3']
dtype could be
dtype={0:{'colA':str, 'colB': 'float64'}, 'Sheet3':{'colA':'datetime64[ns]', 'colB': str}
Alternative Solutions
Iterate yourself and create the dictionary yourself with
Additional Context
In my case, pandas automatic decision of what the object is, doesn't work well in my scenarios. It always assumes numbers, even if the column has explicitly been marked as "text" in Excel, so I need to specify dtypes.
This would make my life easier, and would make sense that the multiple sheet name functionality is compatible with also giving multiple dtype arguments per sheet. I haven't tested if just adding all the columns at the dictionary would work, regardless of the Sheet, but it's very obvious that one can have the same column name in two sheets, and that one might want different datatypes there. And given that I plan to use something like this for automation purposes, I can't just assume same column name will always be the same type.
The text was updated successfully, but these errors were encountered: