In this post, we will learn how to insert a column at specific location in a Pandas dataframe. We will use Pandas insert() function to insert column into DataFrame at a specified location with a specific name. Let us create a data frame using NumPy’s random module. Our data frame looks like this. We have […]
Python Tips
Linear Regression Using Matrix Multiplication in Python Using NumPy
Linear Regression is one of the commonly used statistical techniques used for understanding linear relationship between two or more variables. It is such a common technique, there are a number of ways one can perform linear regression analysis in Python. In this post we will do linear regression analysis, kind of from scratch, using matrix […]
How To Discretize/Bin a Variable in Python with NumPy and Pandas?
Sometimes you may have a quantitative variable in your data set and you might want to discretize it or bin it or categorize it based on the values of the variable. For example, let us say you have measurements of height and want to discretize it such that it is 0 or 1 depending on […]
How to Highlight Data Points with Colors and Text in Python
Sometimes you might want to highlight a select data points on a scatter plot. Often when plotting scatter plots you might want to highlight data points in a different color from the rest of the data points. Other times you want to show select data points in different color and annotate them with text. In […]
Pandas groupby: 13 Functions To Aggregate
Pandas groupby function enables us to do “Split-Apply-Combine” data analysis paradigm easily. Basically, with Pandas groupby, we can split Pandas data frame into smaller groups using one or more variables. Pandas has a number of aggregating functions that reduce the dimension of the grouped object. In this post will examples of using 13 aggregating function […]