Nerd For Tech
Published in

Nerd For Tech

Descriptive Statistics in Pandas

A guide on how to calculate descriptive statistics in Pandas.

Photo by Scott Graham on Unsplash

Loading Data

First of all, let’s import the libraries.

Let’s create a data frame named df and this dataset contains missing data.

You can calculate the sum of the columns with the sum method.

For the sum of rows, you can use the axis = “columns” or axis = 1.

You can calculate the mean of the rows using the mean method.

Note that by default, missing data were not included in the mean. If you want to take into account the missing data, you can use the skipna = False.

Let’s see the maximum values in rows and columns.

Let’s see the minimum values in rows and columns.

Let’s calculate the cumulative sums.

You can use the described method to see summary statistics of the dataset.

To find the correlation coefficient, let’s first import the famous the iris dataset. You can download iris data set from here.

Let’s take a look at the first five rows of iris dataset.

As you can see, there is no column name in the iris dataset. Let’s give the column name.

Let’s see the first five rows of the iris dataset again.

Let’s calculate the correlation between sepal length and sepal width.

You can use the corr method to see the binary correlation of all variables in a data frame.

You can use the cov method to see the binary covariance of all variables.

With the corrwith method, you can obtain binary comparisons between a variable and other variables in the dataset.

You can use the unique method to see the unique values. To show this, let’s create a Series named s.

Let’s use the unique method.

You can use the value_counts method to see the frequency of the values.

To control whether the value is in the dataset you can use the isin method.

Let’s see the rows with these values.

That’s it. I hope you enjoy this post. You can access the notebook here.

--

--

--

NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit https://www.nerdfortech.org/.

Recommended from Medium

Are You Considering Making Your Classes Immutable?

New comers frustration

How to install Laravel on Windows 11 with WAMP

How to create Order Matcher in Go?

Optimize for effectiveness Slack + GitHub

Code Review Guidelines — The Secret Sauce to Listing Marketplace Apps in Record Time 🚀

What is Swagger? Usage with .Net Core 3.1 Web API

EKS RBAC Setup using OKTA

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Tirendaz Academy

Tirendaz Academy

Data Science Lover 🔥 Machine Learning Practitioner 🔥 Deep Learning Enthusiast

More from Medium

Frequently use Pandas methods/functions

Basic data cleaning with Pandas

5 WAYS TO HANDLE MISSING VALUES IN PYTHON

Calculating the number of business days between dates in Python