s = pd.Series([1,2,3,4,5,6,7])
print(s.pct_change())
'''
0 NaN
1 1.000000
2 0.500000
3 0.333333
4 0.250000
5 0.200000
6 0.166667
dtype: float64
'''
df = pd.DataFrame(np.random.randn(5,2))
print(df.pct_change())
'''
0 1
0 NaN NaN
1 -0.079922 -0.967315
2 5.439245 -16.543627
3 -0.982768 1.365857
4 -16.309964 -0.422582
s1 = pd.Series(np.random.randn(10))
s2 = pd.Series(np.random.randn(10))
s1.cov(s2)
'''
-0.2903289442568039
'''
df = pd.DataFrame(np.random.randn(10,5), columns=["a","b","c","d","e"])
df.cov()
'''
a b c d e
a 0.490571 -0.226859 0.195764 0.105226 -0.054498
b -0.226859 1.675397 -0.720394 -0.437154 0.035249
c 0.195764 -0.720394 1.277242 0.422822 -0.073178
d 0.105226 -0.437154 0.422822 0.316138 0.021553
e -0.054498 0.035249 -0.073178 0.021553 0.957176
'''
df.a.corr(df.b)
# -0.25023454111623283
df.corr()
'''
a b c d e
a 1.000000 -0.250235 0.247312 0.267199 -0.079530
b -0.250235 1.000000 -0.492464 -0.600671 0.027835
c 0.247312 -0.492464 1.000000 0.665399 -0.066183
d 0.267199 -0.600671 0.665399 1.000000 0.039181
e -0.079530 0.027835 -0.066183 0.039181 1.000000
'''
s = pd.Series(np.random.np.random.randn(5), index=list('abcde'))
s.d=s.b
s.rank()
'''
a 4.0
b 2.5
c 1.0
d 2.5
e 5.0
dtype: float64
'''