Preparation
Before any data manipulation can occur, two (2) new libraries will require installation.
- The Pandas library enables access to/from a DataFrame.
- The NumPy library supports multi-dimensional arrays and matrices in addition to a collection of mathematical functions.
To install these libraries, navigate to an IDE terminal. At the command prompt ($
), execute the code below. For the terminal used in this example, the command prompt is a dollar sign ($
). Your terminal prompt may be different.
$ pip install pandas
Hit the <Enter>
key on the keyboard to start the installation process.
$ pip install numpy
Hit the <Enter>
key on the keyboard to start the installation process.
If the installations were successful, a message displays in the terminal indicating the same.
Feel free to view the PyCharm installation guide for the required libraries.
Add the following code to the top of each code snippet. This snippet will allow the code in this article to run error-free.
import pandas as pd import numpy as np
DataFrame kurt() and kurtosis()
The DataFrame kurt()
and kurtosis()
methods are identical and return an unbiased kurtosis over a requested axis. For additional information on Kurtosis, click here.
Parameter | Description |
---|---|
axis | If zero (0) or index is selected, apply to each column. Default 0. If one (1) apply to each row. |
skipna | Exclude NA/null values when computing the result. By default, True . |
level | If the axis is a MultiIndex , count along with a particular level, collapsing into a Series. By default, the value is None . |
numeric_only | Includes floats, integers, and boolean columns. If None , this parameter will attempt to use everything. |
**kwargs | This parameter is additional keyword arguments to be passed to the method. |
For this example, the Hockey Teams data is used.
df_teams = pd.DataFrame({'Bruins': [4, 5, 9], 'Oilers': [3, 6, 10], 'Leafs': [2, 7, 11], 'Flames': [1, 8, 12]}) result = df_teams.kurtosis() print(result)
- Line [1] creates a DataFrame from a Dictionary of Lists and saves it to
df_teams
. - Line [2] uses the
kurtosis()
method to determine the output and saves to theresult
variable. - Line [3] outputs the result to the terminal.
Output
Bruins | NaN |
Oilers | NaN |
Leafs | NaN |
Flames | NaN |
dtype: | float64 |
More Pandas DataFrame Methods
Feel free to learn more about the previous and next pandas DataFrame methods (alphabetically) here:
Also, check out the full cheat sheet overview of all Pandas DataFrame methods.