@@ -47,6 +47,8 @@ def cut(x, bins, right=True, labels=None, retbins=False, precision=3):
47
47
a categorical variable. For example, `cut` could convert ages to groups
48
48
of age ranges.
49
49
50
+ Any NA values will be NA in the result
51
+
50
52
Examples
51
53
--------
52
54
>>> cut(np.array([.2, 1.4, 2.5, 6.2, 9.7, 2.1]), 3, retbins=True)
@@ -128,6 +130,36 @@ def cut(x, bins, right=True, labels=None, retbins=False, precision=3):
128
130
129
131
return labels , bins
130
132
133
+
134
+ def qcut (x , n , ties_method = 'average' ):
135
+ """
136
+ Quantile-based discretization function. Discretize variable into
137
+ equal-sized buckets based on rank. For example 1000 values for 10 quantiles
138
+ would produce 1000 integers from 0 to 9 indicating the
139
+
140
+ Parameters
141
+ ----------
142
+ x : ndarray or Series
143
+ n : integer
144
+ Number of quantiles. 10 for deciles, 4 for quartiles, etc.
145
+ ties_method : {'average', 'min', 'max', 'first'}, default 'average'
146
+ average: average rank of group
147
+ min: lowest rank in group
148
+ max: highest rank in group
149
+ first: ranks assigned in order they appear in the array
150
+
151
+ Returns
152
+ -------
153
+
154
+ Notes
155
+ -----
156
+
157
+ Examples
158
+ --------
159
+ """
160
+ pass
161
+
162
+
131
163
def _format_label (x , precision = 3 ):
132
164
fmt_str = '%%.%dg' % precision
133
165
if com .is_float (x ):
0 commit comments