pydata/pandas — pull request #4502 by hayd (2013-08-07 15:34:27+00:00)
Title: ENH add bins argument to value_counts

fixes #3945

Also, adds arguments present in top-level function to the Series
method (sort and ascending).

Note: this only works with numeric data (it raises a TypeError if there was a TypeError problem in cut, however perhaps cut should raise a more descirptive error...)

```
In [1]: s = pd.Series(np.random.randn(100))

In [2]: s.value_counts(bins=4)
Out[2]:
0.017354 44
-1.154431 35
1.189140 14
-2.330904 7
dtype: int64

In [3]: s.value_counts(bins=4, normalize=True) # also works with sort and ascending arguments.
Out[3]:
0.017354 0.44
-1.154431 0.35
1.189140 0.14
-2.330904 0.07
dtype: float64

In [11]: s = pd.Series(list('abc'))

In [12]: s.value_counts(bins=1)
TypeError: bins argument only works with numeric data.
```

*Note: Have a test failing on python3 (topically) a sorting one*.