Last active
August 15, 2018 19:44
-
-
Save vallantin/27ad7796af0b3864816f1cce88cc3afb to your computer and use it in GitHub Desktop.
Get the mean, minimum, maximum, standard deviation, 25th, 50th and 75th percentiles of a Data Frame
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 35, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>A</th>\n", | |
" <th>B</th>\n", | |
" <th>C</th>\n", | |
" <th>D</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>count</th>\n", | |
" <td>100.000000</td>\n", | |
" <td>100.000000</td>\n", | |
" <td>100.000000</td>\n", | |
" <td>100.000000</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>mean</th>\n", | |
" <td>53.010000</td>\n", | |
" <td>49.650000</td>\n", | |
" <td>48.310000</td>\n", | |
" <td>48.040000</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>std</th>\n", | |
" <td>27.758517</td>\n", | |
" <td>30.336622</td>\n", | |
" <td>29.051224</td>\n", | |
" <td>29.808452</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>min</th>\n", | |
" <td>0.000000</td>\n", | |
" <td>0.000000</td>\n", | |
" <td>0.000000</td>\n", | |
" <td>0.000000</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>25%</th>\n", | |
" <td>29.750000</td>\n", | |
" <td>23.000000</td>\n", | |
" <td>24.750000</td>\n", | |
" <td>22.000000</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>50%</th>\n", | |
" <td>53.000000</td>\n", | |
" <td>46.500000</td>\n", | |
" <td>50.000000</td>\n", | |
" <td>46.500000</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>75%</th>\n", | |
" <td>75.000000</td>\n", | |
" <td>78.250000</td>\n", | |
" <td>72.000000</td>\n", | |
" <td>76.250000</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>max</th>\n", | |
" <td>99.000000</td>\n", | |
" <td>98.000000</td>\n", | |
" <td>98.000000</td>\n", | |
" <td>94.000000</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" A B C D\n", | |
"count 100.000000 100.000000 100.000000 100.000000\n", | |
"mean 53.010000 49.650000 48.310000 48.040000\n", | |
"std 27.758517 30.336622 29.051224 29.808452\n", | |
"min 0.000000 0.000000 0.000000 0.000000\n", | |
"25% 29.750000 23.000000 24.750000 22.000000\n", | |
"50% 53.000000 46.500000 50.000000 46.500000\n", | |
"75% 75.000000 78.250000 72.000000 76.250000\n", | |
"max 99.000000 98.000000 98.000000 94.000000" | |
] | |
}, | |
"execution_count": 35, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"import numpy as np\n", | |
"import pandas as pd\n", | |
"\n", | |
"df = pd.DataFrame(np.random.randint(low=0, high=100, size=(100, 4)),\n", | |
" columns=list('ABCD'))\n", | |
"\n", | |
"df.describe()" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.6.5" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment