Created
January 26, 2026 10:56
-
-
Save unarist/e01f93d743b44656cde70a0416ffddf6 to your computer and use it in GitHub Desktop.
Filter "Spotify Extended Streaming History"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "id": "f7835c5f", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "import pandas as pd\n", | |
| "import glob\n", | |
| "\n", | |
| "df = pd.concat([pd.read_json(file) for file in glob.glob(\"*.json\")], ignore_index=True)\n", | |
| "df" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "id": "025da194", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "df2 = df.copy()\n", | |
| "df2[\"ip_addr\"] = \"0.0.0.0\"\n", | |
| "df2[\"conn_country\"] = \"\"\n", | |
| "df2[\"platform\"] = \"\"\n", | |
| "df2 = df2[df2[\"skipped\"] == False]\n", | |
| "df2 = df2[~df2[\"episode_name\"].notna()]\n", | |
| "df2 = df2[df2[\"ms_played\"] > 120000]\n", | |
| "df2\n", | |
| "# print(df2.groupby(\"master_metadata_album_artist_name\").size().sort_values(ascending=False).to_dict())\n", | |
| "# pd.to_datetime(df2['ts']).hist(bins=50)\n", | |
| "# df2.to_json(\"Streaming_History_Audio_2000-2099_0.json\", orient=\"records\", lines=False, force_ascii=False, indent=2)" | |
| ] | |
| } | |
| ], | |
| "metadata": { | |
| "kernelspec": { | |
| "display_name": "spotify-extended-streaming-history", | |
| "language": "python", | |
| "name": "python3" | |
| }, | |
| "language_info": { | |
| "codemirror_mode": { | |
| "name": "ipython", | |
| "version": 3 | |
| }, | |
| "file_extension": ".py", | |
| "mimetype": "text/x-python", | |
| "name": "python", | |
| "nbconvert_exporter": "python", | |
| "pygments_lexer": "ipython3", | |
| "version": "3.13.2" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 5 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment