Commit
•
e19490a
1
Parent(s):
195a3cd
chore: Update dataset growth plot to exclude current month
Browse files
app.py
CHANGED
@@ -48,10 +48,14 @@ def plot_datasets_growth(data, framework):
|
|
48 |
df = pd.DataFrame(data)
|
49 |
df["createdAt"] = pd.to_datetime(df["createdAt"])
|
50 |
df["month"] = df["createdAt"].dt.to_period("M").astype(str)
|
|
|
|
|
|
|
|
|
|
|
51 |
df_counts = df.groupby("month").size().reset_index(name="count")
|
52 |
df_counts["cumulative_count"] = df_counts["count"].cumsum()
|
53 |
df_counts["growth_rate"] = df_counts["count"].pct_change()
|
54 |
-
|
55 |
fig = px.line(df_counts, x="month", y="cumulative_count", title="Dataset Growth")
|
56 |
fig.update_layout(
|
57 |
xaxis_title="Month",
|
@@ -67,11 +71,9 @@ def plot_datasets_growth(data, framework):
|
|
67 |
title="", orientation="h", yanchor="bottom", y=1.02, xanchor="right", x=1
|
68 |
),
|
69 |
)
|
70 |
-
|
71 |
fig.add_scatter(
|
72 |
x=df_counts["month"], y=df_counts["growth_rate"], name="Growth Rate", yaxis="y2"
|
73 |
)
|
74 |
-
|
75 |
fig.update_layout(
|
76 |
title={
|
77 |
"text": f"Dataset Growth for {framework} datasets",
|
@@ -93,7 +95,6 @@ def plot_datasets_growth(data, framework):
|
|
93 |
)
|
94 |
],
|
95 |
)
|
96 |
-
|
97 |
return fig
|
98 |
|
99 |
|
@@ -105,13 +106,17 @@ def update_dashboard(framework):
|
|
105 |
|
106 |
|
107 |
with gr.Blocks() as demo:
|
108 |
-
gr.Markdown("#
|
|
|
|
|
|
|
109 |
framework = gr.Dropdown(
|
110 |
choices=choices,
|
111 |
allow_custom_value=True,
|
|
|
112 |
)
|
113 |
-
plot = gr.Plot()
|
114 |
-
markdown = gr.Markdown()
|
115 |
framework.change(update_dashboard, inputs=[framework], outputs=[plot, markdown])
|
116 |
|
117 |
demo.launch()
|
|
|
48 |
df = pd.DataFrame(data)
|
49 |
df["createdAt"] = pd.to_datetime(df["createdAt"])
|
50 |
df["month"] = df["createdAt"].dt.to_period("M").astype(str)
|
51 |
+
|
52 |
+
# Exclude the current month
|
53 |
+
current_month = pd.Period.now("M").strftime("%Y-%m")
|
54 |
+
df = df[df["month"] < current_month]
|
55 |
+
|
56 |
df_counts = df.groupby("month").size().reset_index(name="count")
|
57 |
df_counts["cumulative_count"] = df_counts["count"].cumsum()
|
58 |
df_counts["growth_rate"] = df_counts["count"].pct_change()
|
|
|
59 |
fig = px.line(df_counts, x="month", y="cumulative_count", title="Dataset Growth")
|
60 |
fig.update_layout(
|
61 |
xaxis_title="Month",
|
|
|
71 |
title="", orientation="h", yanchor="bottom", y=1.02, xanchor="right", x=1
|
72 |
),
|
73 |
)
|
|
|
74 |
fig.add_scatter(
|
75 |
x=df_counts["month"], y=df_counts["growth_rate"], name="Growth Rate", yaxis="y2"
|
76 |
)
|
|
|
77 |
fig.update_layout(
|
78 |
title={
|
79 |
"text": f"Dataset Growth for {framework} datasets",
|
|
|
95 |
)
|
96 |
],
|
97 |
)
|
|
|
98 |
return fig
|
99 |
|
100 |
|
|
|
106 |
|
107 |
|
108 |
with gr.Blocks() as demo:
|
109 |
+
gr.Markdown("# Dataset frameworks/tags on the Hub")
|
110 |
+
gr.Markdown(
|
111 |
+
"This dashboard displays the number of datasets per author and the growth of datasets over time for a given framework/tag."
|
112 |
+
)
|
113 |
framework = gr.Dropdown(
|
114 |
choices=choices,
|
115 |
allow_custom_value=True,
|
116 |
+
label="Select a framework/tag",
|
117 |
)
|
118 |
+
plot = gr.Plot(label="Growth of datasets over time")
|
119 |
+
markdown = gr.Markdown(label="summary")
|
120 |
framework.change(update_dashboard, inputs=[framework], outputs=[plot, markdown])
|
121 |
|
122 |
demo.launch()
|