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… Continue reading Difference between Pandas where() function and mask() function

6 Tips to change column positions with dplyr’s relocate()

Sometimes you want to change the order of columns in a dataframe. dpyr’s relocate() function makes it easy to move one or more columns to new positions easily by using the same syntax as select() function. In this post we will see 7 tips to change column order or column position using dplyr’s relocate(). Let… Continue reading 6 Tips to change column positions with dplyr’s relocate()

3 Different ways to add regression line in ggplot2

Add regression line to scatterplot using geom_line()

In this post, we will learn how to add simple regression line in three different ways to a scatter plot made with ggplot2 in R. This is something I have to google almost every time, so here is the post recording the options to add linear regression line. We will use palmer penguin data to… Continue reading 3 Different ways to add regression line in ggplot2

Pandas map: Change Multiple Column Values with a Dictionary

Pandas Change Multiple Columns Values with map

In this tutorial, we will learn how to use Pandas map() function to replace multiple column values using a dictionary. Earlier, we saw how to use Pandas replace() function to change the values in multiple columns using dictionary. As we all know, there are multiple solutions to a problem. Pandas map() function works with Pandas… Continue reading Pandas map: Change Multiple Column Values with a Dictionary