{"id":27946021,"url":"https://github.com/rohinimaity/sales_data_analysis","last_synced_at":"2025-06-28T09:35:56.881Z","repository":{"id":291491476,"uuid":"977765305","full_name":"RohiniMaity/Sales_data_analysis","owner":"RohiniMaity","description":null,"archived":false,"fork":false,"pushed_at":"2025-05-05T00:52:58.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-07T13:51:00.307Z","etag":null,"topics":["data-analysis","postgresql","sql"],"latest_commit_sha":null,"homepage":"","language":"SQL","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/RohiniMaity.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-05-04T23:02:54.000Z","updated_at":"2025-05-05T00:53:01.000Z","dependencies_parsed_at":"2025-05-05T01:30:21.427Z","dependency_job_id":"3c124777-0db7-4660-b415-29c545d568ba","html_url":"https://github.com/RohiniMaity/Sales_data_analysis","commit_stats":null,"previous_names":["rohinimaity/sales_data_analysis"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/RohiniMaity/Sales_data_analysis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RohiniMaity%2FSales_data_analysis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RohiniMaity%2FSales_data_analysis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RohiniMaity%2FSales_data_analysis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RohiniMaity%2FSales_data_analysis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RohiniMaity","download_url":"https://codeload.github.com/RohiniMaity/Sales_data_analysis/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RohiniMaity%2FSales_data_analysis/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262406943,"owners_count":23306285,"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":["data-analysis","postgresql","sql"],"created_at":"2025-05-07T13:47:36.596Z","updated_at":"2025-06-28T09:35:56.860Z","avatar_url":"https://github.com/RohiniMaity.png","language":"SQL","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# 📊 Walmart Sales Data Analysis\n\nThis project performs data cleaning in **Python** and then conducts a comprehensive **SQL analysis** using **PostgreSQL**. It uncovers insights into sales performance, customer behavior, and store-level metrics from Walmart’s transactional data.\n\n---\n\n## 📁 Project Structure\n\n- `project.py`: Python file with:\n  - Data loading and cleaning in **Pandas**\n  - Data export to PostgreSQL (optional)\n  - Analytical SQL queries using `psycopg2` or `sqlalchemy`\n- `Walmart.csv`: Raw transactional dataset (must be present in the same directory)\n- `README.md`: Documentation and explanation\n\n---\n\n## Get Dataset\n\n### Setup Kaggle API\n- API Setup: Obtain your Kaggle API token from Kaggle by navigating to your profile settings and downloading the JSON file.\n- Configure Kaggle:\n   - Place the downloaded kaggle.json file in your local .kaggle folder.\n   - Use the command kaggle datasets download -d \u003cdataset-path\u003e to pull datasets directly into your project.\n\n### Download Walmart Sales Data\n- Data Source: Use the Kaggle API to download the Walmart sales datasets from Kaggle.\n- Dataset Link: [Walmart Sales Dataset](https://www.kaggle.com/datasets/najir0123/walmart-10k-sales-datasets)\n- Storage: Save the data in the data/ folder for easy reference and access.\n\n## 🧼 Data Cleaning Steps (Python)\n\nUsing **Pandas**, the dataset is prepared by:\n- Loading `Walmart.csv` with `pd.read_csv`\n- Checking for duplicates and nulls\n- Removing duplicates and missing entries\n- Performing initial data profiling with `describe()`, `info()`\n\nExample:\n```python\ndf = pd.read_csv(\"Walmart.csv\")\ndf.drop_duplicates(inplace=True)\ndf.dropna(inplace=True)\n```\n\n---\n\n## 🛠️ Database Setup (PostgreSQL)\n\n1. Create a database (e.g., `walmart_db`) in PostgreSQL.\n2. Import the cleaned data into a table called `walmart`.\n3. If using Python to connect:\n```python\nfrom sqlalchemy import create_engine\nimport os\nfrom dotenv import load_dotenv\n\nload_dotenv()\nengine = create_engine(\n    f\"postgresql+psycopg2://{os.getenv('POSTGRES_USER')}:{os.getenv('POSTGRES_PASSWORD')}@localhost:{os.getenv('POSTGRES_PORT')}/{os.getenv('POSTGRES_DB')}\"\n)\n```\n\n---\n\n## 🔍 Key Analysis Questions (SQL)\n\n1. **Payment Methods**  \n   ➤ How many transactions and items were sold via each method?\n\n2. **Top-Rated Categories**  \n   ➤ Which category had the highest average rating per branch?\n\n3. **Busiest Day per Branch**  \n   ➤ What’s the most active day of the week for each branch?\n\n4. **Quantity Sold by Payment Type**  \n   ➤ How many items were sold using each payment method?\n\n5. **Category Ratings by City**  \n   ➤ What are the average, min, and max ratings for each category by city?\n\n6. **Category Profitability**  \n   ➤ Which categories bring in the most profit?\n\n7. **Popular Payment Methods by Branch**  \n   ➤ What’s the most frequently used payment method at each branch?\n\n8. **Sales by Time of Day**  \n   ➤ How does transaction volume vary across shifts (Morning, Afternoon, Evening)?\n\n9. **Revenue Decline YoY**  \n   ➤ Which branches had the steepest revenue decline year-over-year?\n\n---\n\n## 📌 Highlights\n\n- Used `RANK() OVER (...)` and `GROUP BY` extensively for aggregations and rankings.\n- Converted date strings with `TO_DATE` and extracted week days using `TO_CHAR`.\n- Time of day classification using `EXTRACT(HOUR FROM time)`.\n\n---\n\n## 📚 Dependencies\n\n- Python 3.x\n- pandas\n- sqlalchemy\n- psycopg2\n- dotenv\n- PostgreSQL 12+\n\nInstall with:\n```bash\npip install pandas sqlalchemy psycopg2-binary python-dotenv\n```\n\n---\n\n## 🧠 Learnings\n\n- Handling PostgreSQL’s case sensitivity (e.g., using `\"Branch\"` vs `branch`)\n- Optimizing SQL queries with window functions\n- Using Python for efficient pre-processing before SQL analysis\n\n---\n\n## 📄 License\n\nThis project is intended for educational and analytical purposes. Feel free to fork, reuse, and expand upon it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frohinimaity%2Fsales_data_analysis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frohinimaity%2Fsales_data_analysis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frohinimaity%2Fsales_data_analysis/lists"}