- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Write a Python program to quantify the shape of a distribution in a dataframe
Assume, you have a dataframe and the result for quantify shape of a distribution is,
kurtosis is: Column1 -1.526243 Column2 1.948382 dtype: float64 asymmetry distribution - skewness is: Column1 -0.280389 Column2 1.309355 dtype: float64
Solution
To solve this, we will follow the steps given below −
Define a dataframe
Apply df.kurt(axis=0) to calculate the shape of distribution,
df.kurt(axis=0)
Apply df.skew(axis=0) to calculate unbiased skew over axis-0 to find asymmetry distribution,
df.skew(axis=0)
Example
Let’s see the following code to get a better understanding −
import pandas as pd data = {"Column1":[12,34,56,78,90], "Column2":[23,30,45,50,90]} df = pd.DataFrame(data) print("DataFrame is:\n",df) kurtosis = df.kurt(axis=0) print("kurtosis is:\n",kurtosis) skewness = df.skew(axis=0) print("asymmetry distribution - skewness is:\n",skewness)
Output
DataFrame is: Column1 Column2 0 12 23 1 34 30 2 56 45 3 78 50 4 90 90 kurtosis is: Column1 -1.526243 Column2 1.948382 dtype: float64 asymmetry distribution - skewness is: Column1 -0.280389 Column2 1.309355 dtype: float64
- Related Articles
- Write a program in Python to covert the datatype of a particular column in a dataframe
- Write a program in Python to modify the diagonal of a given DataFrame by 1
- Write a Python program to reshape a given dataframe in different ways
- Write a program in Python to find the minimum rank of a particular column in a dataframe
- Write a program in Python to convert a given dataframe to a LaTex document
- Write a program in Python to print the ‘A’ grade students’ names from a DataFrame
- Write a Python program to export a dataframe to an html file
- Write a program in Python to transpose the index and columns in a given DataFrame
- Write a Python program to perform table-wise pipe function in a dataframe
- Write a program in Python to localize Asian timezone for a given dataframe
- Write a program in Python to count the total number of leap years in a given DataFrame
- Write a Python program to trim the minimum and maximum threshold value in a dataframe
- Write a program in Python to remove first duplicate rows in a given dataframe
- Write a Python program to find the mean absolute deviation of rows and columns in a dataframe
- Write a Python program to count the total number of ages between 20 to 30 in a DataFrame

Advertisements