Sometimes you would like to collapse least frequent values of a factor or character variable in to a new category “Other”. In R forcats library has a suit of functions for lumping the variables. This post contains a Pandas solution that can lump factors or values in three common ways. First, we will see how […]
Python
Barplots and Countplot with Seaborn’s catplot
Love it or hate it, barplots are often useful in a quick exploratory data analysis to understand the variables in a dataset. In this post, we will see multiple examples on how to make barplots/countplot using Seaborn’s catplot() function. A couple of years ago Seaborn introduced catplot() function that provides a common framework to make […]
Python Built-in Datasets
Scikit-learn, a machine learning toolkit in Python, offers a number of datasets ready to use for learning ML and developing new methodologies. If you are new to sklearn, it may be little harder to wrap your head around knowing the available datasets, what information is available as part of the dataset and how to access […]
How to Change the Order of Columns in a Pandas Dataframe
In this tutorial, we will learn how to change the order of columns in Pandas dataframe. We can change the order of the columns in multiple. Here, we will see two ways to change the order of the columns. First, let us load Pandas. import pandas as pd We will use gapminder dataset to change […]
How to Change the Position of Legend in Seaborn
Seaborn v0.11.2 is here. It is a minor release that fixes issues and also has a few features. One of the useful features is the new convenient function “move_legend()” to change the position of legend in Seaborn. Before Seaborn v0.11.2, Matplotlib’s plt.legend() has been the go to function to change the position of legend in […]