3 Ways to Add New Columns to Pandas Dataframe?

While doing data wrangling or data manipulation, often one may want to add a new column or variable to an existing Pandas dataframe without changing anything else. Obviously the new column will have have the same number of elements. Let us see examples of three ways to add new columns to a Pandas data frame.… Continue reading 3 Ways to Add New Columns to Pandas Dataframe?

How to Collapse Multiple Columns in Pandas? Groupby with Dictionary

Often you may want to collapse two or multiple columns in a Pandas data frame into one column. For example, you may have a data frame with data for each year as columns and you might want to get a new column which summarizes multiple columns. One may need to have flexibility of collapsing columns… Continue reading How to Collapse Multiple Columns in Pandas? Groupby with Dictionary

How To Split A Column or Column Names in Pandas and Get Part of it?

Often you may want to create a new variable either from column names of a pandas data frame or from one of the columns of the data frame. Just like Python, Pandas has great string manipulation abilities that lets you manipulate strings easily. Let us see an example of using Pandas to manipulate column names… Continue reading How To Split A Column or Column Names in Pandas and Get Part of it?

How to Get Unique Values from a Column in Pandas Data Frame?

In this tutorial, we will learn how to get unique values of a column in a Pandas dataframe using two approaches. We will first use Pandas unique() function to get unique values of a column and then use Pandas drop_duplicates() function to get unique values of a column. Pandas unique() function To Get Unique values… Continue reading How to Get Unique Values from a Column in Pandas Data Frame?

How To Add a New Column Using a Dictionary in Pandas Data Frame ?

Creating a new column to a dataframe is a common task in doing data analysis. And this task often comes in a variety of forms. Earlier we saw how to add a column using an existing columns in two ways. In this post we will learn how to add a new column using a dictionary… Continue reading How To Add a New Column Using a Dictionary in Pandas Data Frame ?