Created
June 7, 2020 16:42
-
-
Save valeriocos/424ffc2fe9057215992842ed9a0d44ee to your computer and use it in GitHub Desktop.
using counter to count emotions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import collections | |
def __get_reactions(self, item): | |
item_reactions = item.get('award_emoji_data', []) | |
if item_reactions: | |
reactions_counter = collections.Counter([reaction["name"] for reaction in item_reactions]) | |
item_reactions = [{"type": reaction, "count": reactions_counter[reaction]} for reaction in reactions_counter] | |
return {"reactions": item_reactions} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment