forked from Rockyzsu/stock
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpandas_test.py
More file actions
41 lines (31 loc) · 873 Bytes
/
pandas_test.py
File metadata and controls
41 lines (31 loc) · 873 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#-*-coding=utf-8-*-
#author: Rocky Chen
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
def base_case():
dates = pd.date_range("20160516",periods=5)
print dates
df=pd.DataFrame(np.random.randn(5,5),index = dates,columns=list("ABCDE"))
print df
print df.describe()
print df.dtypes
print "Check the head 5"
print df.head()
print "check tail 5"
print df.tail()
print df.index
print df.columns
print df.T
print df['B']
print df[0:2]
print df.loc['20160517':'20160519','A':'C']
ts= pd.Series(np.random.randn(1000),index=pd.date_range('1/1/2000',periods=1000))
ts=ts.cumsum()
print "*"
print ts.plot()
df_11=pd.DataFrame(np.random.randn(1000,4),index=ts.index,columns=['A','B','C','D'])
df_11 =df-df_11.cumsum()
plt.figure()
df_11.plot()
#base_case()