Home TechnologyCoding How to: Python Automation. 3 Python Projects That Will Help Automate Your Life

How to: Python Automation. 3 Python Projects That Will Help Automate Your Life

Ideas to automate your life with Python.

by Ivan
How to: Python Automation. 3 Python Projects That Will Help Automate Your Life Python Automation - 3 Python Projects That Will Help Automate Your Life.

Python Automation – 3 Python Projects That Will Help Automate Your Life. 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.

1. Automate Excel Reporting

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.

How to solve this project

In Python, we can use openpyxl and Pandas to automate your Excel reporting. 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.

2. Automate Data Visualization

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.

How to solve this project

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.

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 voilà! The graph is created and the code is automatically generated.

3. Web Automation

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.

How to solve this project

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 a Python Selenium tutorial for beginners on YouTube. This will help you create a bot in Selenium that will perform almost any task on a website as if you were controlling it yourself.

You may also like

Leave a Reply

[script_16]