Reading and writing Excel files
We all know that Excel is one of the most popular data analysis tools out there. It still is the one that most of us are familiar with. Being able to work with Excel in Polars is essential for data analysts. In this recipe, we’ll go through reading and writing Excel files, as well as utilizing some of their useful parameters.
Getting ready
This recipe requires a few Python libraries on top of Polars. You can install it with the following command:
>>> pip install xlsx2csv xlsxwriter
How to do it...
We’ll cover how to read and write Excel files using the following steps:
- Let’s first read a CSV file into a DataFrame and write it to an Excel file:
output_file_path = '../data/output/financial_sample_output.xlsx' df = pl.read_csv('../data/customer_shopping_data.csv') df.write_excel( output_file_path, worksheet='Output Sheet1', &...