Practical Business Python

Taking care of business, one python script at a time

Mon 14 September 2015

Adding a Simple GUI to Your Pandas Script

Posted by Chris Moffitt in articles   

Using python and pandas in the business world can be a very useful alternative to the pain of manipulating Excel files. While this combination of technologies is powerful, it can be challenging to convince others to use a python script - especially when many may be intimidated by using the command line. In this article I will show an example of how to easily create an end-user-friendly GUI using the Gooey library. This interface is based on wxWindows so it looks like a “native” application on Windows, Mac and Linux. Ultimately, I believe that presenting a simple user interface to your scripts can greatly increase the adoption of python in your place of business.

Read more...



Mon 13 July 2015

Best Practices for Managing Your Code Library

Posted by Chris Moffitt in articles   

Over time you have probably developed a set of python scripts that you use on a frequent basis to make your daily work more effective. However, as you start to collect a bunch of python files, the time you take take to manage them can increase greatly. Your once simple development environment can become an unmanageable mess; especially if you do not try to have some consistency and common patterns for your development process. This article will discuss some best practices to manage your python code base so that you can sustain and maintain it over the years without pulling your hair out in the process.

Read more...



Tue 09 June 2015

Collecting Data with Google Forms and Pandas

Posted by Chris Moffitt in articles   

Google Forms is a service that allows you to collect information via simple web forms. One of the useful features is that the forms will automatically save your data to a Google Sheet. This article will walk through how to create a form, authenticate using OAuth 2 and read all the responses into a pandas dataframe. Because the initial setup and authentication process is a little time consuming, this article will be the first in a two part series.

Read more...


Sun 17 May 2015

Notebooks Now on Github and Other Updates

Posted by Chris Moffitt in articles   

In case you missed it, github recently announced that Jupyter notebooks will be natively rendered by github. This useful new feature will make it easier for followers of pbpython to view notebooks through github as well as download them to your local system and follow along.

I have moved over 4 notebooks to github and set up the associated files so that it should be pretty straightforward for anyone to checkout the pbpython repo and work with the notebooks. This will also make it easier for others to follow along and help spot issues and make this collection of tips and tricks even more robust.

This post also contains a couple of helpful links I wanted to pass on and keep record of because I think they are really useful.

Read more...



Wed 08 April 2015

Improving Pandas 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 16 February 2015

Creating PDF Reports with Pandas, Jinja and WeasyPrint

Posted by Chris Moffitt in articles   

Pandas is excellent at manipulating large amounts of data and summarizing it in multiple text and visual representations. Without much effort, pandas supports output to CSV, Excel, HTML, json and more. Where things get more difficult is if you want to combine multiple pieces of data into one document. For example, if you want to put two DataFrames on one Excel sheet, you need to use the Excel libraries to manually construct your output. It is certainly possible but not simple. This article will describe one method to combine multiple pieces of information into an HTML template and convert it to a standalone PDF document using Jinja templates and WeasyPrint.

Read more...