{"id":14959540,"url":"https://github.com/streamlit/example-app-cohort-analysis","last_synced_at":"2025-10-12T18:47:48.798Z","repository":{"id":99578261,"uuid":"504110688","full_name":"streamlit/example-app-cohort-analysis","owner":"streamlit","description":null,"archived":false,"fork":false,"pushed_at":"2022-06-20T11:32:34.000Z","size":1925,"stargazers_count":5,"open_issues_count":0,"forks_count":7,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-01-29T10:36:27.247Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/streamlit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-16T10:26:22.000Z","updated_at":"2025-01-05T10:18:28.000Z","dependencies_parsed_at":"2023-09-10T01:00:26.144Z","dependency_job_id":null,"html_url":"https://github.com/streamlit/example-app-cohort-analysis","commit_stats":{"total_commits":17,"total_committers":1,"mean_commits":17.0,"dds":0.0,"last_synced_commit":"b3f3c818415ed58a40fad770a08d713099396721"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streamlit%2Fexample-app-cohort-analysis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streamlit%2Fexample-app-cohort-analysis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streamlit%2Fexample-app-cohort-analysis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streamlit%2Fexample-app-cohort-analysis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/streamlit","download_url":"https://codeload.github.com/streamlit/example-app-cohort-analysis/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237088563,"owners_count":19253570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-24T13:19:56.664Z","updated_at":"2025-10-12T18:47:43.776Z","avatar_url":"https://github.com/streamlit.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n#  👥 Cohort Analysis App\n\n[![Streamlit App](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://cohort.streamlitapp.com/)\n\nThis Cohort Analysis App calculates the `retention rate` (the percentage of active customers compared to the total number of customers, split by month). This `retention rate` is then visualized and interpreted through a heatmap.\n\nThese \t2 demos are based on the following tutorials:\n\n---\n### First app (`Bikes` dataset)\n\nThis demo is inspired by this [Cohort Analysis Tutorial](https://github.com/maladeep/cohort-retention-rate-analysis-in-python).\n\n\u003cimg src =\"https://user-images.githubusercontent.com/27242399/174592747-596cb67e-029b-444f-aaeb-975382a4128c.png\" width=\"400px\"\u003e\u003c/img\u003e\n\nThis dataset came from the hypothetical `Sprocket Central Pty Ltd`, a medium size bikes \u0026 cycling accessories organisation.\n\nThe data was collected from `January 1, 2017` to `December 31, 2017`, and available in `CSV` format, downloadable [here](https://www.kaggle.com/datasets/archit9406/customer-transaction-dataset).\n\nEach row in the dataset contains information about an individual bike purchase:\n\n- Who bought it\n- How much they paid\n- The bike's `brand` and `product line`\n- Its `class` and `size`\n- What `day` the purchase happened\n- The `day` when the product was first sold\n\nThe underlying code takes those purchases and groups them into cohorts and calculates the `retention rate`, split by month, so that one can answer the question:\n\nThe underlying code groups those purchases into cohorts and calculates the `retention rate` (split by month) so that one can answer the question:\n\n*if I'm making weekly changes to my store to get people to come back and buy more bikes, are those changes working?\"*\n\nThese cohorts are then visualized and interpreted through a heatmap [powered by Plotly](https://plotly.com/python/).\n\n\n---\n### Second app (`Food` dataset)\n\nThis demo is inspired by this [Cohort Analysis Tutorial](http://www.gregreda.com/2015/08/23/cohort-analysis-with-python/)\n\n\u003cimg src =\"https://user-images.githubusercontent.com/27242399/174386573-882bee1d-38a1-435f-bdf3-a7713239e1e9.png\" width=\"400px\"\u003e\u003c/img\u003e\n\nThis dataset comes from the hypothetical `Relay Food` company. The data spans from `June 1, 2009` to `September 3, 2010` and is available in CSV format (downloadable [here](https://github.com/springcoil/marsmodelling/blob/master/relay-foods.xlsx)).\n\nEach row in the dataset contains information about an individual food order:\n\n   - Who bought it\n   - How much they paid\n   - The pick-up date\n\nThe underlying code groups those purchases into monthly cohorts (with the user's cohort group based on their first order) and calculates the `retention rate` so that one can answer the question:\n\n *if I'm making monthly changes to my shop to get people to come back and order more, are those changes working?\"*\n\nThese cohorts are then visualized and interpreted through a heatmap [powered by Plotly](https://plotly.com/python/).\n\n\n---\n### Process\n\nHere are the steps we undertook to create the cohort analysis app:\n\n1. Load the data \n2. Create the cohort \n3. Calculate the retention rate\n4. Visualize and interpret the retention rate via the heatmap\n \n---\n### About the app\n\n- App created using 🎈[Streamlit](https://streamlit.io/) and [Plotly Heatmaps](https://plotly.com/python/heatmaps/)\n- Deployed on [Streamlit Cloud](https://streamlit.io/cloud) ☁️\n---\n### Questions? Comments?\n\nPlease ask in the [Streamlit community](https://discuss.streamlit.io).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstreamlit%2Fexample-app-cohort-analysis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstreamlit%2Fexample-app-cohort-analysis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstreamlit%2Fexample-app-cohort-analysis/lists"}