In this tutoriual, we will learn how to convert the row name or row index name in a Pandas dataframe to a column. We will use Pandas’ reset_index() function to convert the index with name to a column. Let us load Pandas. Let us create a small dataframe in Pandas with rown index names. Our […]
Pandas 101
Pandas case_when() with multiple examples
The newest Pandas release Pandas 2.2.0 has one of the most useful functions case_when() available on a Pandas Series object. Often you might want to create a new variable from an existing variable using multiple conditions. For a simple binary condition we can use Pandas’ where() function. With the new case_when() function we can apply […]
Difference between Pandas where() function and mask() function
Pandas mask() and where() functions are two related functions that are useful in Pandas to find if elements of Pandas dataframe satisfy a condition. They both preserve the shape of the dataframe. In this post, we will first see simple examples of using Pandas where() and mask() functions and then we will learn the key […]
How to Find if Pandas Dataframe is empty
In this tutorial, we will learn how to find if a Pandas dataframe is empty or not. Pandas empty method applied to a Pandas dataframe will tell us if the dataframe is empty or not. Pandas’ empty method will return True if the dataframe is empty and False otherwise. Let us see some examples of […]
Pandas create new column using if else condition
In this quick tutorial, we will learn how to create a new column using if else condition on an existing column in a Pandas dataframe. To add new column using a condional on existing column we will use Numpy’s where function. So, let us load both numby and Pandas to get started. We. will use […]