Python Data Structures Articles

Sorted By: Most Recent
Giorgos Myrianthous Giorgos Myrianthous
Updated on April 14, 2025

How to Convert a Dictionary to a Pandas DataFrame

Learn how to convert a Python dictionary into a Pandas DataFrame using the pd.DataFrame.from_dict() method and its options, depending on how the data is structured and stored in the dictionary.

Image: Shutterstock / Built In
Artturi Jalli Artturi Jalli
Updated on April 11, 2025

An Introduction to the With Statement in Python

The with statement in Python wraps the execution of a code block using the methods defined by a context manager. It's often used to replace a try-finally block with more concise code. Here's how and when to use the with statement in Python.

Image: Shutterstock / Built In
Dhananjay Patel Dhananjay Patel
Updated on April 09, 2025

A Complete Guide to Stacks in Python

A stack in Python is an abstract data type that stores the order in which items were added to the structure but only allows additions/deletions to the top of the stack.

Image: Shutterstock / Built In
Anthony Corbo Anthony Corbo
Updated on April 03, 2025

What Are Python Algorithms?

A Python algorithm is a series of step-by-step instructions used to solve a problem or complete a calculation. Take a look at some of the main types of algorithms used in Python and how to write algorithms in Python.

Image: Shutterstock / Built In
Anmol Tomar Anmol Tomar
Updated on March 14, 2025

Elbow Method in K-Means Clustering: Definition, Drawbacks, vs. Silhouette Score

The elbow method is a technique used to find the optimal number of clusters (K) in k-means clustering, by identifying the “elbow” point on a graph of k-values and their corresponding within-cluster sum of squares (WCSS) values.

Image: Shutterstock / Built In
Anthony Corbo Anthony Corbo
Updated on March 05, 2025

What Are Python Data Structures?

Python data structures are formats for organizing and storing different kinds of data in Python. The four main types of built-in Python data structures are lists, tuples, sets and dictionaries.

Image: Shutterstock / Built In
Dario Radečić Dario Radečić
Updated on February 18, 2025

3 Ways to Convert a NumPy Array to Pandas DataFrame

A NumPy array can be converted to a Pandas DataFrame through a variety of methods, including passing a NumPy array to pd.DataFrame and using the from_records() method. Learn more.

Image: Shutterstock / Built In
Sara A. Metwalli Sara A. Metwalli
Updated on January 30, 2025

13 Python Snippets You Need to Know

Optimize your workflow with these everyday Python snippets.

Bisola Olasehinde Bisola Olasehinde
Updated on December 18, 2024

How to Insert a Python Variable in a String

There are four common methods that will allow you to add Python variables in a string, including: the comma, the modulus operator, string format and f-strings. Here’s how they work.

Image: Shutterstock / Built In
Dario Radečić Dario Radečić
Updated on December 12, 2024

Python Set Difference: A Complete Guide

Python set difference is a function that returns the elements of the first set that aren’t found in the second set. Here’s how it works with code.

Image: Shutterstock / Built In