Skip to content

Commit ed339f5

Browse files
fix(mediacloud_.py): return data as count series
1 parent 49aec08 commit ed339f5

File tree

1 file changed

+3
-7
lines changed
  • backend-python/src/media_impact_monitor/data_loaders/news_online

1 file changed

+3
-7
lines changed

backend-python/src/media_impact_monitor/data_loaders/news_online/mediacloud_.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,18 @@ def get_mediacloud_counts(
4141
if collection_ids
4242
else None
4343
)
44-
stories = _story_count_over_time(
44+
counts = _story_count_over_time(
4545
query=query,
4646
start_date=start_date,
4747
end_date=end_date,
4848
collection_ids=collection_ids,
4949
platform=platform,
5050
)
51-
if stories is None:
51+
if counts is None:
5252
return None, []
53-
stories["publish_date"] = pd.to_datetime(stories["publish_date"])
54-
counts = stories.resample("D", on="publish_date").size()
55-
counts = counts.reindex(pd.date_range(start_date, end_date), fill_value=0)
56-
counts = counts.rename("count")
53+
counts = pd.DataFrame(counts).set_index("date")["count"]
5754
return counts, []
5855

59-
6056
@cache
6157
def _story_list(**kwargs):
6258
return search.story_list(**kwargs)

0 commit comments

Comments
 (0)