How to count number of rows according to the condition of the Pandas?

There is a date frame ws.

ws['cluster'].value_counts() # prints:
2 293
4 233
0 211
5 35
6 2
3 1
1 1
Name: cluster dtype: int64

As one flick of the wrist (code) to display the row whose number in the cluster is less than, say, 5.
Ie, in this case, output lines related to the cluster No. 6,3, 1.
Important. To turn just the cluster number is impossible, because these numbers are assigned randomly by the K-means method, in each iteration, the distribution of clusters and number of clusters will change.
As a cycle of prints and don't want to do, because the work is done in jupyter, which has its beautiful output without print.
Perhaps there is some simple method?
March 23rd 20 at 19:04
0 answer

Find more questions by tags Python