├── Excel_Report ├── Excel_Report.ipynb ├── Excel_Report_Refactored.py ├── app.py ├── category_chart.html ├── category_report.xlsx └── data │ ├── data1.xlsx │ ├── data2.xlsx │ └── data3.xlsx ├── README.md └── SQL_Example ├── sales.db ├── sales_by_products.sql └── sales_db_schema.png /Excel_Report/Excel_Report.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "01c4299a-b366-40b8-9d95-17f0779737cf", 6 | "metadata": {}, 7 | "source": [ 8 | "# Python and Excel: Generating Excel Reports" 9 | ] 10 | }, 11 | { 12 | "cell_type": "markdown", 13 | "id": "3cc2294c-05d1-4310-9d57-8130a869a3b1", 14 | "metadata": {}, 15 | "source": [ 16 | "## Here is the game plan:" 17 | ] 18 | }, 19 | { 20 | "cell_type": "markdown", 21 | "id": "fb83547a-6da2-484d-b8d6-bcf4d61a8510", 22 | "metadata": { 23 | "heading_collapsed": true 24 | }, 25 | "source": [ 26 | "### Before we start: Provide context" 27 | ] 28 | }, 29 | { 30 | "cell_type": "markdown", 31 | "id": "707ef806-d8b7-49d0-9de0-61988da72ba7", 32 | "metadata": { 33 | "hidden": true 34 | }, 35 | "source": [ 36 | "> As a data analyst, I need your help with Python. \n", 37 | " Please provide efficient, readable, and pythonic code that follows best practices.\n", 38 | " Here is your first task in angled brackets:" 39 | ] 40 | }, 41 | { 42 | "cell_type": "markdown", 43 | "id": "3b5b3c9e-3989-4581-8aed-f7b9516b9ab1", 44 | "metadata": { 45 | "heading_collapsed": true 46 | }, 47 | "source": [ 48 | "### Step 1: Data Collection and Consolidation" 49 | ] 50 | }, 51 | { 52 | "cell_type": "markdown", 53 | "id": "54090a17-5733-4e68-804e-23aa73160009", 54 | "metadata": { 55 | "hidden": true 56 | }, 57 | "source": [ 58 | "> Write a Python script using pandas to combine data from multiple Excel spreadsheets located in the \"data\" folder. The spreadsheets have columns for \"Date\", \"Category\", \"Revenue\", and \"Expenses\"." 59 | ] 60 | }, 61 | { 62 | "cell_type": "markdown", 63 | "id": "1146c3a7-f847-4e9c-8c8b-93d39d12e24a", 64 | "metadata": { 65 | "heading_collapsed": true 66 | }, 67 | "source": [ 68 | "### Step 2: Data Cleaning and Preparation" 69 | ] 70 | }, 71 | { 72 | "cell_type": "markdown", 73 | "id": "60b5abc4-e406-4aff-84d5-974f1e8704eb", 74 | "metadata": { 75 | "hidden": true 76 | }, 77 | "source": [ 78 | "> Clean the consolidated data by removing duplicates and handling missing values" 79 | ] 80 | }, 81 | { 82 | "cell_type": "markdown", 83 | "id": "8bf9b3b0-f780-4287-bc02-b8fb68a794f4", 84 | "metadata": { 85 | "heading_collapsed": true 86 | }, 87 | "source": [ 88 | "### Step 3: Data Analysis and Calculations" 89 | ] 90 | }, 91 | { 92 | "cell_type": "markdown", 93 | "id": "c63f9acb-d0c1-4d29-b15c-82e1c1284c7a", 94 | "metadata": { 95 | "hidden": true 96 | }, 97 | "source": [ 98 | "> Using the cleaned data, calculate the total revenue, expenses, and profit for each category" 99 | ] 100 | }, 101 | { 102 | "cell_type": "markdown", 103 | "id": "08b449c8-69f2-46e3-80b7-8cb6f3179ef0", 104 | "metadata": { 105 | "heading_collapsed": true 106 | }, 107 | "source": [ 108 | "### Step 4: Generating Excel Report" 109 | ] 110 | }, 111 | { 112 | "cell_type": "markdown", 113 | "id": "563fe8a6-60be-4d5e-bdd4-dc3fa9ba6f6a", 114 | "metadata": { 115 | "hidden": true 116 | }, 117 | "source": [ 118 | "> Create an Excel report with a chart representing the total revenue, expenses, and profit by category using xlsxwriter" 119 | ] 120 | }, 121 | { 122 | "cell_type": "markdown", 123 | "id": "2953436c", 124 | "metadata": { 125 | "heading_collapsed": true 126 | }, 127 | "source": [ 128 | "## Let's Code:" 129 | ] 130 | }, 131 | { 132 | "cell_type": "code", 133 | "execution_count": 7, 134 | "id": "641801e5", 135 | "metadata": { 136 | "hidden": true 137 | }, 138 | "outputs": [], 139 | "source": [ 140 | "import xlsxwriter" 141 | ] 142 | }, 143 | { 144 | "cell_type": "code", 145 | "execution_count": 4, 146 | "id": "3543cc3b", 147 | "metadata": { 148 | "hidden": true 149 | }, 150 | "outputs": [ 151 | { 152 | "name": "stdout", 153 | "output_type": "stream", 154 | "text": [ 155 | " Date Category Revenue Expenses Source\n", 156 | "0 2021-01-01 A 1000 500 data1.xlsx\n", 157 | "1 2021-01-02 B 1500 800 data1.xlsx\n", 158 | "2 2021-01-03 C 1200 600 data1.xlsx\n", 159 | "3 2021-01-04 A 900 450 data1.xlsx\n", 160 | "4 2021-01-05 B 1600 850 data1.xlsx\n", 161 | "5 2021-01-06 C 1100 550 data2.xlsx\n", 162 | "6 2021-01-07 A 950 475 data2.xlsx\n", 163 | "7 2021-01-08 B 1400 700 data2.xlsx\n", 164 | "8 2021-01-09 C 1300 650 data2.xlsx\n", 165 | "9 2021-01-10 A 1000 500 data2.xlsx\n", 166 | "10 2021-01-11 B 1550 775 data3.xlsx\n", 167 | "11 2021-01-12 C 1250 625 data3.xlsx\n", 168 | "12 2021-01-13 A 1100 550 data3.xlsx\n", 169 | "13 2021-01-14 B 1450 725 data3.xlsx\n", 170 | "14 2021-01-15 C 1350 675 data3.xlsx\n" 171 | ] 172 | } 173 | ], 174 | "source": [ 175 | "import pandas as pd\n", 176 | "import os\n", 177 | "\n", 178 | "# Define the path to the data folder\n", 179 | "data_folder = 'data'\n", 180 | "\n", 181 | "# Get a list of all the Excel files in the data folder\n", 182 | "excel_files = [f for f in os.listdir(data_folder) if f.endswith('.xlsx')]\n", 183 | "\n", 184 | "# Create an empty dataframe to hold the combined data\n", 185 | "combined_data = pd.DataFrame()\n", 186 | "\n", 187 | "# Loop through each Excel file and append its data to the combined_data dataframe\n", 188 | "for file in excel_files:\n", 189 | " # Load the Excel file into a dataframe\n", 190 | " df = pd.read_excel(os.path.join(data_folder, file))\n", 191 | " \n", 192 | " # Add a column to the dataframe to indicate the source file\n", 193 | " df['Source'] = file\n", 194 | " \n", 195 | " # Append the data to the combined_data dataframe\n", 196 | " combined_data = combined_data.append(df, ignore_index=True)\n", 197 | "\n", 198 | "# Print the combined data\n", 199 | "print(combined_data)\n" 200 | ] 201 | }, 202 | { 203 | "cell_type": "code", 204 | "execution_count": 5, 205 | "id": "df0e02f1", 206 | "metadata": { 207 | "hidden": true 208 | }, 209 | "outputs": [ 210 | { 211 | "name": "stdout", 212 | "output_type": "stream", 213 | "text": [ 214 | " Date Category Revenue Expenses Source\n", 215 | "0 2021-01-01 A 1000 500 data1.xlsx\n", 216 | "1 2021-01-02 B 1500 800 data1.xlsx\n", 217 | "2 2021-01-03 C 1200 600 data1.xlsx\n", 218 | "3 2021-01-04 A 900 450 data1.xlsx\n", 219 | "4 2021-01-05 B 1600 850 data1.xlsx\n", 220 | "5 2021-01-06 C 1100 550 data2.xlsx\n", 221 | "6 2021-01-07 A 950 475 data2.xlsx\n", 222 | "7 2021-01-08 B 1400 700 data2.xlsx\n", 223 | "8 2021-01-09 C 1300 650 data2.xlsx\n", 224 | "9 2021-01-10 A 1000 500 data2.xlsx\n", 225 | "10 2021-01-11 B 1550 775 data3.xlsx\n", 226 | "11 2021-01-12 C 1250 625 data3.xlsx\n", 227 | "12 2021-01-13 A 1100 550 data3.xlsx\n", 228 | "13 2021-01-14 B 1450 725 data3.xlsx\n", 229 | "14 2021-01-15 C 1350 675 data3.xlsx\n" 230 | ] 231 | } 232 | ], 233 | "source": [ 234 | "# Drop duplicate rows\n", 235 | "combined_data.drop_duplicates(inplace=True)\n", 236 | "\n", 237 | "# Handle missing values\n", 238 | "combined_data.dropna(inplace=True)\n", 239 | "\n", 240 | "# Print the cleaned data\n", 241 | "print(combined_data)" 242 | ] 243 | }, 244 | { 245 | "cell_type": "code", 246 | "execution_count": 6, 247 | "id": "e264e541", 248 | "metadata": { 249 | "hidden": true 250 | }, 251 | "outputs": [ 252 | { 253 | "name": "stdout", 254 | "output_type": "stream", 255 | "text": [ 256 | " Revenue Expenses Profit\n", 257 | "Category \n", 258 | "A 4950 2475 2475\n", 259 | "B 7500 3850 3650\n", 260 | "C 6200 3100 3100\n" 261 | ] 262 | } 263 | ], 264 | "source": [ 265 | "# Calculate total revenue, expenses, and profit for each category\n", 266 | "category_data = combined_data.groupby('Category').agg({'Revenue': 'sum', 'Expenses': 'sum'})\n", 267 | "category_data['Profit'] = category_data['Revenue'] - category_data['Expenses']\n", 268 | "\n", 269 | "# Print the category data\n", 270 | "print(category_data)" 271 | ] 272 | }, 273 | { 274 | "cell_type": "code", 275 | "execution_count": 8, 276 | "id": "f5ea603f", 277 | "metadata": { 278 | "hidden": true 279 | }, 280 | "outputs": [ 281 | { 282 | "name": "stdout", 283 | "output_type": "stream", 284 | "text": [ 285 | "Report saved to category_report.xlsx.\n" 286 | ] 287 | } 288 | ], 289 | "source": [ 290 | "# Create an Excel report\n", 291 | "report_name = 'category_report.xlsx'\n", 292 | "workbook = xlsxwriter.Workbook(report_name)\n", 293 | "worksheet = workbook.add_worksheet()\n", 294 | "\n", 295 | "# Write the category data to the report\n", 296 | "worksheet.write(0, 0, 'Category')\n", 297 | "worksheet.write(0, 1, 'Revenue')\n", 298 | "worksheet.write(0, 2, 'Expenses')\n", 299 | "worksheet.write(0, 3, 'Profit')\n", 300 | "\n", 301 | "row = 1\n", 302 | "for index, row_data in category_data.iterrows():\n", 303 | " worksheet.write(row, 0, index)\n", 304 | " worksheet.write(row, 1, row_data['Revenue'])\n", 305 | " worksheet.write(row, 2, row_data['Expenses'])\n", 306 | " worksheet.write(row, 3, row_data['Profit'])\n", 307 | " row += 1\n", 308 | "\n", 309 | "# Create a chart representing the data\n", 310 | "chart = workbook.add_chart({'type': 'column'})\n", 311 | "\n", 312 | "chart.add_series({\n", 313 | " 'name': 'Revenue',\n", 314 | " 'categories': ['Sheet1', 1, 0, row - 1, 0],\n", 315 | " 'values': ['Sheet1', 1, 1, row - 1, 1],\n", 316 | "})\n", 317 | "\n", 318 | "chart.add_series({\n", 319 | " 'name': 'Expenses',\n", 320 | " 'categories': ['Sheet1', 1, 0, row - 1, 0],\n", 321 | " 'values': ['Sheet1', 1, 2, row - 1, 2],\n", 322 | "})\n", 323 | "\n", 324 | "chart.add_series({\n", 325 | " 'name': 'Profit',\n", 326 | " 'categories': ['Sheet1', 1, 0, row - 1, 0],\n", 327 | " 'values': ['Sheet1', 1, 3, row - 1, 3],\n", 328 | "})\n", 329 | "\n", 330 | "chart.set_title({'name': 'Total Revenue, Expenses, and Profit by Category'})\n", 331 | "chart.set_x_axis({'name': 'Category'})\n", 332 | "chart.set_y_axis({'name': 'Amount'})\n", 333 | "chart.set_legend({'position': 'bottom'})\n", 334 | "\n", 335 | "worksheet.insert_chart('E1', chart)\n", 336 | "\n", 337 | "# Close the workbook\n", 338 | "workbook.close()\n", 339 | "\n", 340 | "print(f'Report saved to {report_name}.')" 341 | ] 342 | }, 343 | { 344 | "cell_type": "code", 345 | "execution_count": 9, 346 | "id": "84c02b13", 347 | "metadata": { 348 | "hidden": true 349 | }, 350 | "outputs": [ 351 | { 352 | "name": "stdout", 353 | "output_type": "stream", 354 | "text": [ 355 | "Chart saved to category_chart.html.\n" 356 | ] 357 | } 358 | ], 359 | "source": [ 360 | "import pandas as pd\n", 361 | "import os\n", 362 | "import plotly.express as px\n", 363 | "\n", 364 | "# Define the path to the data folder\n", 365 | "data_folder = 'data'\n", 366 | "\n", 367 | "# Get a list of all the Excel files in the data folder\n", 368 | "excel_files = [f for f in os.listdir(data_folder) if f.endswith('.xlsx')]\n", 369 | "\n", 370 | "# Create an empty dataframe to hold the combined data\n", 371 | "combined_data = pd.DataFrame()\n", 372 | "\n", 373 | "# Loop through each Excel file and append its data to the combined_data dataframe\n", 374 | "for file in excel_files:\n", 375 | " # Load the Excel file into a dataframe\n", 376 | " df = pd.read_excel(os.path.join(data_folder, file))\n", 377 | " \n", 378 | " # Add a column to the dataframe to indicate the source file\n", 379 | " df['Source'] = file\n", 380 | " \n", 381 | " # Append the data to the combined_data dataframe\n", 382 | " combined_data = combined_data.append(df, ignore_index=True)\n", 383 | "\n", 384 | "# Drop duplicate rows\n", 385 | "combined_data.drop_duplicates(inplace=True)\n", 386 | "\n", 387 | "# Handle missing values\n", 388 | "combined_data.dropna(inplace=True)\n", 389 | "\n", 390 | "# Calculate total revenue, expenses, and profit for each category\n", 391 | "category_data = combined_data.groupby('Category').agg({'Revenue': 'sum', 'Expenses': 'sum'})\n", 392 | "category_data['Profit'] = category_data['Revenue'] - category_data['Expenses']\n", 393 | "\n", 394 | "# Create an interactive chart using Plotly\n", 395 | "fig = px.bar(category_data, x=category_data.index, y=['Revenue', 'Expenses', 'Profit'], barmode='group', title='Total Revenue, Expenses, and Profit by Category')\n", 396 | "\n", 397 | "# Save the chart as an HTML file\n", 398 | "chart_name = 'category_chart.html'\n", 399 | "fig.write_html(chart_name)\n", 400 | "\n", 401 | "print(f'Chart saved to {chart_name}.')\n" 402 | ] 403 | } 404 | ], 405 | "metadata": { 406 | "kernelspec": { 407 | "display_name": "Python 3 (ipykernel)", 408 | "language": "python", 409 | "name": "python3" 410 | }, 411 | "language_info": { 412 | "codemirror_mode": { 413 | "name": "ipython", 414 | "version": 3 415 | }, 416 | "file_extension": ".py", 417 | "mimetype": "text/x-python", 418 | "name": "python", 419 | "nbconvert_exporter": "python", 420 | "pygments_lexer": "ipython3", 421 | "version": "3.11.1" 422 | } 423 | }, 424 | "nbformat": 4, 425 | "nbformat_minor": 5 426 | } 427 | -------------------------------------------------------------------------------- /Excel_Report/Excel_Report_Refactored.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | import xlsxwriter 3 | from pathlib import Path 4 | 5 | 6 | def load_excel_files(folder): 7 | """Load all Excel files in a folder into a list of dataframes""" 8 | excel_files = list(folder.glob('*.xlsx')) 9 | return [pd.read_excel(file) for file in excel_files] 10 | 11 | 12 | def combine_dataframes(dataframes): 13 | """Combine multiple dataframes into a single dataframe""" 14 | combined_data = pd.concat(dataframes) 15 | return combined_data.drop_duplicates().dropna() 16 | 17 | 18 | def calculate_category_data(combined_data): 19 | """Calculate total revenue, expenses, and profit for each category""" 20 | category_data = combined_data.groupby('Category').agg({'Revenue': 'sum', 'Expenses': 'sum'}) 21 | category_data['Profit'] = category_data['Revenue'] - category_data['Expenses'] 22 | return category_data 23 | 24 | 25 | def create_category_report(category_data, report_name): 26 | """Create an Excel report summarizing category data""" 27 | workbook = xlsxwriter.Workbook(report_name) 28 | worksheet = workbook.add_worksheet() 29 | 30 | # Write the category data to the report 31 | worksheet.write_row(0, 0, ['Category', 'Revenue', 'Expenses', 'Profit']) 32 | for i, (index, row_data) in enumerate(category_data.iterrows()): 33 | worksheet.write_row(i+1, 0, [index, row_data['Revenue'], row_data['Expenses'], row_data['Profit']]) 34 | 35 | # Create a chart representing the data 36 | chart = workbook.add_chart({'type': 'column'}) 37 | chart.add_series({ 38 | 'name': 'Revenue', 39 | 'categories': ['Sheet1', 1, 0, len(category_data), 0], 40 | 'values': ['Sheet1', 1, 1, len(category_data), 1], 41 | }) 42 | chart.add_series({ 43 | 'name': 'Expenses', 44 | 'categories': ['Sheet1', 1, 0, len(category_data), 0], 45 | 'values': ['Sheet1', 1, 2, len(category_data), 2], 46 | }) 47 | chart.add_series({ 48 | 'name': 'Profit', 49 | 'categories': ['Sheet1', 1, 0, len(category_data), 0], 50 | 'values': ['Sheet1', 1, 3, len(category_data), 3], 51 | }) 52 | chart.set_title({'name': 'Total Revenue, Expenses, and Profit by Category'}) 53 | chart.set_x_axis({'name': 'Category'}) 54 | chart.set_y_axis({'name': 'Amount'}) 55 | chart.set_legend({'position': 'bottom'}) 56 | worksheet.insert_chart('E1', chart) 57 | 58 | # Close the workbook 59 | workbook.close() 60 | print(f'Report saved to {report_name}.') 61 | 62 | 63 | if __name__ == '__main__': 64 | data_folder = Path('data') 65 | excel_dataframes = load_excel_files(data_folder) 66 | combined_data = combine_dataframes(excel_dataframes) 67 | category_data = calculate_category_data(combined_data) 68 | create_category_report(category_data, 'category_report.xlsx') -------------------------------------------------------------------------------- /Excel_Report/app.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | import os 3 | import plotly.express as px 4 | import streamlit as st 5 | 6 | # Define the path to the data folder 7 | data_folder = 'data' 8 | 9 | # Get a list of all the Excel files in the data folder 10 | excel_files = [f for f in os.listdir(data_folder) if f.endswith('.xlsx')] 11 | 12 | # Create an empty dataframe to hold the combined data 13 | combined_data = pd.DataFrame() 14 | 15 | # Loop through each Excel file and append its data to the combined_data dataframe 16 | for file in excel_files: 17 | # Load the Excel file into a dataframe 18 | df = pd.read_excel(os.path.join(data_folder, file)) 19 | 20 | # Add a column to the dataframe to indicate the source file 21 | df['Source'] = file 22 | 23 | # Append the data to the combined_data dataframe 24 | combined_data = combined_data.append(df, ignore_index=True) 25 | 26 | # Drop duplicate rows 27 | combined_data.drop_duplicates(inplace=True) 28 | 29 | # Handle missing values 30 | combined_data.dropna(inplace=True) 31 | 32 | # Calculate total revenue, expenses, and profit for each category 33 | category_data = combined_data.groupby('Category').agg({'Revenue': 'sum', 'Expenses': 'sum'}) 34 | category_data['Profit'] = category_data['Revenue'] - category_data['Expenses'] 35 | 36 | # Create a Streamlit dashboard 37 | st.set_page_config(page_title='Total Revenue, Expenses, and Profit by Category', page_icon=':chart_with_upwards_trend:') 38 | st.title('Total Revenue, Expenses, and Profit by Category') 39 | st.subheader('Grouped Data') 40 | 41 | # Create an interactive chart using Plotly and display it in the dashboard 42 | fig = px.bar(category_data, x=category_data.index, y=['Revenue', 'Expenses', 'Profit'], barmode='group') 43 | st.plotly_chart(fig) 44 | -------------------------------------------------------------------------------- /Excel_Report/category_report.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sven-Bo/Practical-Examples-for-Using-ChatGPT-in-Data-Analysis/c14eaa8cae18602582d9776f4fe5473d66ac3b7f/Excel_Report/category_report.xlsx -------------------------------------------------------------------------------- /Excel_Report/data/data1.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sven-Bo/Practical-Examples-for-Using-ChatGPT-in-Data-Analysis/c14eaa8cae18602582d9776f4fe5473d66ac3b7f/Excel_Report/data/data1.xlsx -------------------------------------------------------------------------------- /Excel_Report/data/data2.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sven-Bo/Practical-Examples-for-Using-ChatGPT-in-Data-Analysis/c14eaa8cae18602582d9776f4fe5473d66ac3b7f/Excel_Report/data/data2.xlsx -------------------------------------------------------------------------------- /Excel_Report/data/data3.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sven-Bo/Practical-Examples-for-Using-ChatGPT-in-Data-Analysis/c14eaa8cae18602582d9776f4fe5473d66ac3b7f/Excel_Report/data/data3.xlsx -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # How I Use ChatGPT as a Data Analyst 📊 2 | In this video, I'll be sharing my experience using ChatGPT as a Data Analyst to make my work easier, from consolidating files and cleaning up data to diving deep into analysis. I'll show you how to put together Excel summary reports and charts using Python and PowerQuery, create eye-catching interactive HTML charts, whip up quick Streamlit dashboards, and generate SQL queries effortlessly. Come along as I share real-life examples and handy tips to help you get the most out of ChatGPT in your own data analysis journey. 3 | 4 | ## ChatGPT Prompts 5 | Links to the ChatGPT conversation history ⤵ 6 | - Excel Report: https://sharegpt.com/c/61O3GXq 7 | - Refactor Code & PowerQuery Steps: https://shareg.pt/mrVjAWd 8 | - SQL Generation: https://shareg.pt/1fWlHku 9 | 10 | ## Video Tutorial 11 | [![YouTube Video](https://img.youtube.com/vi/IAWMMi_VFOI/0.jpg)](https://youtu.be/IAWMMi_VFOI) 12 | 13 | 14 | 15 | 16 | ## 🤓 Check Out My Excel Add-ins 17 | I've developed some handy Excel add-ins that you might find useful: 18 | 19 | - 📊 **[Dashboard Add-in](https://pythonandvba.com/grafly)**: Easily create interactive and visually appealing dashboards. 20 | - 🎨 **[Cartoon Charts Add-In](https://pythonandvba.com/cuteplots)**: Create engaging and fun cartoon-style charts. 21 | - 🤪 **[Emoji Add-in](https://pythonandvba.com/emojify)**: Add a touch of fun to your spreadsheets with emojis. 22 | - 🛠️ **[MyToolBelt Add-in](https://pythonandvba.com/mytoolbelt)**: A versatile toolbelt for Excel, featuring: 23 | - Creation of Pandas DataFrames and Jupyter Notebooks from Excel ranges 24 | - ChatGPT integration for advanced data analysis 25 | - And much more! 26 | 27 | 28 | 29 | ## 🤝 Connect with Me 30 | - 📺 **YouTube:** [CodingIsFun](https://youtube.com/c/CodingIsFun) 31 | - 🌐 **Website:** [PythonAndVBA](https://pythonandvba.com) 32 | - 💬 **Discord:** [Join our Community](https://pythonandvba.com/discord) 33 | - 💼 **LinkedIn:** [Connect with me](https://www.linkedin.com/in/sven-bosau/) 34 | - 📸 **Instagram:** [Follow me](https://www.instagram.com/codingisfun_official/) 35 | 36 | ## Support My Work 37 | Love my content and want to show appreciation? Why not [buy me a coffee](https://pythonandvba.com/coffee-donation) to fuel my creative engine? Your support means the world to me! 😊 38 | 39 | [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://pythonandvba.com/coffee-donation) 40 | 41 | ## Feedback 42 | Got some thoughts or suggestions? Don't hesitate to reach out to me at contact@pythonandvba.com. I'd love to hear from you! 💡 43 | ![Logo](https://www.pythonandvba.com/banner-img) 44 | -------------------------------------------------------------------------------- /SQL_Example/sales.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sven-Bo/Practical-Examples-for-Using-ChatGPT-in-Data-Analysis/c14eaa8cae18602582d9776f4fe5473d66ac3b7f/SQL_Example/sales.db -------------------------------------------------------------------------------- /SQL_Example/sales_by_products.sql: -------------------------------------------------------------------------------- 1 | SELECT p.product_name, SUM(s.total_price) as total_sales 2 | FROM sales s 3 | JOIN products p ON s.product_id = p.product_id 4 | GROUP BY p.product_name 5 | ORDER BY total_sales DESC; -------------------------------------------------------------------------------- /SQL_Example/sales_db_schema.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sven-Bo/Practical-Examples-for-Using-ChatGPT-in-Data-Analysis/c14eaa8cae18602582d9776f4fe5473d66ac3b7f/SQL_Example/sales_db_schema.png --------------------------------------------------------------------------------