Skip to content

Commit

Permalink
feat(stars): add historical visual (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher authored Aug 19, 2024
1 parent 87154d2 commit b9c531c
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions notebook/dashboard.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,45 @@
"outputs": [],
"execution_count": null
},
{
"metadata": {},
"cell_type": "code",
"source": [
"# Star History\n",
"stargazer_data = []\n",
"for repo in df_repos.to_dict('records'):\n",
" stargazers = repo['_repo'].get_stargazers_with_dates()\n",
" for stargazer in stargazers:\n",
" stargazer_data.append({\n",
" \"repo\": repo['repo'],\n",
" \"date\": stargazer.starred_at,\n",
" })\n",
"\n",
"# Convert to DataFrame\n",
"df_stargazers = pd.DataFrame(stargazer_data)\n",
"\n",
"# Sort by date\n",
"df_stargazers = df_stargazers.sort_values(by=\"date\")\n",
"\n",
"# Calculate cumulative stars\n",
"df_stargazers[\"cumulative_stars\"] = df_stargazers.groupby(\"repo\").cumcount() + 1\n",
"\n",
"# Visualize using Plotly\n",
"fig = px.line(\n",
" df_stargazers,\n",
" x=\"date\",\n",
" y=\"cumulative_stars\",\n",
" color=\"repo\",\n",
" title=\"Star History\",\n",
" labels={\"date\": \"Date\", \"cumulative_stars\": \"Cumulative Stars\"},\n",
")\n",
"\n",
"fig.show()"
],
"id": "a08398efe666a399",
"outputs": [],
"execution_count": null
},
{
"metadata": {},
"cell_type": "markdown",
Expand Down

0 comments on commit b9c531c

Please sign in to comment.