kopia lustrzana https://github.com/mkdryden/telegram-stats-bot
stats: reformat file and fix some help messages
rodzic
c63fb3d138
commit
e31231d70d
7
stats.py
7
stats.py
|
@ -140,7 +140,7 @@ class StatsRunner(object):
|
||||||
df['Percent'] = df['count'] / df['count'].sum() * 100
|
df['Percent'] = df['count'] / df['count'].sum() * 100
|
||||||
df = df[['user', 'count', 'Percent']]
|
df = df[['user', 'count', 'Percent']]
|
||||||
df.columns = ['User', 'Total Messages', 'Percent']
|
df.columns = ['User', 'Total Messages', 'Percent']
|
||||||
df['User'] = df['User'].str.replace(r'[^\x00-\x7F]', "", regex=True)
|
df['User'] = df['User'].str.replace(r'[^\x00-\x7F]', "", regex=True) # Drop emoji
|
||||||
|
|
||||||
text = df.iloc[:n].to_string(index=False, header=True, float_format=lambda x: f"{x:.1f}")
|
text = df.iloc[:n].to_string(index=False, header=True, float_format=lambda x: f"{x:.1f}")
|
||||||
|
|
||||||
|
@ -364,7 +364,8 @@ class StatsRunner(object):
|
||||||
|
|
||||||
return None, bio
|
return None, bio
|
||||||
|
|
||||||
def get_message_history(self, user: Tuple[int, str] = None, averages: int = None, start: str = None, end: str = None)\
|
def get_message_history(self, user: Tuple[int, str] = None, averages: int = None, start: str = None,
|
||||||
|
end: str = None) \
|
||||||
-> Tuple[None, BytesIO]:
|
-> Tuple[None, BytesIO]:
|
||||||
"""
|
"""
|
||||||
Make a plot of message history over time
|
Make a plot of message history over time
|
||||||
|
@ -466,7 +467,7 @@ class StatsRunner(object):
|
||||||
raise HelpException("corr must be either pearson or spearman")
|
raise HelpException("corr must be either pearson or spearman")
|
||||||
|
|
||||||
if not 0 <= thresh <= 1:
|
if not 0 <= thresh <= 1:
|
||||||
raise HelpException(f'n must be greater than 0, got: {n}')
|
raise HelpException(f'n must be in the range [0, 1], got: {n}')
|
||||||
|
|
||||||
query = f"""
|
query = f"""
|
||||||
SELECT msg_time, extract(ISODOW FROM msg_time) as dow, extract(HOUR FROM msg_time) as hour,
|
SELECT msg_time, extract(ISODOW FROM msg_time) as dow, extract(HOUR FROM msg_time) as hour,
|
||||||
|
|
Ładowanie…
Reference in New Issue