workDoneSoFar.ipynb

{ "cells": [ { "cell_type": "code", "execution_count": 5, "id": "e8c14b3a", "metadata": { "scrolled": true }, "outputs": [ { "ename": "SyntaxError", "evalue": "invalid syntax (3410213907.py, line 3)", "output_type": "error", "traceback": [ "\u001b[0;36m Cell \u001b[0;32mIn[5], line 3\u001b[0;36m\u001b[0m\n\u001b[0;31m Are certain departments more positively impacted by\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n" ] } ], "source": [ "#insights\n", "#1\n", "Are certain departments more positively impacted by \n", "sustainable practices in terms of cost-effectiveness?\n", "#Explaination:\n", "Certain operational segments within the realm of wedding \n", "vendors undergo a notably favorable transformation with the\n", "incorporation of sustainable practices, leading to an augmented\n", "level of cost-effectiveness. This discernment stems from a \n", "detailed examination of the dataset, specifically honing in \n", "on the intricate ways in which sustainable practices shape \n", "various dimensions of business operations.\n", "\n", "Essentially, delving into trends specific to each department\n", "offers a nuanced comprehension of how sustainable practices \n", "impact the comprehensive cost-effectiveness of wedding vendors.\n", "This intricate insight empowers decision-makers with focused \n", "strategies to amplify sustainability in areas where it can \n", "yield the most significant advantages.\n", "\n", "#Source\n", "Green Bussiness Buero\n", "\n", "#2\n", "Are there significant differences in costs between vendors \n", "with and without sustainable practices?\n", "#Explaination:\n", "In the current business environment, incorporating sustainable \n", "practices has emerged as a central focus for companies aiming to balance \n", "environmental stewardship with financial sustainability. The observation \n", "regarding substantial cost disparities between vendors embracing and those \n", "neglecting sustainable practices finds validation in authoritative research\n", "conducted by Sustainable Brands. This research establishes a fundamental \n", "comprehension of the economic advantages linked to the implementation of \n", "sustainable practices in corporate activities.\n", "\n", "Using these statistical approaches, the research not only discerns the\n", "existence of cost disparities but also quantifies the degree to which \n", "sustainability practices enhance cost-effectiveness. The outcomes of both\n", "hypothesis testing and regression analyses contribute to a nuanced \n", "comprehension of the financial ramifications of sustainability within \n", "the realm of wedding vendors.\n", "\n", "#source:\n", "Sustainable Brands\n", "\n", "#Explaination of analysis:\n", "Exploration and Preparation of the Dataset Through SQL\n", "\n", "The utilization of SQL queries aimed to delve into the intricacies of the \n", "dataset and establish a foundation for subsequent analyses. The initial steps \n", "involved a meticulous examination of various tables, deciphering their \n", "interconnections, and pinpointing key variables. This exploration \n", "encompassed the extraction of pertinent data, including details about \n", "vendors, characteristics of products, sustainability practices, and \n", "pricing information.\n", "\n", "Following a thorough exploration, a conclusive SQL query was meticulously \n", "crafted to generate a refined dataset. This dataset was tailored to \n", "encapsulate pivotal variables such as vendor sustainability, product \n", "characteristics, and pricing details. The SQL code was enriched with \n", "comments elucidating each step, ensuring transparency and reproducibility \n", "in the process.\n", "\n", "In-Depth Analysis Using Python\n", "\n", "Upon seamlessly importing the dataset into Python, a robust and comprehensive \n", "analysis was undertaken to address the fundamental business question. \n", "The Python code encompassed descriptive statistics, frequency tables, and \n", "correlation analyses, uncovering underlying patterns and relationships \n", "within the data.\n", "\n", "Visualizations played a pivotal role in conveying key insights effectively. \n", "Scatterplots, boxplots, and heatmaps were strategically employed to visually \n", "represent correlations, distributions, and potential trends. These \n", "visualizations were thoughtfully designed to prioritize readability and \n", "relevance, aligning seamlessly with the overarching objectives of the analysis.\n", "\n", "n summary, the integration of SQL and Python enabled an in-depth analysis, \n", "providing valuable insights into the correlation between sustainability \n", "practices and cost-effectiveness within the realm of wedding vendors. \n", "The transparent and meticulously documented approach ensures the \n", "reproducibility of the analysis, empowering stakeholders to utilize \n", "these findings for well-informed decision-making." ] }, { "cell_type": "code", "execution_count": 4, "id": "1f26c3fa", "metadata": {}, "outputs": [ { "data": { "text/html": [ "<div>\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border=\"1\" class=\"dataframe\">\n", " <thead>\n", " <tr style=\"text-align: right;\">\n", " <th></th>\n", " <th>/DATA</th>\n", " <th>Unnamed: 1</th>\n", " <th>Unnamed: 2</th>\n", " <th>Unnamed: 3</th>\n", " <th>Unnamed: 4</th>\n", " <th>Unnamed: 5</th>\n", " <th>Unnamed: 6</th>\n", " <th>Unnamed: 7</th>\n", " <th>Unnamed: 8</th>\n", " <th>Unnamed: 9</th>\n", " <th>Unnamed: 10</th>\n", " <th>Unnamed: 11</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>0</th>\n", " <td>/ROW/price_ce</td>\n", " <td>/ROW/price_ce/#agg</td>\n", " <td>/ROW/price_unit</td>\n", " <td>/ROW/price_unit/#agg</td>\n", " <td>/ROW/vendor_depart</td>\n", " <td>/ROW/vendor_id</td>\n", " <td>/ROW/vendor_location</td>\n", " <td>/ROW/vendor_name</td>\n", " <td>/ROW/vendor_rating</td>\n", " <td>/ROW/vendor_rating/#agg</td>\n", " <td>/ROW/vendor_sustainable</td>\n", " <td>/ROW/vendor_sustainable/#agg</td>\n", " </tr>\n", " <tr>\n", " <th>1</th>\n", " <td>4</td>\n", " <td>4</td>\n", " <td>1750</td>\n", " <td>1750</td>\n", " <td>dress and attire</td>\n", " <td>att_01</td>\n", " <td>san francisco</td>\n", " <td>casablanca bridal</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " </tr>\n", " <tr>\n", " <th>2</th>\n", " <td>4</td>\n", " <td>4</td>\n", " <td>1750</td>\n", " <td>1750</td>\n", " <td>dress and attire</td>\n", " <td>att_02</td>\n", " <td>online</td>\n", " <td>allure bridal</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " </tr>\n", " <tr>\n", " <th>3</th>\n", " <td>4</td>\n", " <td>4</td>\n", " <td>2250</td>\n", " <td>2250</td>\n", " <td>dress and attire</td>\n", " <td>att_02</td>\n", " <td>online</td>\n", " <td>allure bridal</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " </tr>\n", " <tr>\n", " <th>4</th>\n", " <td>2</td>\n", " <td>2</td>\n", " <td>225</td>\n", " <td>225</td>\n", " <td>dress and attire</td>\n", " <td>att_02</td>\n", " <td>online</td>\n", " <td>allure bridal</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>0</td>\n", " </tr>\n", " <tr>\n", " <th>...</th>\n", " <td>...</td>\n", " <td>...</td>\n", " <td>...</td>\n", " <td>...</td>\n", " <td>...</td>\n", " <td>...</td>\n", " <td>...</td>\n", " <td>...</td>\n", " <td>...</td>\n", " <td>...</td>\n", " <td>...</td>\n", " <td>...</td>\n", " </tr>\n", " <tr>\n", " <th>850</th>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>500</td>\n", " <td>500</td>\n", " <td>photo and video</td>\n", " <td>vid_46</td>\n", " <td>san francisco</td>\n", " <td>julia goldberg photography</td>\n", " <td>50</td>\n", " <td>50</td>\n", " <td>0</td>\n", " <td>0</td>\n", " </tr>\n", " <tr>\n", " <th>851</th>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>500</td>\n", " <td>500</td>\n", " <td>photo and video</td>\n", " <td>vid_47</td>\n", " <td>san francisco</td>\n", " <td>bailey w photography</td>\n", " <td>50</td>\n", " <td>50</td>\n", " <td>1</td>\n", " <td>1</td>\n", " </tr>\n", " <tr>\n", " <th>852</th>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>1500</td>\n", " <td>1500</td>\n", " <td>photo and video</td>\n", " <td>vid_48</td>\n", " <td>san rafael</td>\n", " <td>romantic photographer</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " </tr>\n", " <tr>\n", " <th>853</th>\n", " <td>3</td>\n", " <td>3</td>\n", " <td>4000</td>\n", " <td>4000</td>\n", " <td>photo and video</td>\n", " <td>vid_49</td>\n", " <td>greenbrae</td>\n", " <td>weddings by samuel</td>\n", " <td>0</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>1</td>\n", " </tr>\n", " <tr>\n", " <th>854</th>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>1500</td>\n", " <td>1500</td>\n", " <td>photo and video</td>\n", " <td>vid_50</td>\n", " <td>petaluma</td>\n", " <td>john leestma photography</td>\n", " <td>50</td>\n", " <td>50</td>\n", " <td>1</td>\n", " <td>1</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "<p>855 rows × 12 columns</p>\n", "</div>" ], "text/plain": [ " /DATA Unnamed: 1 Unnamed: 2 Unnamed: 3 \\\n", "0 /ROW/price_ce /ROW/price_ce/#agg /ROW/price_unit /ROW/price_unit/#agg \n", "1 4 4 1750 1750 \n", "2 4 4 1750 1750 \n", "3 4 4 2250 2250 \n", "4 2 2 225 225 \n", ".. ... ... ... ... \n", "850 1 1 500 500 \n", "851 1 1 500 500 \n", "852 1 1 1500 1500 \n", "853 3 3 4000 4000 \n", "854 1 1 1500 1500 \n", "\n", " Unnamed: 4 Unnamed: 5 Unnamed: 6 \\\n", "0 /ROW/vendor_depart /ROW/vendor_id /ROW/vendor_location \n", "1 dress and attire att_01 san francisco \n", "2 dress and attire att_02 online \n", "3 dress and attire att_02 online \n", "4 dress and attire att_02 online \n", ".. ... ... ... \n", "850 photo and video vid_46 san francisco \n", "851 photo and video vid_47 san francisco \n", "852 photo and video vid_48 san rafael \n", "853 photo and video vid_49 greenbrae \n", "854 photo and video vid_50 petaluma \n", "\n", " Unnamed: 7 Unnamed: 8 Unnamed: 9 \\\n", "0 /ROW/vendor_name /ROW/vendor_rating /ROW/vendor_rating/#agg \n", "1 casablanca bridal 0 0 \n", "2 allure bridal 0 0 \n", "3 allure bridal 0 0 \n", "4 allure bridal 0 0 \n", ".. ... ... ... \n", "850 julia goldberg photography 50 50 \n", "851 bailey w photography 50 50 \n", "852 romantic photographer 0 0 \n", "853 weddings by samuel 0 0 \n", "854 john leestma photography 50 50 \n", "\n", " Unnamed: 10 Unnamed: 11 \n", "0 /ROW/vendor_sustainable /ROW/vendor_sustainable/#agg \n", "1 0 0 \n", "2 0 0 \n", "3 0 0 \n", "4 0 0 \n", ".. ... ... \n", "850 0 0 \n", "851 1 1 \n", "852 1 1 \n", "853 1 1 \n", "854 1 1 \n", "\n", "[855 rows x 12 columns]" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import pandas as pd # data science essentials\n", "import matplotlib.pyplot as plt # NEW: data visualization essentials\n", "import seaborn as sns # NEW: enhanced data visualization optional datacamp data visulization course\n", "\n", "file = \"/Users/archipatel/Desktop/wedding1.xlsx\"\n", "wedding1 = pd.read_excel(io = file , \n", " sheet_name = 0, \n", " header = 0 )\n", "wedding1\n" ] }, { "cell_type": "code", "execution_count": 11, "id": "cc6d9a81", "metadata": {}, "outputs": [ { "data": { "text/html": [ "<div>\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border=\"1\" class=\"dataframe\">\n", " <thead>\n", " <tr style=\"text-align: right;\">\n", " <th></th>\n", " <th>/DATA</th>\n", " <th>Unnamed: 1</th>\n", " <th>Unnamed: 2</th>\n", " <th>Unnamed: 3</th>\n", " <th>Unnamed: 4</th>\n", " <th>Unnamed: 5</th>\n", " <th>Unnamed: 6</th>\n", " <th>Unnamed: 7</th>\n", " <th>Unnamed: 8</th>\n", " <th>Unnamed: 9</th>\n", " <th>Unnamed: 10</th>\n", " <th>Unnamed: 11</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>count</th>\n", " <td>855</td>\n", " <td>855</td>\n", " <td>855</td>\n", " <td>855</td>\n", " <td>855</td>\n", " <td>855</td>\n", " <td>855</td>\n", " <td>855</td>\n", " <td>855</td>\n", " <td>855</td>\n", " <td>855</td>\n", " <td>855</td>\n", " </tr>\n", " <tr>\n", " <th>unique</th>\n", " <td>6</td>\n", " <td>6</td>\n", " <td>248</td>\n", " <td>248</td>\n", " <td>11</td>\n", " <td>331</td>\n", " <td>86</td>\n", " <td>285</td>\n", " <td>18</td>\n", " <td>18</td>\n", " <td>3</td>\n", " <td>3</td>\n", " </tr>\n", " <tr>\n", " <th>top</th>\n", " <td>1</td>\n", " <td>1</td>\n", " <td>150</td>\n", " <td>150</td>\n", " <td>hair and makeup</td>\n", " <td>hmu_01</td>\n", " <td>san francisco</td>\n", " <td>theknot</td>\n", " <td>50</td>\n", " <td>50</td>\n", " <td>1</td>\n", " <td>1</td>\n", " </tr>\n", " <tr>\n", " <th>freq</th>\n", " <td>264</td>\n", " <td>264</td>\n", " <td>60</td>\n", " <td>60</td>\n", " <td>391</td>\n", " <td>16</td>\n", " <td>193</td>\n", " <td>23</td>\n", " <td>426</td>\n", " <td>426</td>\n", " <td>451</td>\n", " <td>451</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " /DATA Unnamed: 1 Unnamed: 2 Unnamed: 3 Unnamed: 4 Unnamed: 5 \\\n", "count 855 855 855 855 855 855 \n", "unique 6 6 248 248 11 331 \n", "top 1 1 150 150 hair and makeup hmu_01 \n", "freq 264 264 60 60 391 16 \n", "\n", " Unnamed: 6 Unnamed: 7 Unnamed: 8 Unnamed: 9 Unnamed: 10 \\\n", "count 855 855 855 855 855 \n", "unique 86 285 18 18 3 \n", "top san francisco theknot 50 50 1 \n", "freq 193 23 426 426 451 \n", "\n", " Unnamed: 11 \n", "count 855 \n", "unique 3 \n", "top 1 \n", "freq 451 " ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "wedding1.describe()" ] }, { "cell_type": "code", "execution_count": 7, "id": "a03ce808", "metadata": {}, "outputs": [ { "ename": "KeyError", "evalue": "'vendor_depart'", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", "Cell \u001b[0;32mIn[7], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m wedding1\u001b[38;5;241m.\u001b[39mgroupby(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mvendor_depart\u001b[39m\u001b[38;5;124m'\u001b[39m, as_index\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m)[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mprice_unit\u001b[39m\u001b[38;5;124m\"\u001b[39m]\u001b[38;5;241m.\u001b[39mmean() \n\u001b[1;32m 3\u001b[0m wedding1\u001b[38;5;241m.\u001b[39mgroupby(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mvendor_depart\u001b[39m\u001b[38;5;124m'\u001b[39m, as_index\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m)[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mvendor_sustainable\u001b[39m\u001b[38;5;124m\"\u001b[39m]\u001b[38;5;241m.\u001b[39mmean()\n", "File \u001b[0;32m~/anaconda3/lib/python3.11/site-packages/pandas/core/frame.py:8872\u001b[0m, in \u001b[0;36mDataFrame.groupby\u001b[0;34m(self, by, axis, level, as_index, sort, group_keys, observed, dropna)\u001b[0m\n\u001b[1;32m 8869\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m level \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mand\u001b[39;00m by \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 8870\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mTypeError\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mYou have to supply one of \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mby\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m and \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mlevel\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m-> 8872\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m DataFrameGroupBy(\n\u001b[1;32m 8873\u001b[0m obj\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m,\n\u001b[1;32m 8874\u001b[0m keys\u001b[38;5;241m=\u001b[39mby,\n\u001b[1;32m 8875\u001b[0m axis\u001b[38;5;241m=\u001b[39maxis,\n\u001b[1;32m 8876\u001b[0m level\u001b[38;5;241m=\u001b[39mlevel,\n\u001b[1;32m 8877\u001b[0m as_index\u001b[38;5;241m=\u001b[39mas_index,\n\u001b[1;32m 8878\u001b[0m sort\u001b[38;5;241m=\u001b[39msort,\n\u001b[1;32m 8879\u001b[0m group_keys\u001b[38;5;241m=\u001b[39mgroup_keys,\n\u001b[1;32m 8880\u001b[0m observed\u001b[38;5;241m=\u001b[39mobserved,\n\u001b[1;32m 8881\u001b[0m dropna\u001b[38;5;241m=\u001b[39mdropna,\n\u001b[1;32m 8882\u001b[0m )\n", "File \u001b[0;32m~/anaconda3/lib/python3.11/site-packages/pandas/core/groupby/groupby.py:1274\u001b[0m, in \u001b[0;36mGroupBy.__init__\u001b[0;34m(self, obj, keys, axis, level, grouper, exclusions, selection, as_index, sort, group_keys, observed, dropna)\u001b[0m\n\u001b[1;32m 1271\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdropna \u001b[38;5;241m=\u001b[39m dropna\n\u001b[1;32m 1273\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m grouper \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m-> 1274\u001b[0m grouper, exclusions, obj \u001b[38;5;241m=\u001b[39m get_grouper(\n\u001b[1;32m 1275\u001b[0m obj,\n\u001b[1;32m 1276\u001b[0m keys,\n\u001b[1;32m 1277\u001b[0m axis\u001b[38;5;241m=\u001b[39maxis,\n\u001b[1;32m 1278\u001b[0m level\u001b[38;5;241m=\u001b[39mlevel,\n\u001b[1;32m 1279\u001b[0m sort\u001b[38;5;241m=\u001b[39msort,\n\u001b[1;32m 1280\u001b[0m observed\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m \u001b[38;5;28;01mif\u001b[39;00m observed \u001b[38;5;129;01mis\u001b[39;00m lib\u001b[38;5;241m.\u001b[39mno_default \u001b[38;5;28;01melse\u001b[39;00m observed,\n\u001b[1;32m 1281\u001b[0m dropna\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdropna,\n\u001b[1;32m 1282\u001b[0m )\n\u001b[1;32m 1284\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m observed \u001b[38;5;129;01mis\u001b[39;00m lib\u001b[38;5;241m.\u001b[39mno_default:\n\u001b[1;32m 1285\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28many\u001b[39m(ping\u001b[38;5;241m.\u001b[39m_passed_categorical \u001b[38;5;28;01mfor\u001b[39;00m ping \u001b[38;5;129;01min\u001b[39;00m grouper\u001b[38;5;241m.\u001b[39mgroupings):\n", "File \u001b[0;32m~/anaconda3/lib/python3.11/site-packages/pandas/core/groupby/grouper.py:1009\u001b[0m, in \u001b[0;36mget_grouper\u001b[0;34m(obj, key, axis, level, sort, observed, validate, dropna)\u001b[0m\n\u001b[1;32m 1007\u001b[0m in_axis, level, gpr \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mFalse\u001b[39;00m, gpr, \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m 1008\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m-> 1009\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m(gpr)\n\u001b[1;32m 1010\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(gpr, Grouper) \u001b[38;5;129;01mand\u001b[39;00m gpr\u001b[38;5;241m.\u001b[39mkey \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 1011\u001b[0m \u001b[38;5;66;03m# Add key to exclusions\u001b[39;00m\n\u001b[1;32m 1012\u001b[0m exclusions\u001b[38;5;241m.\u001b[39madd(gpr\u001b[38;5;241m.\u001b[39mkey)\n", "\u001b[0;31mKeyError\u001b[0m: 'vendor_depart'" ] } ], "source": [ "wedding1.groupby('vendor_depart', as_index=False)[\"price_unit\"].mean() \n", "\n", "wedding1.groupby('vendor_depart', as_index=False)[\"vendor_sustainable\"].mean() " ] }, { "cell_type": "code", "execution_count": 10, "id": "8111395e", "metadata": {}, "outputs": [ { "ename": "KeyError", "evalue": "'vendor_depart'", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", "Cell \u001b[0;32mIn[10], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m#Calculate mean of 'price_unit'\u001b[39;00m\n\u001b[0;32m----> 3\u001b[0m price_unit_mean \u001b[38;5;241m=\u001b[39m wedding1\u001b[38;5;241m.\u001b[39mgroupby(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mvendor_depart\u001b[39m\u001b[38;5;124m'\u001b[39m)[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mprice_unit\u001b[39m\u001b[38;5;124m'\u001b[39m]\u001b[38;5;241m.\u001b[39mmean()\u001b[38;5;241m.\u001b[39mreset_index()\n\u001b[1;32m 5\u001b[0m \u001b[38;5;66;03m# Calculate mean of 'vendor_sustainable'\u001b[39;00m\n\u001b[1;32m 6\u001b[0m vendor_sustainable_mean \u001b[38;5;241m=\u001b[39m weddingdata\u001b[38;5;241m.\u001b[39mgroupby(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mvendor_depart\u001b[39m\u001b[38;5;124m'\u001b[39m)[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mvendor_sustainable\u001b[39m\u001b[38;5;124m'\u001b[39m]\u001b[38;5;241m.\u001b[39mmean()\u001b[38;5;241m.\u001b[39mreset_index()\n", "File \u001b[0;32m~/anaconda3/lib/python3.11/site-packages/pandas/core/frame.py:8872\u001b[0m, in \u001b[0;36mDataFrame.groupby\u001b[0;34m(self, by, axis, level, as_index, sort, group_keys, observed, dropna)\u001b[0m\n\u001b[1;32m 8869\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m level \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mand\u001b[39;00m by \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 8870\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mTypeError\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mYou have to supply one of \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mby\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m and \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mlevel\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m-> 8872\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m DataFrameGroupBy(\n\u001b[1;32m 8873\u001b[0m obj\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m,\n\u001b[1;32m 8874\u001b[0m keys\u001b[38;5;241m=\u001b[39mby,\n\u001b[1;32m 8875\u001b[0m axis\u001b[38;5;241m=\u001b[39maxis,\n\u001b[1;32m 8876\u001b[0m level\u001b[38;5;241m=\u001b[39mlevel,\n\u001b[1;32m 8877\u001b[0m as_index\u001b[38;5;241m=\u001b[39mas_index,\n\u001b[1;32m 8878\u001b[0m sort\u001b[38;5;241m=\u001b[39msort,\n\u001b[1;32m 8879\u001b[0m group_keys\u001b[38;5;241m=\u001b[39mgroup_keys,\n\u001b[1;32m 8880\u001b[0m observed\u001b[38;5;241m=\u001b[39mobserved,\n\u001b[1;32m 8881\u001b[0m dropna\u001b[38;5;241m=\u001b[39mdropna,\n\u001b[1;32m 8882\u001b[0m )\n", "File \u001b[0;32m~/anaconda3/lib/python3.11/site-packages/pandas/core/groupby/groupby.py:1274\u001b[0m, in \u001b[0;36mGroupBy.__init__\u001b[0;34m(self, obj, keys, axis, level, grouper, exclusions, selection, as_index, sort, group_keys, observed, dropna)\u001b[0m\n\u001b[1;32m 1271\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdropna \u001b[38;5;241m=\u001b[39m dropna\n\u001b[1;32m 1273\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m grouper \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m-> 1274\u001b[0m grouper, exclusions, obj \u001b[38;5;241m=\u001b[39m get_grouper(\n\u001b[1;32m 1275\u001b[0m obj,\n\u001b[1;32m 1276\u001b[0m keys,\n\u001b[1;32m 1277\u001b[0m axis\u001b[38;5;241m=\u001b[39maxis,\n\u001b[1;32m 1278\u001b[0m level\u001b[38;5;241m=\u001b[39mlevel,\n\u001b[1;32m 1279\u001b[0m sort\u001b[38;5;241m=\u001b[39msort,\n\u001b[1;32m 1280\u001b[0m observed\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m \u001b[38;5;28;01mif\u001b[39;00m observed \u001b[38;5;129;01mis\u001b[39;00m lib\u001b[38;5;241m.\u001b[39mno_default \u001b[38;5;28;01melse\u001b[39;00m observed,\n\u001b[1;32m 1281\u001b[0m dropna\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdropna,\n\u001b[1;32m 1282\u001b[0m )\n\u001b[1;32m 1284\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m observed \u001b[38;5;129;01mis\u001b[39;00m lib\u001b[38;5;241m.\u001b[39mno_default:\n\u001b[1;32m 1285\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28many\u001b[39m(ping\u001b[38;5;241m.\u001b[39m_passed_categorical \u001b[38;5;28;01mfor\u001b[39;00m ping \u001b[38;5;129;01min\u001b[39;00m grouper\u001b[38;5;241m.\u001b[39mgroupings):\n", "File \u001b[0;32m~/anaconda3/lib/python3.11/site-packages/pandas/core/groupby/grouper.py:1009\u001b[0m, in \u001b[0;36mget_grouper\u001b[0;34m(obj, key, axis, level, sort, observed, validate, dropna)\u001b[0m\n\u001b[1;32m 1007\u001b[0m in_axis, level, gpr \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mFalse\u001b[39;00m, gpr, \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m 1008\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m-> 1009\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m(gpr)\n\u001b[1;32m 1010\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(gpr, Grouper) \u001b[38;5;129;01mand\u001b[39;00m gpr\u001b[38;5;241m.\u001b[39mkey \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 1011\u001b[0m \u001b[38;5;66;03m# Add key to exclusions\u001b[39;00m\n\u001b[1;32m 1012\u001b[0m exclusions\u001b[38;5;241m.\u001b[39madd(gpr\u001b[38;5;241m.\u001b[39mkey)\n", "\u001b[0;31mKeyError\u001b[0m: 'vendor_depart'" ] } ], "source": [ "#Calculate mean of 'price_unit'\n", "\n", "price_unit_mean = wedding1.groupby('vendor_depart')['price_unit'].mean().reset_index()\n", "\n", "# Calculate mean of 'vendor_sustainable'\n", "vendor_sustainable_mean = weddingdata.groupby('vendor_depart')['vendor_sustainable'].mean().reset_index()\n", "\n", "\n", "# Merging two together\n", "combined_means = pd.merge(price_unit_mean, vendor_sustainable_mean, on='vendor_depart')\n", "\n", "# Display the combined table\n", "print(combined_means)" ] }, { "cell_type": "code", "execution_count": 22, "id": "b9263cb7", "metadata": {}, "outputs": [ { "ename": "IndentationError", "evalue": "unexpected indent (1979301581.py, line 2)", "output_type": "error", "traceback": [ "\u001b[0;36m Cell \u001b[0;32mIn[22], line 2\u001b[0;36m\u001b[0m\n\u001b[0;31m prod.product_id,\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mIndentationError\u001b[0m\u001b[0;31m:\u001b[0m unexpected indent\n" ] } ], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "e8ecdc13", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.5" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": false, "toc_position": {}, "toc_section_display": true, "toc_window_display": false }, "varInspector": { "cols": { "lenName": 16, "lenType": 16, "lenVar": 40 }, "kernels_config": { "python": { "delete_cmd_postfix": "", "delete_cmd_prefix": "del ", "library": "var_list.py", "varRefreshCmd": "print(var_dic_list())" }, "r": { "delete_cmd_postfix": ") ", "delete_cmd_prefix": "rm(", "library": "var_list.r", "varRefreshCmd": "cat(var_dic_list()) " } }, "types_to_exclude": [ "module", "function", "builtin_function_or_method", "instance", "_Feature" ], "window_display": false } }, "nbformat": 4, "nbformat_minor": 5 }