Skip to content

Commit

Permalink
118 add youtube videos as source to histogram (#122)
Browse files Browse the repository at this point in the history
* typo

* no need to specify unit for ISO 8601 format
  • Loading branch information
longshuicy authored May 22, 2024
1 parent 34567de commit e7acf92
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions containerized_analytics/smile/histogram/histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ def plot_freq(index, counts, interval, localPath, remotePath):
return div_url


def count_freq(df, time_col_name, time_freq, time_unit):
def count_freq(df, time_col_name, time_freq, time_unit=None):
# convert time column to datetime
df[time_col_name] = pd.to_datetime(df[time_col_name],unit=time_unit)
df[time_col_name] = pd.to_datetime(df[time_col_name], unit=time_unit)
# set index to datetime
df.set_index(df[time_col_name],inplace=True)

Expand Down
5 changes: 3 additions & 2 deletions containerized_analytics/smile/histogram/rabbitmq_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,16 @@ def rabbitmq_handler(ch, method, properties, body):
freq = count_freq(df, 'info.dateuploaded', interval, 's')

# youtube videos
elif 'snnipet.publishedAt' in df.columns:
elif 'snippet.publishedAt' in df.columns:
# default at 1 month
if 'interval' in event:
interval = event['interval']
else:
interval = '1M'
freq = count_freq(df, 'snnipet.publishedAt', interval, 's')
freq = count_freq(df, 'snippet.publishedAt', interval)

else:
print("No valid time column found")
return {'url': 'null'}

index = freq.index.tolist()
Expand Down

0 comments on commit e7acf92

Please sign in to comment.