how to group by keys with respect of some part of values in python?
问题 I have a json file with keys and Results . The result has 3 parts. like this: df.json()[0]['Results'][0] {'categoryId': '2674', 'categoryName': 'software engineer', 'score': '1.0377672767639161'} I want to collect all keys who have the same categoryName in the result. and then count them. Is it possible? 回答1: One way of doing it would be iterating over every group in one of the following ways: if you just want to know the count of one group you can do this: category_name = "software engineer"