{"id":28907608,"url":"https://github.com/harshbrar03/retail-store-sales-analysis","last_synced_at":"2026-05-06T11:32:23.884Z","repository":{"id":300370898,"uuid":"1006000318","full_name":"harshbrar03/retail-store-sales-analysis","owner":"harshbrar03","description":"A beginner-friendly data analytics project demonstrating the complete ETL workflow using a retail dataset. It involves data cleaning with Python, storing in PostgreSQL, querying with advanced SQL, and visualizing insights through Python.","archived":false,"fork":false,"pushed_at":"2025-06-21T09:46:35.000Z","size":723,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-21T10:23:53.616Z","etag":null,"topics":["matplotlib","pandas","postgresql-database","python","sql","sqlalchemy"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/harshbrar03.png","metadata":{"files":{"readme":"readME.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2025-06-21T09:07:17.000Z","updated_at":"2025-06-21T09:46:38.000Z","dependencies_parsed_at":"2025-06-21T10:23:55.039Z","dependency_job_id":"6c6de728-868b-4f84-92ac-06769f0590a7","html_url":"https://github.com/harshbrar03/retail-store-sales-analysis","commit_stats":null,"previous_names":["harshbrar03/retail-store-sales-analysis"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/harshbrar03/retail-store-sales-analysis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harshbrar03%2Fretail-store-sales-analysis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harshbrar03%2Fretail-store-sales-analysis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harshbrar03%2Fretail-store-sales-analysis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harshbrar03%2Fretail-store-sales-analysis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/harshbrar03","download_url":"https://codeload.github.com/harshbrar03/retail-store-sales-analysis/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harshbrar03%2Fretail-store-sales-analysis/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32691743,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-06T08:33:17.875Z","status":"ssl_error","status_checked_at":"2026-05-06T08:33:17.221Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["matplotlib","pandas","postgresql-database","python","sql","sqlalchemy"],"created_at":"2025-06-21T16:03:41.703Z","updated_at":"2026-05-06T11:32:23.872Z","avatar_url":"https://github.com/harshbrar03.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🛒 Retail Store Sales Analysis (SQL + Python + PostgreSQL)\n\nThis project demonstrates a complete data workflow — from data extraction and transformation to loading it into a PostgreSQL database and performing business analysis using SQL and Python. It follows a simplified ETL (Extract, Transform, Load) process, similar to those used in real-world data workflows.\n\n---\n\n## 📦 Dataset\n\n- **Source**: [Kaggle - Retail Orders Dataset](https://www.kaggle.com/datasets/ankitbansal06/retail-orders)\n- **Data Size**: 9,994 records\n- **Columns**: Order ID, Order Date, Product ID, Region, Category, Sub-Category, Segment, Cost Price, Discount, Profit, etc.\n\n---\n\n## 🧰 Tools \u0026 Technologies Used\n\n- **Python** (Pandas, Matplotlib)\n- **SQL** (PostgreSQL)\n- **SQLAlchemy** (for DB connection)\n- **Kaggle API** (for dataset download)\n- **Jupyter Notebook**\n\n---\n\n## 📌 Folder Structure\n\u003cpre\u003eRetail-Store-Analysis/\n\n├── retail_analysis.ipynb     # Main Jupyter Notebook  \n├── orders.csv               # Raw dataset (extracted)  \n├── orders_cleaned.csv       # Cleaned dataset after transformation  \n├── retail-orders.zip        # Downloaded zip from Kaggle  \n├── queries.sql              # SQL queries for BI tool integration  \n├── README.md                # Project overview and insights  \u003c/pre\u003e\n\n---\n\n## 🧭 Project Workflow Diagram\n\n![Workflow Diagram](workflow.jpg)\n\n## ⚙️ Project Workflow\n\n1. **Download** dataset from Kaggle using the API\n2. **Extract** and read the file into a Pandas DataFrame\n3. **Clean \u0026 transform** the data\n    - Renamed columns\n    - Handled missing values\n    - Added new columns like `discount`, `sale_price`, and `profit`\n4. **Push data** to a PostgreSQL database using SQLAlchemy\n5. **Write SQL queries** to answer business questions\n6. **Visualize** results using Python plots (Matplotlib)\n\n---\n\n## ❓ Business Questions Answered\n\n1. What is the total sales and profit over time (monthly/yearly)?\n2. Which regions are generating the highest profit and sales?\n3. Most profitable categories and sub-categories?\n4. Which ship modes are most used and profitable?\n5. Top-performing cities/states by sales and profit\n6. Impact of discount on profit\n7. Category-wise Sales and Profit Overview\n8. Which customer segments bring the most sales and profit?\n9. Does Profit Margin Vary Across Sub-Categories?\n\n---\n\n## 📊 Key Insights\n\n- Sales and profit vary month to month. Some months perform better than others.\n- Western and Eastern regions have higher sales and profit.\n- Copiers, Phones, and Accessories are among the most profitable sub-categories.\n- Standard Class is the most used ship mode, but others also contribute well to profits.\n- States like California lead in total sales.\n- Higher discounts generally reduce profit, can even lead to losses.\n- Technology is the most profitable and high-selling category overall.\n- Consumers contribute the most to sales, but all segments bring value.\n- Sub-categories like Copiers have better profit margins compared to others.\n\n---\n\n## 🧠 SQL Techniques Used\n\nThis project goes beyond basic querying and applies a variety of SQL techniques to extract meaningful insights from the data. Below are some of the key concepts used:\n\n- **Aggregations \u0026 Grouping**: Used `SUM()`, `AVG()`, `COUNT()` with `GROUP BY` to calculate sales, profit, and orders.\n- **Filtering \u0026 Sorting**: Applied `WHERE`, `CASE`, and `ORDER BY` to categorize data (e.g., by discount ranges or top performers).\n- **Common Table Expressions (CTEs)**: Used `WITH` clauses to break complex queries into readable steps (e.g., monthly growth, top selling products per region).\n- **Window Functions**: Applied `ROW_NUMBER() OVER(PARTITION BY ...)` to rank products by sales within each region or category.\n- **Date Functions**: Used `EXTRACT()`, `TO_CHAR()` to analyze trends by month and year.\n- **Profit Margin Calculation**: Computed custom metrics like profit margins using arithmetic in `SELECT` statements.\n\n📄 The full set of queries can be found in the `queries.sql` file.\n\n---\n\n## 🚀 How to Run This Project\n\n1. Clone the repository\n2. Install dependencies: `pip install pandas sqlalchemy psycopg2-binary matplotlib`\n3. Set up PostgreSQL and create a database named `retail_store`\n4. Run the notebook `retail_analysis.ipynb` step by step\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharshbrar03%2Fretail-store-sales-analysis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharshbrar03%2Fretail-store-sales-analysis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharshbrar03%2Fretail-store-sales-analysis/lists"}