## How to Create a Correlation Matrix using Pandas

In this short guide, I’ll show you how to create a Correlation Matrix using Pandas. I’ll also review the steps to display the matrix using Seaborn. To start, here is a template that you can apply in order to create a correlation matrix using pandas: df.corr() Next, I’ll show you an example with the steps …

## How to Create a Pie Chart using Matplotlib

Need to create a pie chart using matplotlib? If so, you can use the following template to create your pie chart: import matplotlib.pyplot as plt my_data = [value1,value2,value3,…] my_labels = ‘label1′,’label2′,’label3′,… plt.pie(my_data,labels=my_labels,autopct=’%1.1f%%’) plt.title(‘My Title’) plt.axis(‘equal’) plt.show() Next, I’ll review an example with the steps to create different types of pie charts. Steps to Create a …

## How to Convert Integers to Floats in Pandas DataFrame

In this short guide, I’ll review two methods to convert integers to floats in Pandas DataFrame: (1) The astype(float) method: df[‘DataFrame Column’] = df[‘DataFrame Column’].astype(float) (2) The to_numeric method: df[‘DataFrame Column’] = pd.to_numeric(df[‘DataFrame Column’], downcast=’float’) In the next section, I’ll review an example with the steps to apply the above two methods in practice. Steps …

## Convert CSV to Excel using Python (tool included)

In this quick guide, I’ll show you how to convert a CSV to Excel using Python. I’ll also include the Python code for a tool that can facilitate the conversion: To start, here is a template that you can use to convert a CSV to Excel using Python: import pandas as pd read_file = pd.read_csv …

## How to Take a Screenshot using Python

You may use the following template to take a screenshot using Python: import pyautogui myScreenshot = pyautogui.screenshot() myScreenshot.save(r’Path to save screenshot\file name.png’) Next, I’ll show you the full steps to take a screenshot using Python. I’ll also include the code to create a GUI to take screenshots: Steps to Take a Screenshot using Python Step …

## Pandas DataFrame to SQL (with examples)

In this guide, I’ll show you how to get from Pandas DataFrame to SQL. Here are the steps that you may follow. Steps to get from Pandas DataFrame to SQL Step 1: Create a DataFrame To start, let’s create a DataFrame based on the following data about cars: Brand Price Honda Civic 22000 Toyota Corolla …

## How to List all txt Files in a Directory using Python

Need to list all txt files in a directory using Python? If so, you may use the following templates to list your files: List all the txt files in a directory: import glob import os os.chdir(r’directory where the files are located’) myFiles = glob.glob(‘*.txt’) print(myFiles) List the paths of the txt files: import glob myFilesPaths …

## How to Rename a File using Python (with examples)

You may use the following template to rename a file using Python: import os os.rename(r’file path\OLD file name.file type’,r’file path\NEW file name.file type’) Let’s now review an example with the steps to rename a file using Python. Steps to Rename a File using Python Suppose that your goal is to rename a text file from …

## How to Drop Rows with NaN Values in Pandas DataFrame

In this short guide, I’ll show you how to drop rows with NaN values in Pandas DataFrame. To start, here is the syntax that you may apply in order drop rows with NaN values in your DataFrame: df.dropna() In the next section, I’ll review the steps to apply the above syntax in practice. Steps to …

## How to Append an Item to a List in Python

Need to append an item to a list in Python? If so, you may use the following template to append your item to the end of a list: ListName.append(new item to be added) Let’s now see how to apply this template in practice. Steps to Append an Item to a List in Python Step 1: …