Last active
July 24, 2017 02:27
-
-
Save ksomemo/efba1e4eafe28298d572 to your computer and use it in GitHub Desktop.
python package での zscore
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 | |
import scipy as sp | |
import seaborn as sns | |
import matplotlib.pyplot as plt | |
%matplotlib inline | |
# pd.stats.misc.zscore AttributeError | |
df = pd.DataFrame({"n": range(10)}) | |
df = df.assign( | |
sp_z=sp.stats.zscore(df["n"]), | |
ddof_t_z=(df["n"] - df["n"].mean()) / df["n"].std(), | |
ddof_f_z=(df["n"] - df["n"].mean()) / df["n"].std(ddof=False) | |
) | |
# degrees of freedom | |
# http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.std.html | |
print(df.min()) | |
print(df.max()) | |
df.plot(subplots=True, figsize=(10, 4), layout=(1, 4)) | |
plt.tight_layout() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment