Created
March 27, 2019 02:45
-
-
Save pkaf/0357606d928384fbf7257136d46a8820 to your computer and use it in GitHub Desktop.
This implements user defined list of functions to summarise aka describe() any pandas dataframe
This file contains hidden or 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
import pandas as pd | |
import numpy as np | |
def describe(x): | |
data = [np.mean(x), x.std(), x.median() - x.quantile(0.25), | |
x.median(), x.quantile(0.75) - x.median(), np.sum(x)] | |
names = ['mean', 'std', '-err', '50%', '+err', 'sum'] | |
return pd.DataFrame(data, index=names).T | |
#functional call | |
#instead of calling default pandas command using df.describe() | |
#one has to call the following | |
df.apply(describe) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment