Skip to content

Commit a35ad6f

Browse files
author
Mofan Zhou
committed
create pd 11
1 parent 5959e33 commit a35ad6f

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

numpy&pandas/11_pandas_intro.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# View more python learning tutorial on my Youtube and Youku channel!!!
2+
3+
# Youtube video tutorial: https://www.youtube.com/channel/UCdyjiB5H8Pu7aDTNVXTTpcg
4+
# Youku video tutorial: http://i.youku.com/pythontutorial
5+
6+
7+
import pandas as pd
8+
import numpy as np
9+
10+
s = pd.Series([1,3,6,np.nan,4,1]) # similar with 1D numpy
11+
print(s)
12+
dates = pd.date_range('20160101', periods=6)
13+
df = pd.DataFrame(np.random.randn(6,4), index=dates, columns=['A','B','C','D'])
14+
print(df['B'])
15+
df2 = pd.DataFrame({'A' : 1.,
16+
'B' : pd.Timestamp('20130102'),
17+
'C' : pd.Series(1,index=list(range(4)),dtype='float32'),
18+
'D' : np.array([3] * 4,dtype='int32'),
19+
'E' : pd.Categorical(["test","train","test","train"]),
20+
'F' : 'foo'})
21+
print(df2)
22+
print(df2.dtypes)
23+
24+
print(df.index)
25+
print(df.columns)
26+
print(df.values)
27+
print(df.describe())
28+
print(df.T)
29+
print(df.sort_index(axis=1, ascending=False))
30+
print(df.sort_values(by='B'))

0 commit comments

Comments
 (0)