Practical Business Python

Taking care of business, one python script at a time

Mon 07 December 2015

Creating Advanced Excel Workbooks with Python

Posted by Chris Moffitt in articles   

I have written several articles about using python and pandas to manipulate data and create useful Excel output. In my experience, no matter how strong the python tools are, there are times when you need to rely on Excel as the vehicle to communicate your message or further analyze the data. This article will walk through some additional improvements you can make to your Excel-based output by:

  • Adding Excel tables with XlsxWriter

  • Inserting custom VBA into your Excel file

  • Using COM for merging multiple Excel worksheets

Read more...


Wed 08 April 2015

Improving Pandas’s Excel Output

Posted by Chris Moffitt in articles   

Pandas makes it very easy to output a DataFrame to Excel. However, there are limited options for customizing the output and using Excel’s features to make your output as useful as it could be. Fortunately, it is easy to use the excellent XlsxWriter module to customize and enhance the Excel workbooks created by Panda’s to_excel function. This article will describe how to use XlsxWriter and Pandas to make complex, visually appealing and useful Excel workbooks. As an added bonus, the article will briefly discuss the use of the new assign function that has been introduced in pandas 0.16.0.

Read more...


Mon 02 February 2015

Generating Excel Reports from a Pandas Pivot Table

Posted by Chris Moffitt in articles   

The previous pivot table article described how to use the pandas pivot_table function to combine and present data in an easy to view manner. This concept is probably familiar to anyone that has used pivot tables in Excel. However, pandas has the capability to easily take a cross section of the data and manipulate it. This cross section capability makes a pandas pivot table really useful for generating custom reports. This article will give a short example of how to manipulate the data in a pivot table to create a custom Excel report with a subset of pivot table data.

Read more...


Mon 29 December 2014

Pandas Pivot Table Explained

Posted by Chris Moffitt in articles   

Most people likely have experience with pivot tables in Excel. Pandas provides a similar function called (appropriately enough) pivot_table. While it is exceedingly useful, I frequently find myself struggling to remember how to use the syntax to format the output for my needs. This article will focus on explaining the pandas pivot_table function and how to use it for your data analysis.

Read more...


Wed 17 December 2014

Combining Data From Multiple Excel Files

Posted by Chris Moffitt in articles   

A very common tasks for python and pandas is to automate the process of aggregating data from multiple files and spreadsheets.

This article will walk through the basic flow required to parse multiple Excel files, combine the data, clean it up and analyze it. The combination of python + pandas can be extremely powerful for these activities and can be a very useful alternative to the manual processes or painful VBA scripts frequently used in business settings today.

Read more...