How to use the Pandas map() function

The Pandas map() function can be used to map the values of a series to another set of values or run a custom function. It runs at the series level,...

How to use Pandas pipe() to create data pipelines

The Pandas pipe() function takes a dataframe as its input, transforms or manipulates it, and returns the transformed dataframe. It is a very useful function that can be used to...

How to use Pandas assign() to create new dataframe columns

The Pandas assign() function is used to create new columns in a dataframe, usually based on calculations. The assign() function takes the name of the new column to create along...

How to measure Python code execution times with timeit

If you’re writing Python code in a Jupyter notebook that is eventually going to be used in production, it’s sensible to consider how long it takes to run. This is...

How to use Pandas show_versions() to view package versions

The Pandas library is under constant development and new features are added regularly. This means that code you may read about online may not work if you are running an...

How to use Pandas from_dict() to create a dataframe

The Pandas library is so versatile that it provides several ways to create a dataframe. One of the most commonly used is the from_dict() method, which allows you to create...

How to use method chaining in Pandas

Pandas method chaining, or flow programming, is a modern, but sometimes controversial way of structuring Pandas code into a structured chain or series of commands. Conceptually, Pandas chaining is a...

How to round values in Pandas using round()

When working with numeric data in Pandas you’ll often need to round numbers to the nearest whole number, round them up, round them down, or round them to two decimal...

How to transpose a Pandas dataframe using T and transpose()

When working with Pandas dataframes that contain many columns, or those containing very large amounts of content, it is often useful to display the dataframe by flipping its orientation through...