3 Python Projects That Will Help Automate Your Life | by Frank Andrade | Towards Data Science

Most jobs have some tasks that add little value to our profession. Doing such tasks once isn’t a big deal, but when they become repetitive and time-consuming, they have to be automated.
By automating tasks you will stop wasting time doing mundane tasks and focus on what matters most for you. On top of that, you will put into practice all your knowledge in Python and even learn new things.
In this guide, I will show you 3 Python projects that helped me automate some of my everyday tasks at work and hopefully will help you too.
Think of all the things you have to do to make an Excel reporting — you use Excel formulas, create a pivot table, make a chart, and format the worksheet.
Doing it once is easy, but things get complicated when you have to do it lots of times. Fortunately, Python can help you automate these tasks, so you’ll only need a couple of clicks the next time you have to make an Excel reporting.
In Python, we can use openpyxl and Pandas to automate your Excel reporting. Here’s a guide I made to automate your Excel reporting with Python. Both are great Python libraries, but the downside is that it might take some time for beginners to learn openpyxl and it doesn’t have applications beyond Excel.
There’s an easier approach to automate your Excel reporting though. You only need to install a Python library named mitosheet (aka Mito). This library allows us to group data and calculate summary stats using an intuitive Excel-like interface. The best part is that Mito generates the code for each edit, so we’ll be able to see the Python code that corresponds to each edit.
In the example below, you can see how I used mitosheet’s interface to create a pivot table. After making the pivot table, the code is automatically created, isn’t that great?
To automate pivot tables and more Excel tasks you need to install the mitosheet library. To install it, first, open a new terminal or command prompt and then download the Mito installer with the following command:
python -m pip install mitoinstaller
Then, run the installer (this command may take a few moments to run)
python -m mitoinstaller install
That’s it! Check this link to learn how to create your first pivot table with mitosheet.
Most data analysis projects end with a presentation that contains lots of graphs. In my previous jobs, I’d update my Excel reporting and then manually make visualizations such as bar plots, piecharts, boxplots, and more.
This was time-consuming tough, so I looked for an alternative in Python. I found a couple of libraries that could help me automate plotting visualizations. I only had to read my updated Excel reporting with Python and by running a script all the visualizations would be created.
To automate data visualization, first, we need to write code that creates the graph we want (preferably in a Jupiter Notebook file). Then write down how the input data (Excel file) should look like, so you make sure the column names, the shape of the data, data type, and other important features remain the same in the next update.
Now you might be wondering “how can I make visualizations with Python?” Well, Python offers different options to make standard as well as interactive visualizations. Here’s a guide to making visualizations with Matplotlib/Seaborn and here’s another guide to making interactive visualizations with Pandas/Plotly.
That said, learning such libraries might take you a good number of hours. Here Mito can help too. You can use Mito to make data visualization with a couple of clicks while generating the corresponding Python code. This code can be used to automate the creation of data visualization for future data.
Let’s have a look at how it works.
In the gif above, I’m using the mitosheet library to create a barplot of a Netflix dataset with a couple of clicks. I only need to select a column, click on the graph button, and voilà! The graph is created and the code is automatically generated.
One of the boring tasks I had to do as a junior data analyst was to upload files to a client’s website on a daily basis. The steps were quite simple: Go to website “X,” click on this button, select an option from a dropdown and click on upload.
Doing this could take 2 minutes or so, but I had to repeat these steps hundreds of times during the week. This is why I decided to automate this task with Selenium. This is a tool for controlling web browsers like Chrome through Python.
To automate any website with Python, first think of all the steps you would normally follow to do a task on a website. Your task might involve clicking on buttons, selecting elements within dropdowns, introducing text, scrolling up/down, logging in to pages, etc.
Once all the tasks are enumerated, replicate all the steps in Python using Selenium. Below is my Python Selenium tutorial for beginners on YouTube and here’s a Selenium guide in Python. Both will help you create a bot in Selenium that will perform almost any task on a website as if you were controlling it yourself.
Bonus: If you reach this point, it means that you’re into automation, here are 4 more automation projects you can with Python, and here are other 4 projects you can do even without writing a single line of code.
medium.datadriveninvestor.com
Join my email list with 3k+ people to get my Python for Data Science Cheat Sheet I use in all my tutorials (Free PDF)
If you enjoy reading stories like these and want to support me as a writer, consider signing up to become a Medium member. It’s $5 a month, giving you unlimited access to thousands of Python guides and Data science articles. If you sign up using my link, I’ll earn a small commission with no extra cost to you.