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 […]
Python Tips
How To Convert Pandas Dataframe to a Dictionary
In this tutorial, we will learn how to convert two columns from dataframe into a dictionary. As the picture below shows the goal is to use one of the column values as keys to dictionary and the second column values as values. Note that this is different from creating a dictionary with column name as […]
How to Replace Multiple Column Values with Dictionary in Python
Sometimes you might like to change the content of Pandas dataframe, values in one or more columns (not the names of the columns) with some specific values. Pandas’ replace() function is a versatile function to replace the content of a Pandas data frame. First, we will see how to replace multiple column values in a […]
How to Convert a NumPy Array to Pandas Dataframe
NumPy and Pandas are two most useful python toolkits for data analysis. Sometimes you might want to convert a 2d-array in numpy to a dataframe. In this short tutorial, we will learn how to convert a numpy array into Pandas dataframe. Let us first create some numpy array. We will use NumPy’s random module to […]
Gaussian Mixture Models with Scikit-learn in Python
In simpler statistical models, we typically assume our data came from a single distribution. For example, to model height, we can assume that each observation came from a single Gaussian distribution with some mean and variance. However, often we might be in a scenario where that assumption is not valid and our data is more […]