Supercharge value_counts() Method in Pandas With Sidetable
The 𝐯𝐚𝐥𝐮𝐞_𝐜𝐨𝐮𝐧𝐭𝐬() method is commonly used to analyze categorical columns, but it has many limitations.
For instance, if one wants to view the percentage, cumulative count, etc., in one place, things do get a bit tedious. This requires more code and is time-consuming.
Instead, use 𝐬𝐢𝐝𝐞𝐭𝐚𝐛𝐥𝐞. Consider it as a supercharged version of 𝐯𝐚𝐥𝐮𝐞_𝐜𝐨𝐮𝐧𝐭𝐬(). As shown below, the 𝐟𝐫𝐞𝐪() method from sidetable provides a more useful summary than 𝐯𝐚𝐥𝐮𝐞_𝐜𝐨𝐮𝐧𝐭𝐬().
Additionally, sidetable can aggregate multiple columns too. You can also provide threshold points to merge data into a single bucket. What's more, it can print missing data stats, pretty print values, etc.
Read more: GitHub.
Share this post on LinkedIn: Post Link.
I like to explore, experiment and write about data science concepts and tools. You can read my articles on Medium. Also, you can connect with me on LinkedIn.