File tree 3 files changed +31
-1
lines changed
3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,8 @@ pandas 0.7.0
70
70
NA values inserted in non-numeric columns (GH #614)
71
71
- Can pass a list of dicts or Series to ``DataFrame.append `` to concatenate
72
72
multiple rows (GH #464)
73
+ - Add ``level `` argument to ``DataFrame.xs `` for selecting data from other
74
+ MultiIndex levels (GH #371, GH #629)
73
75
74
76
**API Changes **
75
77
Original file line number Diff line number Diff line change 30
30
from pandas .util .testing import debug
31
31
32
32
from pandas .tools .merge import merge , concat
33
- from pandas .tools .pivot import pivot_table
33
+ from pandas .tools .pivot import pivot_table , crosstab
Original file line number Diff line number Diff line change @@ -165,3 +165,31 @@ def _convert_by(by):
165
165
by = list (by )
166
166
return by
167
167
168
+ def crosstab (rows , columns ):
169
+ """
170
+ Compute a simple cross-tabulation of two (or more) factors
171
+
172
+ Parameters
173
+ ----------
174
+ rows :
175
+ columns :
176
+
177
+ Returns
178
+ -------
179
+ crosstab : DataFrame
180
+ """
181
+ rname = cname = None
182
+ if isinstance (rows , Series ):
183
+ rname = rows .name
184
+
185
+ if isinstance (columns , Series ):
186
+ cname = columns .name
187
+
188
+ df = DataFrame ({'rows' : rows , 'columns' : columns })
189
+ table = df .groupby (['rows' , 'columns' ]).size ()
190
+
191
+ result = table .unstack ()
192
+ result .columns .name = cname
193
+ result .index .name = rname
194
+
195
+ return result
You can’t perform that action at this time.
0 commit comments