Research

  • [X] I have searched the [pandas] tag on StackOverflow for similar questions.

  • [X] I have asked my usage related question on StackOverflow.

Link to question on StackOverflow

https://stackoverflow.com/questions/75686468/typeerror-read-excel-got-an-unexpected-keyword-argument-headers-using-panda

Question about pandas

I am trying to combine excel spreadsheets using python, and the code i used a few months ago was working fine. However now i am getting an error Traceback (most recent call last): File "P:\2018\218143\GIS\Working_HBK_ASE_Project\SUE_QLData\Python\SUEGISPrep.py", line 15, in data_xlsA1 = pd.read_excel(r'\chicagostorage2017\public\2018\218143 - ISTHA SUE\05 - GIS\05.09 - GIS Source Data\LG_ASE_TAS_4296_LookAheadSchedule.xlsx', 'Schedule and QLA Results', headers= 1, skiprows= skprws, index_col=None, dtype=datatype,converters=conversions) File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\pandas\util_decorators.py", line 299, in wrapper return func(args, *kwargs) TypeError: read_excel() got an unexpected keyword argument 'headers'

I did not write this code and am not very good at programing and was wondering if someone could help me overcome this issue. here is the code I am having an issue with.

import pandas as pd

skprws = range(0, 3)
datatype = {"Task\nOrder": str,"Contract \nRequest\nNumber": str, "Actual \nNorthing": float, "Actual \nEasting": float, "Proposed Northing": float, "Proposed Easting": float, "Ground Elevation": float, "Top of Utility": float, "Depth": float, "Rim Elevation": float, "Depth (1)": float, "Invert (1)": float, "Depth (2)": float, "Invert (2)": float, "Depth (3)": float, "Invert (3)": float, "Depth (4)": float, "Invert (4)": float, "Depth (5)": float, "Invert (5)": float, "MP \nStart": float, "MP \nEnd": float}
conversions= {"Request #": int, "Priority": int, "SUE Contract Number": int, "Request Contract\nNumber": int, "FWAR\nNumber": int}
data_xlsA1 = pd.read_excel(r'\\chicagostorage2017\public\2018\218143 - ISTHA SUE\05 - GIS\05.09 - GIS Source Data\LG_ASE_TAS_4296_LookAheadSchedule.xlsx', 'Schedule and QLA Results', headers= 1, skiprows= skprws, index_col=None, dtype=datatype,converters=conversions)
data_xlsA2 = pd.read_excel(r'\\chicagostorage2017\public\2018\218143 - ISTHA SUE\05 - GIS\05.09 - GIS Source Data\LG_ASE_TAS_4297_LookAheadSchedule.xlsx', 'Schedule and QLA Results', headers= 1, skiprows= skprws, index_col=None, dtype=datatype,converters=conversions)
data_xlsA3 = pd.read_excel(r'\\chicagostorage2017\public\2018\218143 - ISTHA SUE\05 - GIS\05.09 - GIS Source Data\LG_ASE_TAS_4415_LookAheadSchedule.xlsx', 'Schedule and QLA Results', headers= 1, skiprows= skprws, index_col=None, dtype=datatype,converters=conversions)
data_xlsA4 = pd.read_excel(r'\\chicagostorage2017\public\2018\218143 - ISTHA SUE\05 - GIS\05.09 - GIS Source Data\LG_ASE_TAS_4700_LookAheadSchedule.xlsx', 'Schedule and QLA Results', headers= 1, skiprows= skprws, index_col=None, dtype=datatype,converters=conversions)
data_xlsA5 = pd.read_excel(r'\\chicagostorage2017\public\2018\218143 - ISTHA SUE\05 - GIS\05.09 - GIS Source Data\MM Formatted-LG_HBK_ARD_4570_LookAheadSchedule_02242023.xlsx', 'Schedule and QLA Results', headers= 1, skiprows= skprws, index_col=None, dtype=datatype,converters=conversions)
data_xlsB1 = pd.read_excel(r'\\chicagostorage2017\public\2018\218143 - ISTHA SUE\05 - GIS\05.09 - GIS Source Data\LG_ASE_TAS_4296_LookAheadSchedule.xlsx', 'QLB Results', headers= 1, skiprows= skprws, index_col=None, dtype=datatype,converters=conversions)
data_xlsB2 = pd.read_excel(r'\\chicagostorage2017\public\2018\218143 - ISTHA SUE\05 - GIS\05.09 - GIS Source Data\LG_ASE_TAS_4297_LookAheadSchedule.xlsx', 'QLB Results', headers= 1, skiprows= skprws, index_col=None, dtype=datatype,converters=conversions)
data_xlsB3 = pd.read_excel(r'\\chicagostorage2017\public\2018\218143 - ISTHA SUE\05 - GIS\05.09 - GIS Source Data\LG_ASE_TAS_4415_LookAheadSchedule.xlsx', 'QLB Results', headers= 1, skiprows= skprws, index_col=None, dtype=datatype,converters=conversions)
data_xlsB4 = pd.read_excel(r'\\chicagostorage2017\public\2018\218143 - ISTHA SUE\05 - GIS\05.09 - GIS Source Data\LG_ASE_TAS_4700_LookAheadSchedule.xlsx', 'QLB Results', headers= 1, skiprows= skprws, index_col=None, dtype=datatype,converters=conversions)
data_xlsB5 = pd.read_excel(r'\\chicagostorage2017\public\2018\218143 - ISTHA SUE\05 - GIS\05.09 - GIS Source Data\MM Formatted-LG_HBK_ARD_4570_LookAheadSchedule_02242023.xlsx', 'QLB Results', headers= 1, skiprows= skprws, index_col=None, dtype=datatype,converters=conversions)
data_xlsC1 = pd.read_excel(r'\\chicagostorage2017\public\2018\218143 - ISTHA SUE\05 - GIS\05.09 - GIS Source Data\LG_ASE_TAS_4296_LookAheadSchedule.xlsx', 'QLC Results', headers= 1, skiprows= skprws, index_col=None, dtype=datatype,converters=conversions)
data_xlsC2 = pd.read_excel(r'\\chicagostorage2017\public\2018\218143 - ISTHA SUE\05 - GIS\05.09 - GIS Source Data\LG_ASE_TAS_4297_LookAheadSchedule.xlsx', 'QLC Results', headers= 1, skiprows= skprws, index_col=None, dtype=datatype,converters=conversions)
data_xlsC3 = pd.read_excel(r'\\chicagostorage2017\public\2018\218143 - ISTHA SUE\05 - GIS\05.09 - GIS Source Data\LG_ASE_TAS_4415_LookAheadSchedule.xlsx', 'QLC Results', headers= 1, skiprows= skprws, index_col=None, dtype=datatype,converters=conversions)
data_xlsC4 = pd.read_excel(r'\\chicagostorage2017\public\2018\218143 - ISTHA SUE\05 - GIS\05.09 - GIS Source Data\LG_ASE_TAS_4700_LookAheadSchedule.xlsx', 'QLC Results', headers= 1, skiprows= skprws, index_col=None, dtype=datatype,converters=conversions)
data_xlsC5 = pd.read_excel(r'\\chicagostorage2017\public\2018\218143 - ISTHA SUE\05 - GIS\05.09 - GIS Source Data\MM Formatted-LG_HBK_ARD_4570_LookAheadSchedule_02242023.xlsx', 'QLC Results', headers= 1, skiprows= skprws, index_col=None, dtype=datatype,converters=conversions)

dfA = pd.concat([data_xlsA1, data_xlsA2, data_xlsA3, data_xlsA4, data_xlsA5])
dfB = pd.concat([data_xlsB1, data_xlsB2, data_xlsB3, data_xlsB4, data_xlsB5])
dfC = pd.concat([data_xlsC1, data_xlsC2, data_xlsC3, data_xlsC4, data_xlsC5])

dfA.to_excel(r'P:\2018\218143\GIS\Data\TBL\Excel_In\LG_ASE_TAS_Combined_QLA_LookAhead.xlsx', encoding= 'utf-8', index=False)
dfB.to_excel(r'P:\2018\218143\GIS\Data\TBL\Excel_In\LG_ASE_TAS_Combined_QLB.xlsx', encoding= 'utf-8', index=False)
dfC.to_excel(r'P:\2018\218143\GIS\Data\TBL\Excel_In\LG_ASE_TAS_Combined_QLC.xlsx', encoding= 'utf-8', index=False)

print("Files Constructed")

Comment From: phofl

Hi, thanks for your report. the keyword you are looking for is header, not headers.