added some formatting to the reaction DataFrames
This commit is contained in:
@@ -48,7 +48,7 @@ class ReactionData:
|
||||
q = f"SELECT * FROM reactions WHERE emoji LIKE '{emoji}'"
|
||||
if after is not None:
|
||||
q += f" AND datetime >= '{after}'"
|
||||
return self.read_sql(query=q, con=con)
|
||||
return self.read_sql(query=q, con=con).sort_values('count', ascending=False)
|
||||
|
||||
def read_all(self, con: sqlite3.Connection = None) -> pd.DataFrame:
|
||||
return self.read_sql(query='SELECT * FROM reactions', con=con)
|
||||
@@ -64,8 +64,11 @@ class ReactionData:
|
||||
con.close()
|
||||
|
||||
res['datetime'] = pd.to_datetime(res['datetime'], utc=True)
|
||||
res['datetime'] = res['datetime'].dt.tz_convert(
|
||||
datetime.now().astimezone().tzinfo
|
||||
)
|
||||
|
||||
return res.sort_values('count', ascending=False)
|
||||
return res.sort_values('datetime').reset_index(drop=True)
|
||||
|
||||
def row_count(self, con: sqlite3.Connection = None) -> int:
|
||||
with con or self.connect() as con:
|
||||
@@ -77,7 +80,7 @@ class ReactionData:
|
||||
def earliest(self, con: sqlite3.Connection = None):
|
||||
with con or self.connect() as con:
|
||||
cur = con.execute('SELECT MIN(datetime) FROM reactions')
|
||||
date = pd.to_datetime(cur.fetchone()[0])
|
||||
date = pd.to_datetime(cur.fetchone()[0]).to_pydatetime()
|
||||
con.close()
|
||||
return date
|
||||
|
||||
|
||||
Reference in New Issue
Block a user