How to Create an Entry Box using Tkinter

In this short guide, you’ll see how to create an entry box using tkinter. More specifically, you’ll observe a simple example with the steps to create: To start, here is the syntax to create the entry box (in the next section, you’ll see the full steps to derive this code, including a more stylish version … Read more

Convert Strings to Floats in Pandas DataFrame

Here are two ways to convert strings to floats in Pandas DataFrame (1) astype(float) Copy df[“DataFrame Column”] = df[“DataFrame Column”].astype(float) (2) apply(float) Copy df[“DataFrame Column”] = df[“DataFrame Column”].apply(float) Scenarios to Convert Strings to Floats in Pandas DataFrame Scenario 1: Numeric values stored as strings To keep things simple, let’s create a DataFrame, where the ‘Price‘ column contains … Read more

Get the Descriptive Statistics for Pandas DataFrame

To get the descriptive statistics for a specific column in your DataFrame: Copy df[‘dataframe_column’].describe() To get the descriptive statistics for an entire DataFrame: Copy df.describe(include=’all’) Steps to Get the Descriptive Statistics for Pandas DataFrame Step 1: Collect the Data To start, you’ll need to collect the data for your DataFrame. For example, here is a … Read more

Plot Histogram in Python using Matplotlib

You may use the following template to plot a histogram in Python using Matplotlib: Copy import matplotlib.pyplot as pltx = [value1, value2, value3,….]plt.hist(x, bins=number of bins)plt.show() Steps to plot a histogram in Python using Matplotlib Step 1: Install the Matplotlib package If you haven’t already done so, install the Matplotlib package using the following command: Copy … Read more

Example of Confusion Matrix in Python

In this short tutorial, you’ll see a full example of a Confusion Matrix in Python. Topics to be reviewed: Creating a Confusion Matrix using pandas Displaying the Confusion Matrix using seaborn Getting additional stats via pandas_ml Working with non-numeric data Creating a Confusion Matrix in Python using Pandas To start, here is the dataset to be … Read more

SQL to Pandas DataFrame

In this guide, you’ll see how to get from SQL to Pandas DataFrame. Steps Step 1: Create a database and table To start, create a database in Python using the sqlite3 package, where: product_id product_name price 1 Computer 800 2 Printer 200 3 Tablet 300 4 Desk 450 5 Chair 150 Here is the complete … Read more

How to Plot a DataFrame using Pandas

In this guide, you’ll see how to plot a DataFrame using Pandas. More specifically, you’ll see the complete steps to plot: Scatter diagram Line chart Bar chart Pie chart Plot a Scatter Diagram using Pandas Scatter plots are used to depict a relationship between two variables. Here are the steps to plot a scatter diagram … Read more

How to Union Pandas DataFrames using Concat

You can union Pandas DataFrames using concat: Copy pd.concat([df1, df2]) You may concatenate additional DataFrames by adding them within the brackets. Steps to Union Pandas DataFrames using Concat Step 1: Create the first DataFrame For example, let’s say that you have the following DataFrame about products: Copy import pandas as pd data1 = { “product”: … Read more

How to Select Rows from Pandas DataFrame

In this short guide, you’ll see the steps to select rows from Pandas DataFrame based on the conditions specified. Steps to Select Rows from Pandas DataFrame Step 1: Gather your data Firstly, you’ll need to gather your data. Here is an example of a data gathered about boxes: Color Shape Price Green Rectangle 10 Green … Read more

Example of K-Means Clustering in Python

K-Means Clustering is a concept that falls under Unsupervised Learning. This algorithm can be used to find groups within unlabeled data. To demonstrate this concept, we’ll review a simple example of K-Means Clustering in Python. Topics to be covered: Creating a DataFrame for two-dimensional dataset Finding the centroids of 3 clusters, and then of 4 clusters … Read more