When You Should Not Use the head() Method In Pandas
One often retrieves the top π€ rows of a sorted Pandas DataFrame by using π‘πππ() method. However, there's a flaw in this approach.
If your data has repeated values, π‘πππ() will not consider that and just return the first π€ rows.
If you want to consider repeated values, use π§π₯ππ«π ππ¬π (or π§π¬π¦ππ₯π₯ππ¬π) instead. Here, you can specify the desired behavior for duplicate values using the π€πππ© parameter.
Share this post on LinkedIn: link.
Find the code for my tips here:Β GitHub.
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.