small tweaks
This commit is contained in:
8
msg.py
8
msg.py
@@ -5,6 +5,7 @@ from typing import Dict, Iterable
|
||||
|
||||
import discord
|
||||
import pandas as pd
|
||||
import pandas.errors
|
||||
from dotenv import load_dotenv
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
@@ -89,8 +90,11 @@ def emoji_messages(msg_df, react_df, emoji_name: str, days: int = 10) -> pd.Data
|
||||
LOGGER.info(
|
||||
f'Found {reacted_msgs.shape[0]} messages for the leaderboard, {reactions["count"].sum():.0f} reactions total')
|
||||
|
||||
reacted_msgs['count'] = reacted_msgs.index.to_series().apply(
|
||||
lambda idx: reactions.loc[pd.IndexSlice[idx, emoji_name], 'count'])
|
||||
try:
|
||||
reacted_msgs['count'] = reacted_msgs.index.to_series().apply(
|
||||
lambda idx: reactions.loc[pd.IndexSlice[idx, emoji_name], 'count'])
|
||||
except pandas.errors.InvalidIndexError as e:
|
||||
LOGGER.error(f'{e}\n{reacted_msgs[reacted_msgs.index.duplicated()]}')
|
||||
|
||||
reacted_msgs = reacted_msgs[
|
||||
reacted_msgs['created'] >= (datetime.today() - timedelta(days=days)).astimezone()]
|
||||
|
||||
Reference in New Issue
Block a user