def test_dates(self):
for t in self.mock_tweets:
self.feels_db.insert_tweet(t)
self.assertEqual(len(self.feels_db.tweet_dates), 3)
tweets = []
with open(self.tweets_data_path) as tweets_file:
lines = filter(None, (line.rstrip() for line in tweets_file))
for line in lines:
try:
tweets.append(Tweet(json.loads(line)))
except KeyError:
pass
for t in tweets:
self.feels_db.insert_tweet(t)
self.assertEqual(len(self.feels_db.tweet_dates), 105)
df = self.feels_db.tweet_dates
timebox = timedelta(seconds=60)
second = timedelta(seconds=1)
df = df.groupby(pd.TimeGrouper(freq=f'{int(timebox/second)}S')).size()
df = df[df != 0]
print(df)
self.assertEqual(len(df), 3)
self.assertEqual(df.iloc[0], 103)
评论列表
文章目录