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
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 Save Sparse Matrix in Python to Mtx and Npz file
Sparse matrices in Python are of great of use when you work with dataset that are of high dimensional and sparse. Python’s Scipy has a set of tools to work with different types of commonly used sparse matrices. In this post, we will learn how to save a sparse matrix in Mtx format and npz […]
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 […]