Pandas One Liner Solution beats 95% | Detailed Solution explaining each step.
Approach\n1. Select the class column from the DataFrame and calculate the value_counts for each class available in the class.\n\ncourses[\'class\'].value_counts
# Approach\n1. Select the class column from the DataFrame and calculate the value_counts for each class available in the class.\n```\ncourses[\'class\'].value_counts()\n```\n2. Comparing this to >4 will give you a boolean list containing true for those classes which are present at least 5 times.\n```\ncourses[\'class\'].value_counts()>4\n```\n3. Selecting only those classes which are stated True.\n```\ncourses[\'class\'].value_counts()[(courses[\'class\'].value_counts()>4)]\n```\n4. As value_counts will return us a Series which will be containing classes as indexes and their counts as their values we use .index function to just fetch the classes name.\n\n5.  Now this data is still in Series whereas we have to return a dataframe for which we used .to_frame() function to convert the series into a dataframe.\n\n# Code\n```\nimport pandas as pd\n\ndef find_classes(courses: pd.DataFrame) -> pd.DataFrame:\n    return courses[\'class\'].value_counts()[(courses[\'class\'].value_counts()>4)].index.to_frame()\n```\n\n# Feedback\nUpvote this solution if it helped you, so it can reach more people.\n
['Pandas']