A Hidden Feature of Describe Method In Pandas
The 𝗱𝗲𝘀𝗰𝗿𝗶𝗯𝗲() method in Pandas is commonly used to print descriptive statistics about the data.
But have you ever noticed that its output is always limited to numerical columns? Of course, details like mean, median, std. dev., etc. hold no meaning for non-numeric columns, so the results make total sense.
However, 𝗱𝗲𝘀𝗰𝗿𝗶𝗯𝗲() can also provide a quick summary of non-numeric columns. You can do this by specifying 𝗶𝗻𝗰𝗹𝘂𝗱𝗲="𝗮𝗹𝗹." As a result, it will return the number of unique elements, the top element with its frequency.
Read more: Documentation.
Share this post on LinkedIn: Post Link.
Thanks for reading Daily Dose of Data Science! Subscribe for free to learn something new and insightful about Python and Data Science every day. Also, get a Free Data Science PDF (250+ pages) with 200+ tips.
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.