Pandas ‘count(distinct)’ equivalent
I believe this is what you want: Example:
I believe this is what you want: Example:
Non-numpy way: Use collections.Counter;
If you only want one item’s count, use the count method: Important Note regarding count performance Don’t use this if you want to count multiple items. Calling count in a loop requires a separate pass over the list for every count call, which can be catastrophic for performance. If you want to count all items, or even just multiple items, use Counter, … Read more
PDO fetch returns false on failure. So you need to check this case too:
You can just use table(): Then you can subset it: Or convert it into a data.frame if you’re more comfortable working with that: