zscore

In [22]:
import pandas as pd
import numpy as np
import scipy as sp
import seaborn as sns
import matplotlib.pyplot as plt

%matplotlib inline
In [17]:
pd.stats.misc.zscore
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-17-e3d28676c8a4> in <module>()
----> 1 pd.stats.misc.zscore

AttributeError: module 'pandas.stats' has no attribute 'misc'
In [9]:
sp.stats.zscore
Out[9]:
<function scipy.stats.stats.zscore>
In [35]:
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)
)
ddof=False

print(df.min())
print(df.max())

df.plot(subplots=True, figsize=(10, 4), layout=(1, 4))
plt.tight_layout()
n           0.000000
ddof_f_z   -1.566699
ddof_t_z   -1.486301
sp_z       -1.566699
dtype: float64
n           9.000000
ddof_f_z    1.566699
ddof_t_z    1.486301
sp_z        1.566699
dtype: float64
../../../_images/contents_notebooks_pandas_zscore_4_1.png
In [ ]: