Excel files are widely used files in the business domain. Excel files can be easily read in Python's pandas using the read_excel() function. The read_excel() function takes a file path and sheet_name parameters to read the data:
# Read excel file
df=pd.read_excel('employee.xlsx',sheet_name='performance')
# display initial 5 records
df.head()
This results in the following output:
DataFrame objects can be written on Excel sheets. We can use the to_excel() function to export DataFrame objects into an Excel sheet. Mostly, the to_excel() function arguments are the same as to_csv() except for the sheet_name argument:
df.to_excel('employee_performance.xlsx')
In the preceding code example, we have exported a single DataFrame into an Excel sheet. We can also export multiple DataFrames in a single file with different sheet names. We can also write more than one DataFrame in a single Excel file (each DataFrame on different sheets...