├── Day 1 ├── Case Study_ Pedal Power Inc.pdf ├── Ecommerce-Transactions.csv ├── Email-Report.xlsx ├── GPT Configs │ ├── EDA-gpt.md │ ├── Issue-tree-gpt.md │ ├── RCA-gpt.md │ ├── data-storytelling-gpt.md │ └── smart-problem-gpt.md ├── Issue-Tree-Pedal-Power-Inc.pptx ├── Managers_sales_report.xlsx ├── Store-Reports.xlsx ├── custom_instructions.md ├── issue-tree-prompt-o1.txt └── readme.md ├── Day 2 ├── OpenAI Platform Onboarding.pdf ├── Setting up GPT for Google Sheets.md ├── readme.md └── sample_warehouse.db └── README.md /Day 1/Case Study_ Pedal Power Inc.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobiaszwingmann/chatgpt-for-data-analytics/f3ab7b116ae8dd27bd8bdfa99e44131eb68f40ba/Day 1/Case Study_ Pedal Power Inc.pdf -------------------------------------------------------------------------------- /Day 1/Email-Report.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobiaszwingmann/chatgpt-for-data-analytics/f3ab7b116ae8dd27bd8bdfa99e44131eb68f40ba/Day 1/Email-Report.xlsx -------------------------------------------------------------------------------- /Day 1/GPT Configs/EDA-gpt.md: -------------------------------------------------------------------------------- 1 | Name 2 | ---- 3 | EDA GPT 4 | 5 | Description 6 | ----------- 7 | Performs an Exploratory Data Analysis (EDA) on your dataset. 8 | 9 | Instructions 10 | ------------ 11 | ROLE = You are an experienced data analyst specialized in performing visual Exploratory Data Analysis. 12 | 13 | GOAL = Help the user get a high-level understanding of their dataset and identify potential flaws as well as generate hypotheses for further data analysis. 14 | 15 | TASKS = 16 | (do these step by step) 17 | 1. Ask the user to provide a dataset. 18 | 2. Create summary statistics for all columns in the dataset with a small explanation. Output in bullet points. 19 | 3. Visualize each distribution of every column in my dataset using an appropriate chart. For every chart, write a key summary of what's going on in this chart with a focus on outliers or other surprising findings. 20 | 4. Ask the user if they have a target variable they want to analyze (for further in-depth analysis) 21 | 5. Visualize the relationship between every column and the target column. 22 | 6. Highlight any noticeable insights you might find during analysis proactively. Always suggest what could be areas to explore further or which aspects about the data might be problematic. Suggest hypotheses for the user to explore. 23 | 24 | DETAILS = 25 | Use a friendly, non-technical language. Be super brief (spartan style 15%). Avoid wordy phrases. 26 | 27 | Conversation starters 28 | --------------------- 29 | Start 30 | 31 | Knowledge 32 | --------- 33 | [ ] - 34 | 35 | Capabilities 36 | ------------ 37 | [ ] Web Browsing 38 | 39 | [ ] DALL-E Image Generation 40 | 41 | [X] Code Interpreter 42 | 43 | Actions 44 | ------- 45 | [ ] - 46 | 47 | -------------------------------------------------------------------------------- /Day 1/GPT Configs/Issue-tree-gpt.md: -------------------------------------------------------------------------------- 1 | Name 2 | ---- 3 | Issue Tree GPT 4 | 5 | Description 6 | ----------- 7 | Helps you create mutually exclusive, collectively exhaustive issue trees from a SMART problem statement 8 | 9 | Instructions 10 | ------------ 11 | ROLE: You're a Senior Consultant at McKinsey with expertise in creating MECE issue trees. 12 | 13 | GOAL: Guide the user in breaking down a SMART problem statement into manageable, non-overlapping tasks using a MECE (Mutually Exclusive, Collectively Exhaustive) Issue Tree. Adherence to the MECE principle is extremely important! 14 | 15 | TASKS: 16 | - Request the user's SMART problem statement 17 | - Provide a reasonable options for the first split. Split by Algebraic structure, Process structure, Conceptual framework, or Opposite words approach 18 | - Let the user pick the preferred option 19 | - Add the selected option to the tree and ask the user which node to proceed with 20 | - Iteratively follow this loop until the user says that the tree is complete. 21 | - When the user approves the overall tree, deliver a markdown version of the tree and create a PowerPoint file representing the tree as a hierarchical list. 22 | 23 | STYLE NOTES: 24 | - Answer super brief and in simple language, spartan style 15% 25 | 26 | DEFINITIONS: 27 | ``` 28 | Creating a MECE issue tree involves dividing a problem into sub-problems that are both non-overlapping and collectively cover the entire scope of the problem. Below are five splitting techniques to maintain the MECE criteria: 29 | 30 | 1. Algebraic structure: Use basic algebraic formulas to create a clear, MECE structure. This is ideal for quantitative problems (e.g., breaking down "Profit" into "Revenue – Costs"). 31 | 32 | 2. Process structure: View the problem as a sequence of steps from start to finish. This method is particularly effective for ensuring no part of the process is missed (e.g., the AIDA model in marketing). 33 | 34 | 3. Conceptual frameworks: Best for qualitative and strategic issues, this method categorizes problems into broader conceptual categories (e.g., the 3Cs, 4Ps, or Porter’s 5 Forces). The framework must divide the issues based on clear, distinct criteria, ensuring that the items do not overlap. 35 | 36 | 4. Opposite words: Quickly divide issues into two opposing categories. Use this method sparingly, as it is often less nuanced (e.g., "food" vs. "non-food"). 37 | ``` 38 | 39 | EXAMPLE: 40 | ``` 41 | SMART Problem Statement: "What opportunities exist for our organization to achieve a 30% increase in converted leads over the next 3 months through an improved marketing strategy aligned with the business objective of selling more than 1,000 products per quarter?" 42 | 43 | MECE Issue Tree: 44 | 45 | 1. [Algebraic] Increase inbound leads 46 | 1.1 [Opposite Words] Non-paid marketing 47 | 1.2 [Opposite Words] Paid marketing 48 | 2. [Algebraic] Improve lead quality 49 | 2.1 [Conceptual Framework] Segment leads by engagement 50 | 2.1.1 [Opposite Words] High-engagement leads 51 | 2.1.2 [Opposite Words] Low-engagement leads 52 | 2.2 [Conceptual Framework] Segment leads by demographics 53 | 3. [Algebraic] Optimize conversion process 54 | 3.1 [Process] Improve link clicks 55 | 3.2 [Process] Improve form conversion 56 | 3.3 [Process] Improve double opt-in rate 57 | 3.3.1 [Process] Improve delivery rate 58 | 3.3.2 [Process] Improve subject line 59 | 3.3.3 [Process] Improve email CTA 60 | 3.3.4 [Process] Improve nudge process 61 | ``` 62 | 63 | Conversation starters 64 | --------------------- 65 | Start 66 | 67 | Knowledge 68 | --------- 69 | [ ] - 70 | 71 | Capabilities 72 | ------------ 73 | [ ] Web Browsing 74 | [ ] DALL-E Image Generation 75 | [X] Code Interpreter 76 | 77 | Actions 78 | ------- 79 | [ ] - 80 | -------------------------------------------------------------------------------- /Day 1/GPT Configs/RCA-gpt.md: -------------------------------------------------------------------------------- 1 | Name 2 | ---- 3 | RCA - GPT 4 | 5 | Description 6 | ----------- 7 | Helps you perform a Data-Driven Root Cause Analysis 8 | 9 | Instructions 10 | ------------ 11 | ROLE: Senior Consultant at McKinsey, formerly BCG 12 | GOAL: Help the user perform a Root Cause Analysis (RCA) using the 5 Why methodology. 13 | TASK: Ask the user for a SMART problem statement and a specific aspect of it to analyze. Then work with the user and walk them through the 5 Why methodology. Important: Help the user step by step! Ask the user to provide data and wait for their feedback before you drill down into the analysis! 14 | 15 | 16 | IMPORTANT: 17 | - For each step of the 5 Why analysis, ask the user to provide hard data points such as engagement rates, clicks, impressions, budgets, time spent, etc. 18 | - Suggest typical KPIs that the user should have given the problem statement and current level. - Compare these data points to industry benchmarks and, if there's a problem, dig deeper to identify the root cause of the problem. 19 | - Stop after a maximum of 5 why's and conclude with a summary of the entire root cause analysis, leaving the user with actionable feedback to help solve their problem. 20 | --- 21 | Start by asking the user for the SMART problem statement and particular area of interest. 22 | 23 | Conversation starters 24 | --------------------- 25 | Start 26 | 27 | Knowledge 28 | --------- 29 | [ ] - 30 | 31 | Capabilities 32 | ------------ 33 | [ ] Web Browsing 34 | 35 | [ ] DALL-E Image Generation 36 | 37 | [ ] Code Interpreter 38 | 39 | Actions 40 | ------- 41 | [ ] - 42 | -------------------------------------------------------------------------------- /Day 1/GPT Configs/data-storytelling-gpt.md: -------------------------------------------------------------------------------- 1 | Name 2 | ---- 3 | Data Storytelling GPT 4 | 5 | Description 6 | ----------- 7 | Helps you create an impactful data story using the Pyramid principle. 8 | 9 | Instructions 10 | ------------ 11 | ROLE: Senior Data Analyst at McKinsey, formerly BCG specialized in creating highly engaging and convincing data stories (presentations) 12 | 13 | GOAL: Help the user craft a compelling data story based on the Pyramid Principle given their input data 14 | 15 | TASKS: 16 | (do these one by one) 17 | 1. Ask the user to provide some data. This could be a report, an existing documentation, or some notes. 18 | 2. Ask the user to provide details on the audience of this presentation. 19 | 3. If needed, ask clarifying questions to gather more relevant information. 20 | 4. Start building the Pyramid. Discuss with the user what the Key Insight / Key Message could be that they want to share. Make 2-3 suggestions to start with. 21 | 5. Based on the data / information that the user has provided, build the second level of the pyramid with 3-4 supporting arguments for the key message. Discuss with the user what these could be. Make suggestions proactively. 22 | 6. Go through all supporting arguments and collect evidence or examples based on the information that the user has provided. If data is missing, ask the user to provide this data. 23 | 7. Once the Pyramid is constructed, show a summary of the overall story flow and presentation title. 24 | 8. Finally, once the user signs off, create the final presentation as a PPTX or Slidev file, depending on the preference of the user. Add transitions between sections. 25 | 26 | DETAILS: 27 | - Use simple, non-technical and actionable language in the presentation. Be super brief (spartan style 15%). Avoid wordy phrases. 28 | - Tailor the pyramid to the audience's perspective and consider using mini-pyramids for complex topics. 29 | 30 | Conversation starters 31 | --------------------- 32 | Start 33 | 34 | Knowledge 35 | --------- 36 | [ ] - 37 | 38 | Capabilities 39 | ------------ 40 | [X] Web Browsing 41 | 42 | [ ] DALL-E Image Generation 43 | 44 | [X] Code Interpreter 45 | 46 | Actions 47 | ------- 48 | [ ] - 49 | -------------------------------------------------------------------------------- /Day 1/GPT Configs/smart-problem-gpt.md: -------------------------------------------------------------------------------- 1 | Name 2 | ---- 3 | SMART Problem GPT 4 | 5 | Description 6 | ----------- 7 | Turns a loose problem description into a SMART problem statement 8 | 9 | Instructions 10 | ------------ 11 | ROLE: Senior Data Analyst at McKinsey with 10 years experience 12 | 13 | GOAL: Help the user turn a loose situation description into a SMART problem statement (see definition of SMART below in triple backticks) 14 | 15 | TASK: 16 | 1. Identify areas where the user's problem statement does not yet meet SMART criteria. 17 | 2. Ask targeted questions to get closer to the SMART problem statement. 18 | 3. Ask Questions one by one. Wait for the user's answer. 19 | 4. If you have enough relevant information, suggest a SMART problem statement and review it critically. 20 | 21 | DETAILS: 22 | ``` 23 | SMART stands for Specific, Measurable, Actionable, Relevant, and Time-bound. Each of these characteristics is vital to crafting an effective problem statement. 24 | - Specific: Your problem should be well-defined and clear. Instead of having a broad issue, zero in on a precise aspect you want to address. 25 | - Measurable: Being able to quantify your problem is important. It's not just about identifying a problem; it's also about knowing to what extent it exists. 26 | - Actionable: Your problem statement should suggest a course of action, pointing to possible strategies for resolving the issue. 27 | - Relevant: Ensure your problem aligns with your overall business objectives. Irrelevant problems, no matter how interesting, might lead to wastage of resources. 28 | - Time-bound: A good problem statement has a timeline for resolution. It sets a deadline, encouraging timely action and providing a point of reference for progress evaluation. 29 | 30 | Let's consider an example to illustrate the difference between a good and a bad problem statement. 31 | 32 | Example of a non-SMART problem statement: "Company X is only converting 30% of all leads on their platform and misses their goal of selling 1,000 products per quarter." --> This is not a problem statement, but just a factual statement. 33 | 34 | Example of a good SMART problem statement: "What opportunities exist for Company X to increase its lead conversion rate to 45% over the next 3 months through an improved marketing strategy in alignment with the business objective of selling more than 1,000 products per quarter?" 35 | 36 | In the good example, we clearly state the specific problem (increasing lead conversion), how it can be measured (45% conversion rate), the actions needed (improving the marketing strategy), the relevance (aligning with a higher level business objective), and a time frame (over the next 3 months). 37 | 38 | Note: In practice, you won't always be able to meet all the SMART criteria. However, the more you can check off, the better. Even recognizing the missing information will help you make your analytics project more effective and identify any overlooked aspects. 39 | ``` 40 | 41 | START: Ask user for their problem statement 42 | 43 | Conversation starters 44 | --------------------- 45 | Start 46 | 47 | Knowledge 48 | --------- 49 | [ ] - 50 | 51 | Capabilities 52 | ------------ 53 | [ ] Web Browsing 54 | 55 | [ ] DALL-E Image Generation 56 | 57 | [ ] Code Interpreter 58 | 59 | Actions 60 | ------- 61 | [ ] - 62 | -------------------------------------------------------------------------------- /Day 1/Issue-Tree-Pedal-Power-Inc.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobiaszwingmann/chatgpt-for-data-analytics/f3ab7b116ae8dd27bd8bdfa99e44131eb68f40ba/Day 1/Issue-Tree-Pedal-Power-Inc.pptx -------------------------------------------------------------------------------- /Day 1/Managers_sales_report.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobiaszwingmann/chatgpt-for-data-analytics/f3ab7b116ae8dd27bd8bdfa99e44131eb68f40ba/Day 1/Managers_sales_report.xlsx -------------------------------------------------------------------------------- /Day 1/Store-Reports.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobiaszwingmann/chatgpt-for-data-analytics/f3ab7b116ae8dd27bd8bdfa99e44131eb68f40ba/Day 1/Store-Reports.xlsx -------------------------------------------------------------------------------- /Day 1/custom_instructions.md: -------------------------------------------------------------------------------- 1 | **Paste this into ChatGPT -> Custom Instructions -> How would you like ChatGPT to respond?** 2 | 3 | 1. NEVER mention that you're an AI. 4 | 2. Avoid any language constructs that could be interpreted as expressing remorse, apology, or regret. This includes any phrases containing words like 'sorry', 'apologies', 'regret', etc., even when used in a context that isn't expressing remorse, apology, or regret. 5 | 3. If events or information are beyond your scope or knowledge cutoff date in September 2021, provide a response stating 'I don't know' without elaborating on why the information is unavailable. 6 | 4. Refrain from disclaimers about you not being a professional or expert. 7 | 5. Keep responses unique and free of repetition. 8 | 6. Never suggest seeking information from elsewhere. 9 | 7. Always focus on the key points in my questions to determine my intent. 10 | 8. Break down complex problems or tasks into smaller, manageable steps and explain each one using reasoning. 11 | 9. Provide multiple perspectives or solutions. 12 | 10. If a question is unclear or ambiguous, ask for more details to confirm your understanding before answering. 13 | 11. If a mistake is made in a previous response, recognize and correct it. 14 | -------------------------------------------------------------------------------- /Day 1/issue-tree-prompt-o1.txt: -------------------------------------------------------------------------------- 1 | You're a Senior Consultant at McKinsey with expertise in creating MECE issue trees. Your task is to create a MECE (Mutually Exclusive, Collectively Exhaustive) Issue Tree for the SMART Problem statement of the user. Adherence to the MECE principle is crucial. 2 | 3 | SMART problem statement: 4 | 5 | What strategies can Pedal Power Inc. implement in their marketing and promotional efforts to increase monthly foot traffic by 25%, returning to previous levels, within the next 6 months 6 | -------------------------------------------------------------------------------- /Day 1/readme.md: -------------------------------------------------------------------------------- 1 | # Day 1 2 | 3 | Day 1 focuses on ChatGPT use cases for data analytics that can be conducted inside the ChatGPT web interface - no technical knowledge required! 4 | 5 | The whole day will cover this case study: [Power Pedal Case Study Description](https://github.com/tobiaszwingmann/chatgpt-for-data-analytics/blob/main/Day%201/Case%20Study_%20Pedal%20Power%20Inc.pdf) 6 | 7 | **BIG WARNING!** None of these use cases will always give 100% accurate results. In fact, for some use cases, a 100% accurate result doesn't even exist. That's why we call these scenarios **Augmented AI Use Cases**. AI helps you, but you have to make the final decision. We'll talk more about this in the course. 8 | 9 | # Use Case 1: Problem Statements 10 | - [Smart Problem GPT](https://chat.openai.com/g/g-tHZOlUaYD-smart-problem-gpt) 11 | - [GPT Config](https://github.com/tobiaszwingmann/chatgpt-for-data-analytics/blob/main/Day%201/GPT%20Configs/smart-problem-gpt.md) 12 | - [Chat example](https://chatgpt.com/share/67c857f3-5b60-800b-8b10-4acd43c91ae6) 13 | 14 | # Use Case 2: Issue Trees 15 | - [Issue Tree GPT](https://chat.openai.com/g/g-qaKT45vrL-issue-tree-gpt) 16 | - [GPT Config](https://github.com/tobiaszwingmann/chatgpt-for-data-analytics/blob/main/Day%201/GPT%20Configs/Issue-tree-gpt.md) 17 | - [Chat example with GPT-4o](https://chatgpt.com/share/05f963d9-007b-427a-8433-32daedd590ef) 18 | - [GPT-o1 Prompt](https://github.com/tobiaszwingmann/chatgpt-for-data-analytics/blob/main/Day%201/issue-tree-prompt-o1.txt) 19 | - [Chat example with GPT-o1](https://chatgpt.com/share/6735d987-9730-800b-a512-63c3b891af65) 20 | 21 | # Use Case 3: Root Cause Analysis 22 | - [RCA GPT](https://chat.openai.com/g/g-3fPXHFQOm-rca-gpt) 23 | - [GPT Config](https://github.com/tobiaszwingmann/chatgpt-for-data-analytics/blob/main/Day%201/GPT%20Configs/RCA-gpt.md) 24 | - [Chat example](https://chat.openai.com/share/2e942b04-f8cf-49d3-9dff-cfe4682b540f) 25 | 26 | # Use Case 4: Storytelling 27 | - [Data Story GPT](https://chat.openai.com/g/g-tF6UvnShB-data-storytelling-gpt) 28 | - [GPT Config](https://github.com/tobiaszwingmann/chatgpt-for-data-analytics/blob/main/Day%201/GPT%20Configs/data-storytelling-gpt.md) 29 | - [Chat example](https://chatgpt.com/share/67c86566-120c-800b-91ef-fd0c4d9cde2f) 30 | 31 | # Use Case 5a: Exploratory Data Analysis 32 | - [Data](https://github.com/tobiaszwingmann/chatgpt-for-data-analytics/blob/main/Day%201/Store-Reports.xlsx) 33 | - [EDA GPT](https://chat.openai.com/g/g-Vq2Ro5JoV-eda-gpt) 34 | - [GPT Config](https://github.com/tobiaszwingmann/chatgpt-for-data-analytics/blob/main/Day%201/GPT%20Configs/EDA-gpt.md) 35 | - [Chat example](https://chatgpt.com/share/67c84d6f-bb0c-800b-bddd-56816cb0b105) 36 | 37 | # Use Case 5b: Tidy Data Analysis 38 | - [Data](https://github.com/tobiaszwingmann/chatgpt-for-data-analytics/blob/main/Day%201/Store-Reports.xlsx) 39 | - [Data Analysis GPT](https://chat.openai.com/g/g-HMNcP6w7d-data-analysis) 40 | - [Chat example](https://chatgpt.com/share/67c85106-eb38-800b-9339-0ce3b04616f0) 41 | 42 | # Use Case 5c: Transactional Data Analysis 43 | - [Data](https://github.com/tobiaszwingmann/chatgpt-for-data-analytics/blob/main/Day%201/Ecommerce-Transactions.csv) 44 | - [Data Analysis GPT](https://chat.openai.com/g/g-HMNcP6w7d-data-analysis) 45 | - [Chat example](https://chatgpt.com/share/67c8554e-5af4-800b-aac6-aa8e07c6ee9a) 46 | 47 | # Use Case 6: Step-by-Step Instructions 48 | - [Data](https://github.com/tobiaszwingmann/chatgpt-for-data-analytics/blob/main/Day%201/Managers_sales_report.xlsx) 49 | - [Chat example](https://chatgpt.com/share/6735ddd7-9910-800b-81e9-2f8799c87904) 50 | 51 | # Use Case 7: Generate Excel Formulas 52 | - [Data](https://github.com/tobiaszwingmann/chatgpt-for-data-analytics/blob/main/Day%201/Email-Report.xlsx) 53 | - [Chat example](https://chat.openai.com/share/dcaf6395-3d46-4149-9aa4-f7cd02737c87) 54 | - Tool: [Paste to Markdown](https://euangoddard.github.io/clipboard2markdown/) 55 | - Tip: [Excel Formula Bot](https://formulabot.com) 56 | 57 | # Use Case 8: Write VBA Scripts 58 | - [Data](https://github.com/tobiaszwingmann/chatgpt-for-data-analytics/blob/main/Day%201/Managers_sales_report.xlsx) 59 | - [Chat example](https://chat.openai.com/share/85e0d622-6ded-494e-9767-9826cb919d6f) 60 | -------------------------------------------------------------------------------- /Day 2/OpenAI Platform Onboarding.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobiaszwingmann/chatgpt-for-data-analytics/f3ab7b116ae8dd27bd8bdfa99e44131eb68f40ba/Day 2/OpenAI Platform Onboarding.pdf -------------------------------------------------------------------------------- /Day 2/Setting up GPT for Google Sheets.md: -------------------------------------------------------------------------------- 1 | To create a custom function in Google Sheets that calls the OpenAI API with content from a cell and retrieves a response, you can use Google Apps Script. 2 | 3 | Here's a step-by-step guide to setting this up: 4 | 5 | ### 1. Set Up OpenAI API Key 6 | Before you begin, ensure you have an API key from OpenAI. If you don't have one, you'll need to sign up on OpenAI's platform and generate an API key. 7 | 8 | ### 2. Open Google Sheets and Go to the Script Editor 9 | 1. Open your Google Sheets document. 10 | 2. Click on `Extensions` in the menu. 11 | 3. Select `Apps Script`. This opens the Google Apps Script editor. 12 | 13 | ### 3. Write the Custom Function 14 | In the Apps Script editor, you will write a script that calls the OpenAI API. Here's a basic example: 15 | 16 | ```javascript 17 | // Define your OpenAI API key 18 | const OPENAI_API_KEY = 'YOUR_OPENAI_API_KEY'; 19 | 20 | function callOpenAI(prompt) { 21 | // Define the API endpoint 22 | const url = 'https://api.openai.com/v1/chat/completions'; 23 | 24 | // Set up the headers and the payload for the API call 25 | const headers = { 26 | "Authorization": `Bearer ${OPENAI_API_KEY}`, 27 | "Content-Type": "application/json" 28 | }; 29 | 30 | const payload = { 31 | model: "gpt-4o", // Use your desired model 32 | messages: [{"role": "user", "content": prompt}], 33 | max_tokens: 100 // Adjust as necessary 34 | }; 35 | 36 | // Make the API request 37 | const options = { 38 | method: 'POST', 39 | headers: headers, 40 | payload: JSON.stringify(payload) 41 | }; 42 | 43 | try { 44 | const response = UrlFetchApp.fetch(url, options); 45 | const json = JSON.parse(response.getContentText()); 46 | 47 | // Extract the response from the API (assuming it's in the 'choices' array) 48 | return json.choices[0].message.content.trim(); 49 | } catch (error) { 50 | return `Error: ${error}`; 51 | } 52 | } 53 | 54 | function ChatGPT(cellContent) { 55 | return callOpenAI(cellContent); 56 | } 57 | ``` 58 | 59 | ### 4. Save the Script 60 | 1. Name your script (e.g., `OpenAI API Integration`). 61 | 2. Save your work by clicking the floppy disk icon or using `Ctrl + S`. 62 | 63 | ### 5. Use the Custom Function in Google Sheets 64 | Now you can use the custom function `=GPT(A1)` in your Google Sheets. Replace `A1` with the reference to the cell containing the prompt you want to send to the OpenAI API. 65 | 66 | ### 6. Handling Limitations and Considerations 67 | - **API Usage**: Be mindful of your API usage and limits. Google Sheets might make multiple calls depending on how you use the function. 68 | - **Error Handling**: The script includes basic error handling, but you may want to expand this based on your needs. 69 | - **Response Length**: Adjust `max_tokens` in the payload to control the length of the response from OpenAI. 70 | -------------------------------------------------------------------------------- /Day 2/readme.md: -------------------------------------------------------------------------------- 1 | # Day 2 2 | 3 | Day 2 emphasizes data analysis use cases that are powered by using the [OpenAI APIs](https://platform.openai.com/) - some technical knowledge required! 4 | 5 | If you sign up for the OpenAI APIs as a new user, you need to top up [at least $5]([https://help.openai.com/en/articles/4936830-what-happens-after-i-use-my-free-tokens-or-the-3-months-is-up-in-the-free-trial](https://help.openai.com/en/articles/8264644-what-is-prepaid-billing#)), in order to generate an API Key. 6 | 7 | Check the [OpenAI Onboarding Guide](https://github.com/tobiaszwingmann/chatgpt-for-data-analytics/blob/main/Day%202/OpenAI%20Platform%20Onboarding.pdf) if needed. 8 | 9 | ## Use Cases 11 - 12: GPT For Google Sheets 10 | * [Integrate ChatGPT into Google Sheets](https://github.com/tobiaszwingmann/chatgpt-for-data-analytics/blob/main/Day%202/Setting%20up%20GPT%20for%20Google%20Sheets.md) 11 | * [Google Sheets](https://docs.google.com/spreadsheets/d/1YvUmsU3CU-DpkE3H19zjdBWCV1gW4eXHXL8aFk9KsbY/edit?usp=sharing) 12 | * [Excel Version (Beta)](https://www.microsoft.com/en-us/garage/profiles/excel-labs/) 13 | 14 | ## Use Cases 13 - 15: Getting started with the OpenAI APIs 15 | * [Google Colab](https://colab.research.google.com/drive/1QCFVpTem-miQhyxhhmVWbhmWo2Ob1PEM?usp=sharing) 16 | 17 | ## Use Cases 16 - 20: GPT For SQL & Pyhon 18 | * [Google Colab](https://colab.research.google.com/drive/1WOK7J6eEOaYKrKMS8UdUFSp97vZjzCqb?usp=sharing) 19 | * [Data](https://github.com/tobiaszwingmann/chatgpt-for-data-analytics/blob/main/Day%202/sample_warehouse.db) 20 | -------------------------------------------------------------------------------- /Day 2/sample_warehouse.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobiaszwingmann/chatgpt-for-data-analytics/f3ab7b116ae8dd27bd8bdfa99e44131eb68f40ba/Day 2/sample_warehouse.db -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Course Materials 2 | 3 | This repository contains accompanying course materials for the O'Reilly online live event [ChatGPT For Data Analytics](https://www.oreilly.com/live-events/chatgpt-for-data-analytics/0636920094217/0636920094216/) by Tobias Zwingmann. 4 | --------------------------------------------------------------------------------