{"id":28374060,"url":"https://github.com/ckeuss/bike_store","last_synced_at":"2026-04-29T00:05:30.298Z","repository":{"id":233324528,"uuid":"784639277","full_name":"ckeuss/Bike_store","owner":"ckeuss","description":"This exploratory data analysis examines customer, product and sales data of a retail bike store ","archived":false,"fork":false,"pushed_at":"2025-02-10T19:41:39.000Z","size":591,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-29T21:09:31.481Z","etag":null,"topics":["python","sql"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ckeuss.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":"2024-04-10T08:51:19.000Z","updated_at":"2025-02-10T19:41:43.000Z","dependencies_parsed_at":"2024-04-15T19:45:30.030Z","dependency_job_id":"eefc74f6-0e1f-49c5-9f31-7c52ea01fbf8","html_url":"https://github.com/ckeuss/Bike_store","commit_stats":null,"previous_names":["ckeuss/bike_store"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ckeuss/Bike_store","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ckeuss%2FBike_store","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ckeuss%2FBike_store/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ckeuss%2FBike_store/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ckeuss%2FBike_store/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ckeuss","download_url":"https://codeload.github.com/ckeuss/Bike_store/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ckeuss%2FBike_store/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261930428,"owners_count":23231880,"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":["python","sql"],"created_at":"2025-05-29T21:07:55.618Z","updated_at":"2026-04-29T00:05:30.270Z","avatar_url":"https://github.com/ckeuss.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bike store\n## SQL and Python\n### Project Overview\nIn this data analysis project a data base and queries are first created with SQL and then visualised using Python. \nIt aims to provide insight into e.g. the range of products, customers and sales of the bike store for the period 2016 to 2018.\n\nIt can answer key questions such as:\n- What type of bike is most popular?\n- Which bike category makes the most revenue?\n- Which store processes the most orders?\n\n### Data Sources\nThe retail bike store data is originally from a sample database from sqlservertutorial.net. \nI found and downloaded the csv files for the different tables on Kaggle.\n[more information](https://www.kaggle.com/datasets/dillonmyrick/bike-store-sample-database)\n\n### Tools\n- Python, incl. mysql.connector \n- SQL\n  \n### References\nI used the following article by Craig Dickson to learn about connecting python to SQL and building a database.  \nhttps://www.freecodecamp.org/news/connect-python-with-sql/\n\n### Data Analysis\nSome interesting code worked with:\n\n```\nwith open(\"./csv/brands.csv\", newline= \"\") as csvfile:\n    reader = csv.reader(csvfile)\n    next(reader)  #Skip the header\n    \n    for row in reader:\n        values = (row[0], row[1])\n\n        #INSERT\n        query = \"INSERT IGNORE INTO brands(brand_id, brand_name) \\\n        VALUES (%s, %s)\"\n\n        execute_query(connection, query, values)\n\n```\n\n```\nq4 = \"\"\"\nSELECT\n    ca.category_id,\n    ca.category_name,\n    SUM((oi.quantity * oi.list_price) * (1 - oi.discount)) AS total_revenue,\n    SUM(oi.quantity) AS sold_items\nFROM \n    order_items oi\n    INNER JOIN products p ON oi.product_id = p.product_id\n    INNER JOIN categories ca ON p.category_id = ca.category_id\nGROUP BY category_id\nORDER BY category_id;\n\n    \"\"\"\n\nresults = read_query(connection, q4)\n\n#Returns a list of lists and then creates a pandas DataFrame\nresult_list = []\n\nfor result in results:\n  result = list(result)\n  result_list.append(result)\n\n\ncolumns = [\"Category_id\", \"Category\", \"Total_revenue\", \"Sold_items\"]\ndf4 = pd.DataFrame(result_list, columns=columns)\n\ndf4\n\n```\n        \n```\n#barplot\ncolors = [\"#EB615F\", \"#507399\", \"#EBDC59\", \"#99B82C\", \"#AB3F32\", \"#3A4E6B\", \"#C1B0FA\"]\nplt.bar(df4[\"Category\"], df4[\"Sold_items\"], color = colors)\n\n#number on top of bars\n#index i as the x-coordinate to position the text at the center of each bar\nfor i, items in enumerate(df4[\"Sold_items\"]):\n    plt.text(i, items - 30, str(items), ha= \"center\", va=\"top\")\n\n#title and labels\nplt.xlabel(\"Category\")\nplt.ylabel(\"Sold items\")\nplt.title(\"Sold items per category\")\nplt.xticks(rotation=45, ha=\"right\")  # Rotate x-axis labels\nplt.tight_layout()\nplt.show()\n\n```\n\n### Insights on products, sales and revenue\nThe analysed bike store sells seven different types of bikes, the most products fall into the categories _Mountain Bikes_, _Cruisers Bicycles_ and _Road Bikes_, which are also the most sold items. Other categories are _Children Bicycles_, _Electric Bikes_, _Comfort Bicycles_ and _Cyclocross Bicycles_. \n\n![image](https://github.com/ckeuss/Bike_store/assets/147528104/3dd3d6fe-87e5-47b0-9426-70ed989cfff6)\n\nMarch and April seem to be the months with the highest number of orders and the majority of the orders were processed by Baldwin Bikes in NY (Store 2), one of the three branches. \n\n![image](https://github.com/ckeuss/Bike_store/assets/147528104/0f9267f5-686f-4a01-917d-0f7cd2d54787)\n\n\nThe most popular bikes in 2016 to 2018 were _Mountain Bikes_ and _Cruisers Bicycles_. The by far highest total revenue was made with _Mountain Bikes_ with around 2.71 million dollar, although bikes of this category have only the fourth highest average list price. The most expensive bikes are on average _Electric Bikes_ and _Road Bikes_. \n\n![image](https://github.com/ckeuss/Bike_store/assets/147528104/e7025d5c-fc44-4b3a-9ee2-b3db434f3cb5)\n\n\nFrom the revenue development of the three most profitable bike categories _Mountain Bikes_, _Road Bikes_ and _Electric Bikes_ from 2016 to 2018 it can be concluded that the revenue of _Electric Bikes_ is rsing while the revenue of _Mountain Bikes_ and _Road Bikes_ is on a decline, most severely concerning the _Mountain Bikes_ with a decline of around 2/3 of the original revenue in 2016. The decline could be due to many different factors and could be analyzed further by looking at the customers needs, marketing funnels, customer service, customer loyalty, price development and competition.\n\n![image](https://github.com/ckeuss/Bike_store/assets/147528104/6b4467d6-d8c9-4636-9f20-82c84a68ce4e)\n\nIn terms of punctual deliveries the analysis shows that most deliveries arrive on time, however in 2016 to 2018 around one third of the orders in the months January to March, July, October and November were delivered after the required date.\n\n\n\n### Feedback\n\nIf you encounter any issues, mistakes, or have suggestions for improvement, please let me know.\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fckeuss%2Fbike_store","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fckeuss%2Fbike_store","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fckeuss%2Fbike_store/lists"}