{"id":26896055,"url":"https://github.com/sofiasawczenko/sales_time_series_analysis","last_synced_at":"2025-04-01T02:59:31.718Z","repository":{"id":178759731,"uuid":"662322907","full_name":"sofiasawczenko/sales_time_series_analysis","owner":"sofiasawczenko","description":"This project analyzes the sales data of the company \"Alucar\" from the years 2017 and 2018, utilizing Python's pandas for data manipulation and seaborn for visualizing trends in the data.","archived":false,"fork":false,"pushed_at":"2024-12-18T11:07:51.000Z","size":130,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-18T12:23:51.306Z","etag":null,"topics":[],"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/sofiasawczenko.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}},"created_at":"2023-07-04T21:56:07.000Z","updated_at":"2024-12-18T11:08:10.000Z","dependencies_parsed_at":"2023-07-25T23:49:22.345Z","dependency_job_id":null,"html_url":"https://github.com/sofiasawczenko/sales_time_series_analysis","commit_stats":null,"previous_names":["sofiasawczenko/analyzing_times_series","sofiasawczenko/time_series_analysis"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sofiasawczenko%2Fsales_time_series_analysis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sofiasawczenko%2Fsales_time_series_analysis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sofiasawczenko%2Fsales_time_series_analysis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sofiasawczenko%2Fsales_time_series_analysis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sofiasawczenko","download_url":"https://codeload.github.com/sofiasawczenko/sales_time_series_analysis/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246574843,"owners_count":20799221,"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":"2025-04-01T02:59:31.231Z","updated_at":"2025-04-01T02:59:31.712Z","avatar_url":"https://github.com/sofiasawczenko.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Alucar - Analyzing Sales.\n\nThis project analyzes the sales data of the company \"Alucar\" from the years 2017 and 2018, utilizing Python's `pandas` for data manipulation and `seaborn` for visualizing trends in the data.\n\n## Overview\n\nThe dataset used in this project contains monthly sales data for Alucar, with two primary columns:\n- `mes`: The month of the sale (in YYYY-MM-DD format)\n- `vendas`: The number of sales for that month\n\nThis analysis involves several steps:\n1. Importing and cleaning the data.\n2. Visualizing sales trends over time.\n3. Calculating and visualizing the month-to-month increase in sales.\n4. Calculating and visualizing the acceleration of sales increases.\n\n## Requirements\n\nEnsure you have the following libraries installed:\n- pandas\n- seaborn\n- matplotlib\n\nInstall the necessary libraries by running:\n```bash\npip install pandas seaborn matplotlib\n```\n\n## Steps\n\n### 1. Loading the Data\nThe dataset is loaded from a CSV file alucar.csv and displayed to inspect the first few rows.\n\n```bash\nimport pandas as pd\nalucar = pd.read_csv('dados/alucar.csv')\nalucar.head()\n```\n### 2. Data Inspection\nThe number of rows and columns are checked, and the data types of the columns are inspected:\n\n```bash\nprint('Quantidade de linhas e colunas:', alucar.shape)\nprint('Quantidade de dados nulos', alucar.isna().sum().sum())\nprint(alucar.dtypes)\n```\n### 3. Data Cleaning\nThe mes column, initially in object format, is converted to a datetime format for better handling:\n\n```bash\nalucar['mes'] = pd.to_datetime(alucar['mes'])\nalucar.dtypes\n```\n### 4. Visualization - Sales Over Time\nWe use seaborn to create a line plot to visualize how sales have evolved over time from January 2017 to December 2018:\n\n```bash\nimport seaborn as sns\nfrom matplotlib import pyplot as plt\n\nsns.lineplot(x='mes', y='vendas', data=alucar)\n```\n### 5. Visualizing Sales Increase\nWe calculate the month-to-month increase in sales using the diff() function:\n\n```bash\nalucar['aumento'] = alucar['vendas'].diff()\nThis creates a new column, aumento, representing the sales increase each month. The increase is visualized with a line plot:\n```\n```bash\nsns.lineplot(x='mes', y='aumento', data=alucar)\n```\n### 6. Custom Plotting Function\nA custom function plotar() is defined to easily generate line plots with customizable titles, labels, and axes:\n\n```bash\ndef plotar(titulo, labelx, labely, x, y, dataset):\n    sns.set_palette('Accent')\n    sns.set_style('darkgrid')\n    ax = sns.lineplot(x=x, y=y, data=dataset)\n    ax.figure.set_size_inches(12, 6)\n    ax.set_title(titulo, loc='left', fontsize=18)\n    ax.set_xlabel(labelx, fontsize=14)\n    ax.set_ylabel(labely, fontsize=14)\n    ax = ax\n```\nThis function is then used to plot the sales increase over time:\n\n```bash\nplotar('Aumento das vendas da Alucar de 2017 e 2018', 'Tempo', 'Aumento', 'mes', 'aumento', alucar)\n```\n\n### 7. Calculating Acceleration of Sales Increase\nTo analyze the acceleration of sales increases, we calculate the second derivative (change in increase):\n\n```bash\nalucar['aceleracao'] = alucar['aumento'].diff()\nThis is visualized using the same plotar() function:\n```\n```bash\nplotar('Aceleração das vendas da Alucar de 2017 e 2018', 'Tempo', 'Aceleração', 'mes', 'aceleracao', alucar)\n```\n\n## Results\nThe analysis helps to understand the monthly trends, increases, and acceleration in the sales data. Visualizations provide insights into how Alucar's sales have grown over time and how the growth rate has changed.\n\n## Conclusion\nThis project demonstrates a simple yet effective analysis of time series sales data using Python, pandas, and seaborn. The techniques covered include data cleaning, trend visualization, and calculating the rate of change (increase and acceleration) in the data.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsofiasawczenko%2Fsales_time_series_analysis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsofiasawczenko%2Fsales_time_series_analysis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsofiasawczenko%2Fsales_time_series_analysis/lists"}