packages = ["pandas", "numpy"] from datetime import datetime, timedelta import pandas as pd from pyodide.http import open_url url = ( "https://raw.githubusercontent.com/vietvudanh/vietlott-data/master/data/power655.jsonl" ) data_655 = pd.read_json(open_url(url), lines=True) data_655['date'] = pd.to_datetime(data_655['date']).dt.date data_655 = data_655.sort_values(by=['date', 'id'], ascending=False) # plot def fn_stats(df_, window_time=None): if window_time is not None: df_ = df_[df_['date'] >= (datetime.now().date() - timedelta(days=window_time))] df_explode = df_.explode('result') stats = df_explode.groupby('result').agg( count=('id', 'count') ) stats['%'] = (stats['count'] / len(df_explode) * 100).round(2) return stats stats = fn_stats(data_655) # stats n months #stats_15d = fn_stats(data_655, 15) #stats_30d = fn_stats(data_655, 30) #stats_60d = fn_stats(data_655, 60) #stats_90d = fn_stats(data_655, 90) display(data_655.head(10), target='detail_top_10') #display(stats, target='stats_all_time') #display(stats_15d, target='stats_15d') #display(stats_30d, target='stats_30d') #display(stats_60d, target='stats_60d') #display(stats_90d, target='stats_90d') data_655

Detail top 10

All time

15d

30d

60d

90d