fix
This commit is contained in:
parent
8f5050ab31
commit
8e3962db65
@ -26,7 +26,9 @@ interval_options = [
|
|||||||
{'label': '5 minutes', 'value': 5},
|
{'label': '5 minutes', 'value': 5},
|
||||||
{'label': '10 minutes', 'value': 10},
|
{'label': '10 minutes', 'value': 10},
|
||||||
{'label': '30 minutes', 'value': 30},
|
{'label': '30 minutes', 'value': 30},
|
||||||
{'label': '60 minutes', 'value': 60}
|
{'label': '60 minutes', 'value': 60},
|
||||||
|
{'label': '⅓ day', 'value': 480},
|
||||||
|
{'label': '1 day', 'value': 1440}
|
||||||
]
|
]
|
||||||
days_options = [
|
days_options = [
|
||||||
{'label': '7 days', 'value': 7},
|
{'label': '7 days', 'value': 7},
|
||||||
|
@ -211,7 +211,6 @@ def run_loop_test(start_date="2024-10-01", end_date="2025-03-12", interval_hours
|
|||||||
"", "", "", "", "", "", "", "", "", "", f"Error: {str(e)}"])
|
"", "", "", "", "", "", "", "", "", "", f"Error: {str(e)}"])
|
||||||
pbar.update(1)
|
pbar.update(1)
|
||||||
|
|
||||||
# 每处理完一个块写入 CSV
|
|
||||||
with open(output_file, 'a', newline='') as f:
|
with open(output_file, 'a', newline='') as f:
|
||||||
writer = csv.writer(f)
|
writer = csv.writer(f)
|
||||||
writer.writerows(results)
|
writer.writerows(results)
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import numpy as np
|
|
||||||
from pkg.config import render_data
|
from pkg.config import render_data
|
||||||
import pytz
|
import pytz
|
||||||
|
|
||||||
@ -17,7 +16,7 @@ def aggregate_data(data, interval):
|
|||||||
for date in data['date'].unique():
|
for date in data['date'].unique():
|
||||||
day_data = data[data['date'] == date].copy()
|
day_data = data[data['date'] == date].copy()
|
||||||
day_data['interval_group'] = (day_data['minute_of_day'] // interval) * interval
|
day_data['interval_group'] = (day_data['minute_of_day'] // interval) * interval
|
||||||
agg = day_data.groupby('interval_group').size().reset_index(name='tweet_count')
|
agg = day_data.groupby('interval_group')['tweet_count'].sum().reset_index(name='tweet_count')
|
||||||
complete_data = all_minutes.merge(agg, on='interval_group', how='left').fillna({'tweet_count': 0})
|
complete_data = all_minutes.merge(agg, on='interval_group', how='left').fillna({'tweet_count': 0})
|
||||||
complete_data['date'] = date
|
complete_data['date'] = date
|
||||||
result.append(complete_data)
|
result.append(complete_data)
|
||||||
@ -30,7 +29,6 @@ def aggregate_data(data, interval):
|
|||||||
|
|
||||||
return pd.concat(result, ignore_index=True)
|
return pd.concat(result, ignore_index=True)
|
||||||
|
|
||||||
|
|
||||||
def generate_xticks(interval):
|
def generate_xticks(interval):
|
||||||
if interval <= 5:
|
if interval <= 5:
|
||||||
tick_step = 60
|
tick_step = 60
|
||||||
|
Loading…
x
Reference in New Issue
Block a user