Python List of Tuples to DataFrame 🐼

To convert a list of tuples to a Pandas DataFrame, import the pandas library, call the DataFrame constructor, and pass the list of tuples as the data argument such as in pd.DataFrame(tuples_list, columns=[‘Number’, ‘Letter’]). Here’s a minimal example: The output of the given code will be a Pandas DataFrame with two columns, ‘Number’ and ‘Letter’, … Read more

How to Use Python 3.X (3.9, 3.10, or 3.11) as Default for “python3” in Linux?

Ready to embrace the power of Python 3.11 as your default Python3 version? 🐍 Let’s make it happen! Just follow these simple steps: 1️⃣ First, let’s check your current default Python version. Open your terminal and run the following command: python3 –version In my AWS instance, the command python3 pointed to my installed Python version … Read more

Organize Files by Suffix: How I Created a Python Script to Automate a Boring Task

Does the nature of your work involve going through a folder full of dozens, hundreds, or even thousands of files? What if you were told to organize those files according to their extension in a subdirectory, imagine how boring and time-consuming such a task would be if the files contain dozens of extensions! What if … Read more

Dictionary of Lists to DataFrame – Python Conversion

Problem Formulation Working with Python often involves processing complex data structures such as dictionaries and lists. In many instances, it becomes necessary to convert a dictionary of lists into a more convenient and structured format like a Pandas DataFrame 🐼. DataFrames offer numerous benefits, including easier data handling and analysis πŸ”, as well as an … Read more

How I Deployed a Machine Learning Application Using the Flask Webserver

Deployment of Machine Learning models to make them available to end users is the ultimate goal of data scientists. How can you develop a web application if you have little or no knowledge of web development? As data scientists, you can now see that learning Python for web development cannot be overemphasized. There are many … Read more

Python Pickle Module: Simplify Object Persistence [Ultimate Guide]

πŸ₯’ Python pickling is another word for serializing and de-serializing Python objects, so you can store them in a binary format or transmit them across a network. Pickling helps preserving the state of objects, such as data structures or machine learning models, between different sessions or applications. The pickle module in Python’s standard library provides … Read more

Python Regex Capturing Groups – A Helpful Guide (+Video)

Python’s regex capturing groups allow you to extract parts of a string that match a pattern. For example: match = re.search(r'(\d+)’, ‘abc123’) captures the digits, and match.group(1) returns ‘123’. One of the powerful aspects of Python’s regular expression capabilities is the use of capturing groups. By using capturing groups, you can easily extract specific portions … Read more