2 Ways to Randomly Sample Rows from a large CSV file

In this post, we will be learning how to randomly sample/select rows from a large CSV file that is either taking too long to load as a Pandas dataframe or can’t load at all. The key idea is to not to load the whole file as a Pandas dataframe. Instead, we use skiprows argument in… Continue reading 2 Ways to Randomly Sample Rows from a large CSV file

Pandas Cumulative Sum by Group

Pandas cumsum() to compute cumulative sum by group

In this tutorial as part of our Pandas 101 series, we will learn how to compute cumulative sum of a column based on values from a grouping column in Pandas dataframe. Pandas cumsum() function can compute cumulative sum over a DataFrame, In this example we are interested getting cumulative sum of just one column by… Continue reading Pandas Cumulative Sum by Group

Pandas pipe function in Pandas: performing PCA

Pandas pipe function can help us chain together functions that takes either dataframe or series as input. In this introductory tutorial, we will learn how to use Pandas pipe method to simplify code for data analysis. We start with a dataframe as input and do a series of analysis such that that each step takes… Continue reading Pandas pipe function in Pandas: performing PCA

How to Change Matplotlib Plot’s Style

How to Set Matplotlib Plot Style to Seaborn Colorblind Style

In this post we will learn how to find all available style options for matplotlib plot themes and learn to set a style for matplotlib plot. To illustrate the styling options available in Matplotlib, we will use histogram made from beta distributions. To get started, let us load the modules needed. We can use style… Continue reading How to Change Matplotlib Plot’s Style

How to Select Columns/Rows by substring match in Pandas

In this post, we will learn how to select columns of a Pandas dataframe or a rows of a dataframe based on substring match in Pandas. We will use Pandas filter() function with argument “like” to select columns/rows, whose names partially match with a string of interest. Let us load the necessary modules. We are… Continue reading How to Select Columns/Rows by substring match in Pandas