forked from brandon-rhodes/pycon-pandas-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cheat-sheet.txt
166 lines (97 loc) · 5.2 KB
/
cheat-sheet.txt
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
Welcome!
1. Install Pandas and the IPython Notebook
The Anaconda distribution includes Pandas built-in:
http://continuum.io/downloads
2. Download and unzip "Pandas-Tutorial.zip" from
https://github.com/brandon-rhodes/pycon-pandas-tutorial/releases
3. Start the IPython Notebook and visit the "pandas-tutorial"
folder from inside the .zip
len(df) series + value df[df.c == value]
df.head() series + series2 df[(df.c >= value) & (df.d < value)]
df.tail() series.notnull() df[(df.c < value) | (df.d != value)]
df.COLUMN series.isnull() df.sort_values('column')
df['COLUMN'] series.sort_index() df.sort_values(['column1', 'column2'])
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
http://continuum.io/downloads
https://github.com/brandon-rhodes/pycon-pandas-tutorial/releases
len(df) series + value df[df.c == value]
df.head() series + series2 df[(df.c >= value) & (df.d < value)]
df.tail() series.notnull() df[(df.c < value) | (df.d != value)]
df.COLUMN series.isnull() df.sort_values('column')
df['COLUMN'] series.sort_index() df.sort_values(['column1', 'column2'])
s.str.len() s.value_counts()
s.str.contains() s.sort_index() df[['column1', 'column2']]
s.str.startswith() s.plot(...) df.plot(x='a', y='b', kind='bar')
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
len(df) series + value df[df.c == value]
df.head() series + series2 df[(df.c >= value) & (df.d < value)]
df.tail() series.notnull() df[(df.c < value) | (df.d != value)]
df.COLUMN series.isnull() df.sort_values('column')
df['COLUMN'] series.sort_index() df.sort_values(['column1', 'column2'])
s.str.len() s.value_counts()
s.str.contains() s.sort_index() df[['column1', 'column2']]
s.str.startswith() s.plot(...) df.plot(x='a', y='b', kind='bar')
df.set_index('a').sort_index() df.loc['value']
df.set_index(['a', 'b']).sort_index() df.loc[('v','u')]
df.groupby('column') .size() .mean() .min() .max()
df.groupby(['column1', 'column2']) .agg(['min', 'max'])
"The Pink Panther"
brandon@rhodesmill.org
len(df) series + value df[df.c == value]
df.head() series + series2 df[(df.c >= value) & (df.d < value)]
df.tail() series.notnull() df[(df.c < value) | (df.d != value)]
df.COLUMN series.isnull() df.sort_values('column')
df['COLUMN'] series.sort_index() df.sort_values(['column1', 'column2'])
s.str.len() s.value_counts()
s.str.contains() s.sort_index() df[['column1', 'column2']]
s.str.startswith() s.plot(...) df.plot(x='a', y='b', kind='bar')
df.set_index('a').sort_index() df.loc['value']
df.set_index(['a', 'b']).sort_index() df.loc[('v','u')]
df.groupby('column') .size() .mean() .min() .max()
df.groupby(['column1', 'column2']) .agg(['min', 'max'])
df.unstack()
df.stack()
df.fillna(value)
s.fillna(value)
len(df) series + value df[df.c == value]
df.head() series + series2 df[(df.c >= value) & (df.d < value)]
df.tail() series.notnull() df[(df.c < value) | (df.d != value)]
df.COLUMN series.isnull() df.sort_values('column')
df['COLUMN'] series.sort_index() df.sort_values(['column1', 'column2'])
s.str.len() s.value_counts()
s.str.contains() s.sort_index() df[['column1', 'column2']]
s.str.startswith() s.plot(...) df.plot(x='a', y='b', kind='bar')
df.set_index('a').sort_index() df.loc['value']
df.set_index(['a', 'b']).sort_index() df.loc[('v','u')]
df.groupby('column') .size() .mean() .min() .max()
df.groupby(['column1', 'column2']) .agg(['min', 'max'])
df.unstack() s.dt.year
df.stack() s.dt.month
df.fillna(value) s.dt.day
s.fillna(value) s.dt.dayofweek
len(df) series + value df[df.c == value]
df.head() series + series2 df[(df.c >= value) & (df.d < value)]
df.tail() series.notnull() df[(df.c < value) | (df.d != value)]
df.COLUMN series.isnull() df.sort_values('column')
df['COLUMN'] series.sort_index() df.sort_values(['column1', 'column2'])
s.str.len() s.value_counts()
s.str.contains() s.sort_index() df[['column1', 'column2']]
s.str.startswith() s.plot(...) df.plot(x='a', y='b', kind='bar')
df.set_index('a').sort_index() df.loc['value']
df.set_index(['a', 'b']).sort_index() df.loc[('v','u')]
df.groupby('column') .size() .mean() .min() .max()
df.groupby(['column1', 'column2']) .agg(['min', 'max'])
df.unstack() s.dt.year df.merge(df2, how='outer', ...)
df.stack() s.dt.month df.rename(columns={'a': 'y', 'b': 'z'})
df.fillna(value) s.dt.day pd.concat([df1, df2])
s.fillna(value) s.dt.dayofweek
Thanks!
Any questions?
Local variables:
mode:text
mode:page
End: