{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "from matplotlib import pyplot\n",
    "\n",
    "from scipy.stats import shapiro\n",
    "from scipy.stats import normaltest\n",
    "from scipy.stats import anderson\n",
    "from scipy.stats import chi2_contingency\n",
    "from scipy.stats import chi2\n",
    "\n",
    "import statsmodels.api as sm\n",
    "from statsmodels.formula.api import ols\n",
    "from statsmodels.stats.multicomp import pairwise_tukeyhsd\n",
    "from statsmodels.graphics.gofplots import qqplot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "#import the data\n",
    "scdf = pd.read_csv(\"sc.dataset.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(10324, 33)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "scdf.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "ID                                int64\n",
       "Project Code                     object\n",
       "PQ #                             object\n",
       "PO / SO #                        object\n",
       "ASN/DN #                         object\n",
       "Country                          object\n",
       "Managed By                       object\n",
       "Fulfill Via                      object\n",
       "Vendor INCO Term                 object\n",
       "Shipment Mode                    object\n",
       "PQ First Sent to Client Date     object\n",
       "PO Sent to Vendor Date           object\n",
       "Scheduled Delivery Date          object\n",
       "Delivered to Client Date         object\n",
       "Delivery Recorded Date           object\n",
       "Product Group                    object\n",
       "Sub Classification               object\n",
       "Vendor                           object\n",
       "Item Description                 object\n",
       "Molecule/Test Type               object\n",
       "Brand                            object\n",
       "Dosage                           object\n",
       "Dosage Form                      object\n",
       "Unit of Measure (Per Pack)        int64\n",
       "Line Item Quantity                int64\n",
       "Line Item Value                 float64\n",
       "Pack Price                      float64\n",
       "Unit Price                      float64\n",
       "Manufacturing Site               object\n",
       "First Line Designation           object\n",
       "Weight (Kilograms)               object\n",
       "Freight Cost (USD)               object\n",
       "Line Item Insurance (USD)       float64\n",
       "dtype: object"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "scdf.dtypes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "ID                                 0\n",
       "Project Code                       0\n",
       "PQ #                               0\n",
       "PO / SO #                          0\n",
       "ASN/DN #                           0\n",
       "Country                            0\n",
       "Managed By                         0\n",
       "Fulfill Via                        0\n",
       "Vendor INCO Term                   0\n",
       "Shipment Mode                    360\n",
       "PQ First Sent to Client Date       0\n",
       "PO Sent to Vendor Date             0\n",
       "Scheduled Delivery Date            0\n",
       "Delivered to Client Date           0\n",
       "Delivery Recorded Date             0\n",
       "Product Group                      0\n",
       "Sub Classification                 0\n",
       "Vendor                             0\n",
       "Item Description                   0\n",
       "Molecule/Test Type                 0\n",
       "Brand                              0\n",
       "Dosage                          1736\n",
       "Dosage Form                        0\n",
       "Unit of Measure (Per Pack)         0\n",
       "Line Item Quantity                 0\n",
       "Line Item Value                    0\n",
       "Pack Price                         0\n",
       "Unit Price                         0\n",
       "Manufacturing Site                 0\n",
       "First Line Designation             0\n",
       "Weight (Kilograms)                 0\n",
       "Freight Cost (USD)                 0\n",
       "Line Item Insurance (USD)        287\n",
       "dtype: int64"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "scdf.isnull().sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3.487020534676482 %\n",
      "\n",
      "Air            6113\n",
      "Truck          2830\n",
      "Air Charter     650\n",
      "Ocean           371\n",
      "Name: Shipment Mode, dtype: int64\n",
      "Air            6473\n",
      "Truck          2830\n",
      "Air Charter     650\n",
      "Ocean           371\n",
      "Name: Shipment Mode, dtype: int64\n"
     ]
    }
   ],
   "source": [
    "#shipment mode\n",
    "print((scdf['Shipment Mode'].isnull().sum()/scdf.shape[0])*100, '%\\n')\n",
    "print(scdf['Shipment Mode'].value_counts())\n",
    "scdf['Shipment Mode'] = scdf['Shipment Mode'].fillna('Air')\n",
    "print(scdf['Shipment Mode'].value_counts())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "16.815187911662147 %\n",
      "\n",
      "300mg              990\n",
      "200mg              932\n",
      "600mg              772\n",
      "150/300mg          600\n",
      "150/300/200mg      580\n",
      "10mg/ml            552\n",
      "150mg              431\n",
      "200/50mg           395\n",
      "300/300mg          301\n",
      "600/300/300mg      286\n",
      "150/200/30mg       250\n",
      "100mg              228\n",
      "50mg               174\n",
      "200/300mg          160\n",
      "80/20mg/ml         158\n",
      "400mg              156\n",
      "20mg/ml            152\n",
      "30mg               144\n",
      "600/200/300mg      139\n",
      "150/30mg           133\n",
      "30/50/60mg         127\n",
      "300/200mg           94\n",
      "30/60mg             89\n",
      "250mg               88\n",
      "100/25mg            73\n",
      "60/30mg             73\n",
      "600/300mg           63\n",
      "300/100mg           54\n",
      "1mg/ml              54\n",
      "20mg                43\n",
      "25mg                39\n",
      "15mg                38\n",
      "30mg/ml             33\n",
      "300/150/300mg       28\n",
      "30/50/6mg           19\n",
      "30/6mg              14\n",
      "500/25mg            13\n",
      "80mg/ml             13\n",
      "20/120mg            12\n",
      "60/100/12mg         12\n",
      "2g                  11\n",
      "500mg               10\n",
      "150/300+200mg        8\n",
      "150/300mg+600mg      7\n",
      "133.3/33.3mg         7\n",
      "40mg                 6\n",
      "150/200/40mg         5\n",
      "60mg                 5\n",
      "60/12mg              5\n",
      "50+153mg             4\n",
      "125mg                4\n",
      "600mg/2ml            2\n",
      "150/300+300mg        1\n",
      "50mg/g               1\n",
      "Name: Dosage, dtype: int64\n",
      "(8588, 33)\n"
     ]
    }
   ],
   "source": [
    "#dosage\n",
    "print((scdf['Dosage'].isnull().sum()/scdf.shape[0])*100, '%\\n')\n",
    "print(scdf['Dosage'].value_counts())\n",
    "scdf.dropna(how='any', subset=['Dosage'], inplace=True)\n",
    "print(scdf.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2.433628318584071 %\n",
      "\n",
      "count    8379.000000\n",
      "mean      250.407218\n",
      "std       532.363055\n",
      "min         0.000000\n",
      "25%         6.560000\n",
      "50%        45.570000\n",
      "75%       240.320000\n",
      "max      7708.440000\n",
      "Name: Line Item Insurance (USD), dtype: float64\n",
      "0.0 %\n",
      "\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 8312 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#line item insurance\n",
    "print((scdf['Line Item Insurance (USD)'].isnull().sum()/scdf.shape[0])*100, '%\\n')\n",
    "print(scdf['Line Item Insurance (USD)'].describe())\n",
    "scdf['Line Item Insurance (USD)'].hist()\n",
    "scdf['Line Item Insurance (USD)'] = scdf['Line Item Insurance (USD)'].fillna(scdf['Line Item Insurance (USD)'].medianian())\n",
    "print((scdf['Line Item Insurance (USD)'].isnull().sum()/scdf.shape[0])*100, '%\\n')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "ID                                int64\n",
       "Project Code                     object\n",
       "PQ #                             object\n",
       "PO / SO #                        object\n",
       "ASN/DN #                         object\n",
       "Country                          object\n",
       "Managed By                       object\n",
       "Fulfill Via                      object\n",
       "Vendor INCO Term                 object\n",
       "Shipment Mode                    object\n",
       "PQ First Sent to Client Date     object\n",
       "PO Sent to Vendor Date           object\n",
       "Scheduled Delivery Date          object\n",
       "Delivered to Client Date         object\n",
       "Delivery Recorded Date           object\n",
       "Product Group                    object\n",
       "Sub Classification               object\n",
       "Vendor                           object\n",
       "Item Description                 object\n",
       "Molecule/Test Type               object\n",
       "Brand                            object\n",
       "Dosage                           object\n",
       "Dosage Form                      object\n",
       "Unit of Measure (Per Pack)        int64\n",
       "Line Item Quantity                int64\n",
       "Line Item Value                 float64\n",
       "Pack Price                      float64\n",
       "Unit Price                      float64\n",
       "Manufacturing Site               object\n",
       "First Line Designation           object\n",
       "Weight (Kilograms)               object\n",
       "Freight Cost (USD)               object\n",
       "Line Item Insurance (USD)       float64\n",
       "dtype: object"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "scdf.dtypes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {},
   "outputs": [],
   "source": [
    "#lets remove the unnecessary variables first\n",
    "scdf.drop('ID', axis=1, inplace=True)\n",
    "scdf.drop('Project Code', axis=1, inplace=True)\n",
    "scdf.drop('ASN/DN #', axis=1, inplace=True)           "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Project Code                            object\n",
       "PQ #                                    object\n",
       "PO / SO #                               object\n",
       "ASN/DN #                                object\n",
       "Country                                 object\n",
       "Managed By                              object\n",
       "Fulfill Via                             object\n",
       "Vendor INCO Term                        object\n",
       "Shipment Mode                           object\n",
       "PQ First Sent to Client Date            object\n",
       "PO Sent to Vendor Date                  object\n",
       "Scheduled Delivery Date         datetime64[ns]\n",
       "Delivered to Client Date        datetime64[ns]\n",
       "Delivery Recorded Date          datetime64[ns]\n",
       "Product Group                           object\n",
       "Sub Classification                      object\n",
       "Vendor                                  object\n",
       "Item Description                        object\n",
       "Molecule/Test Type                      object\n",
       "Brand                                   object\n",
       "Dosage                                  object\n",
       "Dosage Form                             object\n",
       "Unit of Measure (Per Pack)               int64\n",
       "Line Item Quantity                       int64\n",
       "Line Item Value                        float64\n",
       "Pack Price                             float64\n",
       "Unit Price                             float64\n",
       "Manufacturing Site                      object\n",
       "First Line Designation                  object\n",
       "Weight (Kilograms)                      object\n",
       "Freight Cost (USD)                      object\n",
       "Line Item Insurance (USD)              float64\n",
       "dtype: object"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(scdf['PQ First Sent to Client Date'].value_counts())\n",
    "scdf.drop(scdf[scdf['PQ First Sent to Client Date'] == 'Date Not Captured'].index, inplace = True)\n",
    "\n",
    "print(scdf['PO Sent to Vendor Date'].value_counts())\n",
    "scdf.drop(scdf[scdf['PO Sent to Vendor Date'] == 'Date Not Captured'].index, inplace = True)\n",
    "\n",
    "scdf['Scheduled Delivery Date'] = pd.to_datetime(scdf['Scheduled Delivery Date'])\n",
    "scdf['Delivered to Client Date'] = pd.to_datetime(scdf['Delivered to Client Date'])\n",
    "scdf['Delivery Recorded Date'] = pd.to_datetime(scdf['Delivery Recorded Date'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Important KPIs: Freight Cost, Weight, Line Item Insurance, Line Item Quantity, Pack Price\n",
    "# Important Dimensions: Country, Fullfil Via, Shipment Mode, Product Group, Subclassification, Brand, Dosage Form"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Project Code                            object\n",
      "PQ #                                    object\n",
      "PO / SO #                               object\n",
      "ASN/DN #                                object\n",
      "Country                                 object\n",
      "Managed By                              object\n",
      "Fulfill Via                             object\n",
      "Vendor INCO Term                        object\n",
      "Shipment Mode                           object\n",
      "PQ First Sent to Client Date            object\n",
      "PO Sent to Vendor Date                  object\n",
      "Scheduled Delivery Date         datetime64[ns]\n",
      "Delivered to Client Date        datetime64[ns]\n",
      "Delivery Recorded Date          datetime64[ns]\n",
      "Product Group                           object\n",
      "Sub Classification                      object\n",
      "Vendor                                  object\n",
      "Item Description                        object\n",
      "Molecule/Test Type                      object\n",
      "Brand                                   object\n",
      "Dosage                                  object\n",
      "Dosage Form                             object\n",
      "Unit of Measure (Per Pack)               int64\n",
      "Line Item Quantity                       int64\n",
      "Line Item Value                        float64\n",
      "Pack Price                             float64\n",
      "Unit Price                             float64\n",
      "Manufacturing Site                      object\n",
      "First Line Designation                  object\n",
      "Weight (Kilograms)                      object\n",
      "Freight Cost (USD)                     float64\n",
      "Line Item Insurance (USD)              float64\n",
      "dtype: object\n"
     ]
    }
   ],
   "source": [
    "print(scdf['Freight Cost (USD)'].value_counts())\n",
    "scdf.drop(scdf[scdf['Freight Cost (USD)']=='Freight Included in Commodity Cost'].index, inplace=True)\n",
    "scdf.drop(scdf[scdf['Freight Cost (USD)']=='Invoiced Separately'].index, inplace=True)\n",
    "scdf.drop(scdf[scdf['Freight Cost (USD)'].str.contains('See')].index, inplace=True)\n",
    "scdf['Freight Cost (USD)'] = scdf['Freight Cost (USD)'].astype(float)\n",
    "print(scdf['Freight Cost (USD)'].value_counts())\n",
    "print(scdf.dtypes)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "76                            15\n",
      "9                             14\n",
      "21                            13\n",
      "6                             13\n",
      "Weight Captured Separately    13\n",
      "                              ..\n",
      "1674                           1\n",
      "18994                          1\n",
      "4799                           1\n",
      "1420                           1\n",
      "8296                           1\n",
      "Name: Weight (Kilograms), Length: 2942, dtype: int64\n",
      "76.0       15\n",
      "9.0        14\n",
      "21.0       13\n",
      "6.0        13\n",
      "52.0       12\n",
      "           ..\n",
      "566.0       1\n",
      "17791.0     1\n",
      "20230.0     1\n",
      "12489.0     1\n",
      "2190.0      1\n",
      "Name: Weight (Kilograms), Length: 2941, dtype: int64\n",
      "Project Code                            object\n",
      "PQ #                                    object\n",
      "PO / SO #                               object\n",
      "ASN/DN #                                object\n",
      "Country                                 object\n",
      "Managed By                              object\n",
      "Fulfill Via                             object\n",
      "Vendor INCO Term                        object\n",
      "Shipment Mode                           object\n",
      "PQ First Sent to Client Date            object\n",
      "PO Sent to Vendor Date                  object\n",
      "Scheduled Delivery Date         datetime64[ns]\n",
      "Delivered to Client Date        datetime64[ns]\n",
      "Delivery Recorded Date          datetime64[ns]\n",
      "Product Group                           object\n",
      "Sub Classification                      object\n",
      "Vendor                                  object\n",
      "Item Description                        object\n",
      "Molecule/Test Type                      object\n",
      "Brand                                   object\n",
      "Dosage                                  object\n",
      "Dosage Form                             object\n",
      "Unit of Measure (Per Pack)               int64\n",
      "Line Item Quantity                       int64\n",
      "Line Item Value                        float64\n",
      "Pack Price                             float64\n",
      "Unit Price                             float64\n",
      "Manufacturing Site                      object\n",
      "First Line Designation                  object\n",
      "Weight (Kilograms)                     float64\n",
      "Freight Cost (USD)                     float64\n",
      "Line Item Insurance (USD)              float64\n",
      "dtype: object\n"
     ]
    }
   ],
   "source": [
    "print(scdf['Weight (Kilograms)'].value_counts())\n",
    "scdf.drop(scdf[scdf['Weight (Kilograms)'].str.contains('Weight')].index, inplace=True)\n",
    "scdf['Weight (Kilograms)'] = scdf['Weight (Kilograms)'].astype(float)\n",
    "print(scdf['Weight (Kilograms)'].value_counts())\n",
    "print(scdf.dtypes)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => Freight Cost - Country\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Country\"))</th>\n",
       "      <td>9.057243e+10</td>\n",
       "      <td>31.0</td>\n",
       "      <td>13.731741</td>\n",
       "      <td>2.027123e-67</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>9.827808e+11</td>\n",
       "      <td>4619.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                       sum_sq      df          F        PR(>F)\n",
       "C(Q(\"Country\"))  9.057243e+10    31.0  13.731741  2.027123e-67\n",
       "Residual         9.827808e+11  4619.0        NaN           NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => Freight Cost - Fulfill Via\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Fulfill Via\"))</th>\n",
       "      <td>3.264265e+09</td>\n",
       "      <td>1.0</td>\n",
       "      <td>14.181595</td>\n",
       "      <td>0.000168</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>1.070089e+12</td>\n",
       "      <td>4649.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                           sum_sq      df          F    PR(>F)\n",
       "C(Q(\"Fulfill Via\"))  3.264265e+09     1.0  14.181595  0.000168\n",
       "Residual             1.070089e+12  4649.0        NaN       NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => Freight Cost - Shipment Mode\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Shipment Mode\"))</th>\n",
       "      <td>5.860490e+10</td>\n",
       "      <td>3.0</td>\n",
       "      <td>89.459608</td>\n",
       "      <td>2.810795e-56</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>1.014748e+12</td>\n",
       "      <td>4647.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                             sum_sq      df          F        PR(>F)\n",
       "C(Q(\"Shipment Mode\"))  5.860490e+10     3.0  89.459608  2.810795e-56\n",
       "Residual               1.014748e+12  4647.0        NaN           NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => Freight Cost - Product Group\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Product Group\"))</th>\n",
       "      <td>2.772210e+08</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.600388</td>\n",
       "      <td>0.548641</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>1.073076e+12</td>\n",
       "      <td>4648.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                             sum_sq      df         F    PR(>F)\n",
       "C(Q(\"Product Group\"))  2.772210e+08     2.0  0.600388  0.548641\n",
       "Residual               1.073076e+12  4648.0       NaN       NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => Freight Cost - Sub Classification\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Sub Classification\"))</th>\n",
       "      <td>1.968801e+10</td>\n",
       "      <td>3.0</td>\n",
       "      <td>28.943475</td>\n",
       "      <td>1.553266e-18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>1.053665e+12</td>\n",
       "      <td>4647.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                  sum_sq      df          F        PR(>F)\n",
       "C(Q(\"Sub Classification\"))  1.968801e+10     3.0  28.943475  1.553266e-18\n",
       "Residual                    1.053665e+12  4647.0        NaN           NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => Freight Cost - Brand\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Brand\"))</th>\n",
       "      <td>2.542896e+10</td>\n",
       "      <td>20.0</td>\n",
       "      <td>5.617585</td>\n",
       "      <td>1.173442e-14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>1.047924e+12</td>\n",
       "      <td>4630.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     sum_sq      df         F        PR(>F)\n",
       "C(Q(\"Brand\"))  2.542896e+10    20.0  5.617585  1.173442e-14\n",
       "Residual       1.047924e+12  4630.0       NaN           NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => Freight Cost - Dosage Form\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Dosage Form\"))</th>\n",
       "      <td>6.409313e+10</td>\n",
       "      <td>14.0</td>\n",
       "      <td>21.02925</td>\n",
       "      <td>1.069840e-52</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>1.009260e+12</td>\n",
       "      <td>4636.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                           sum_sq      df         F        PR(>F)\n",
       "C(Q(\"Dosage Form\"))  6.409313e+10    14.0  21.02925  1.069840e-52\n",
       "Residual             1.009260e+12  4636.0       NaN           NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#anova\n",
    "y = scdf['Freight Cost (USD)']\n",
    "model = ols('y ~ C(Q(\"Country\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => Freight Cost - Country\")\n",
    "display(anova_table)\n",
    "\n",
    "model = ols('y ~ C(Q(\"Fulfill Via\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => Freight Cost - Fulfill Via\")\n",
    "display(anova_table)\n",
    "\n",
    "model = ols('y ~ C(Q(\"Shipment Mode\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => Freight Cost - Shipment Mode\")\n",
    "display(anova_table)\n",
    "\n",
    "model = ols('y ~ C(Q(\"Product Group\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => Freight Cost - Product Group\")\n",
    "display(anova_table)\n",
    "\n",
    "model = ols('y ~ C(Q(\"Sub Classification\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => Freight Cost - Sub Classification\")\n",
    "display(anova_table)\n",
    "\n",
    "model = ols('y ~ C(Q(\"Brand\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => Freight Cost - Brand\")\n",
    "display(anova_table)\n",
    "\n",
    "model = ols('y ~ C(Q(\"Dosage Form\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => Freight Cost - Dosage Form\")\n",
    "display(anova_table)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => Weight - Country\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Country\"))</th>\n",
       "      <td>2.222340e+10</td>\n",
       "      <td>30.0</td>\n",
       "      <td>13.017833</td>\n",
       "      <td>1.928943e-61</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>2.621614e+11</td>\n",
       "      <td>4607.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                       sum_sq      df          F        PR(>F)\n",
       "C(Q(\"Country\"))  2.222340e+10    30.0  13.017833  1.928943e-61\n",
       "Residual         2.621614e+11  4607.0        NaN           NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => Weight - Fulfill Via\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Fulfill Via\"))</th>\n",
       "      <td>3.553548e+09</td>\n",
       "      <td>1.0</td>\n",
       "      <td>58.662435</td>\n",
       "      <td>2.264085e-14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>2.808313e+11</td>\n",
       "      <td>4636.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                           sum_sq      df          F        PR(>F)\n",
       "C(Q(\"Fulfill Via\"))  3.553548e+09     1.0  58.662435  2.264085e-14\n",
       "Residual             2.808313e+11  4636.0        NaN           NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => Weight - Shipment Mode\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Shipment Mode\"))</th>\n",
       "      <td>2.821230e+10</td>\n",
       "      <td>3.0</td>\n",
       "      <td>170.114267</td>\n",
       "      <td>1.267192e-104</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>2.561725e+11</td>\n",
       "      <td>4634.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                             sum_sq      df           F         PR(>F)\n",
       "C(Q(\"Shipment Mode\"))  2.821230e+10     3.0  170.114267  1.267192e-104\n",
       "Residual               2.561725e+11  4634.0         NaN            NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => Weight - Product Group\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Product Group\"))</th>\n",
       "      <td>2.606464e+08</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2.126</td>\n",
       "      <td>0.11943</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>2.841242e+11</td>\n",
       "      <td>4635.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                             sum_sq      df      F   PR(>F)\n",
       "C(Q(\"Product Group\"))  2.606464e+08     2.0  2.126  0.11943\n",
       "Residual               2.841242e+11  4635.0    NaN      NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => Weight - Sub Classification\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Sub Classification\"))</th>\n",
       "      <td>5.478408e+09</td>\n",
       "      <td>3.0</td>\n",
       "      <td>30.341051</td>\n",
       "      <td>2.033503e-19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>2.789064e+11</td>\n",
       "      <td>4634.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                  sum_sq      df          F        PR(>F)\n",
       "C(Q(\"Sub Classification\"))  5.478408e+09     3.0  30.341051  2.033503e-19\n",
       "Residual                    2.789064e+11  4634.0        NaN           NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => Weight - Brand\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Brand\"))</th>\n",
       "      <td>6.180269e+09</td>\n",
       "      <td>20.0</td>\n",
       "      <td>5.128295</td>\n",
       "      <td>6.399453e-13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>2.782046e+11</td>\n",
       "      <td>4617.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     sum_sq      df         F        PR(>F)\n",
       "C(Q(\"Brand\"))  6.180269e+09    20.0  5.128295  6.399453e-13\n",
       "Residual       2.782046e+11  4617.0       NaN           NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => Weight - Dosage Form\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Dosage Form\"))</th>\n",
       "      <td>2.007175e+10</td>\n",
       "      <td>14.0</td>\n",
       "      <td>25.076239</td>\n",
       "      <td>9.112334e-64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>2.643131e+11</td>\n",
       "      <td>4623.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                           sum_sq      df          F        PR(>F)\n",
       "C(Q(\"Dosage Form\"))  2.007175e+10    14.0  25.076239  9.112334e-64\n",
       "Residual             2.643131e+11  4623.0        NaN           NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#anova\n",
    "y = scdf['Weight (Kilograms)']\n",
    "model = ols('y ~ C(Q(\"Country\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => Weight - Country\")\n",
    "display(anova_table)\n",
    "\n",
    "model = ols('y ~ C(Q(\"Fulfill Via\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => Weight - Fulfill Via\")\n",
    "display(anova_table)\n",
    "\n",
    "model = ols('y ~ C(Q(\"Shipment Mode\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => Weight - Shipment Mode\")\n",
    "display(anova_table)\n",
    "\n",
    "model = ols('y ~ C(Q(\"Product Group\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => Weight - Product Group\")\n",
    "display(anova_table)\n",
    "\n",
    "model = ols('y ~ C(Q(\"Sub Classification\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => Weight - Sub Classification\")\n",
    "display(anova_table)\n",
    "\n",
    "model = ols('y ~ C(Q(\"Brand\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => Weight - Brand\")\n",
    "display(anova_table)\n",
    "\n",
    "model = ols('y ~ C(Q(\"Dosage Form\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => Weight - Dosage Form\")\n",
    "display(anova_table)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => L.I.Insurance - Country\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Country\"))</th>\n",
       "      <td>1.654541e+08</td>\n",
       "      <td>30.0</td>\n",
       "      <td>17.472671</td>\n",
       "      <td>3.195892e-86</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>1.454170e+09</td>\n",
       "      <td>4607.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                       sum_sq      df          F        PR(>F)\n",
       "C(Q(\"Country\"))  1.654541e+08    30.0  17.472671  3.195892e-86\n",
       "Residual         1.454170e+09  4607.0        NaN           NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => L.I.Insurance - Fulfill Via\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Fulfill Via\"))</th>\n",
       "      <td>7.173875e+06</td>\n",
       "      <td>1.0</td>\n",
       "      <td>20.625803</td>\n",
       "      <td>0.000006</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>1.612450e+09</td>\n",
       "      <td>4636.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                           sum_sq      df          F    PR(>F)\n",
       "C(Q(\"Fulfill Via\"))  7.173875e+06     1.0  20.625803  0.000006\n",
       "Residual             1.612450e+09  4636.0        NaN       NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => L.I.Insurance - Shipment Mode\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Shipment Mode\"))</th>\n",
       "      <td>1.354426e+08</td>\n",
       "      <td>3.0</td>\n",
       "      <td>140.962305</td>\n",
       "      <td>2.088483e-87</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>1.484182e+09</td>\n",
       "      <td>4634.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                             sum_sq      df           F        PR(>F)\n",
       "C(Q(\"Shipment Mode\"))  1.354426e+08     3.0  140.962305  2.088483e-87\n",
       "Residual               1.484182e+09  4634.0         NaN           NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => L.I.Insurance - Product Group\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Product Group\"))</th>\n",
       "      <td>2.238604e+06</td>\n",
       "      <td>2.0</td>\n",
       "      <td>3.207623</td>\n",
       "      <td>0.040542</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>1.617386e+09</td>\n",
       "      <td>4635.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                             sum_sq      df         F    PR(>F)\n",
       "C(Q(\"Product Group\"))  2.238604e+06     2.0  3.207623  0.040542\n",
       "Residual               1.617386e+09  4635.0       NaN       NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => L.I.Insurance - Sub Classification\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Sub Classification\"))</th>\n",
       "      <td>9.072895e+07</td>\n",
       "      <td>3.0</td>\n",
       "      <td>91.664868</td>\n",
       "      <td>1.262103e-57</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>1.528895e+09</td>\n",
       "      <td>4634.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                  sum_sq      df          F        PR(>F)\n",
       "C(Q(\"Sub Classification\"))  9.072895e+07     3.0  91.664868  1.262103e-57\n",
       "Residual                    1.528895e+09  4634.0        NaN           NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => L.I.Insurance - Brand\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Brand\"))</th>\n",
       "      <td>4.601020e+07</td>\n",
       "      <td>20.0</td>\n",
       "      <td>6.74972</td>\n",
       "      <td>9.275745e-19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>1.573614e+09</td>\n",
       "      <td>4617.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     sum_sq      df        F        PR(>F)\n",
       "C(Q(\"Brand\"))  4.601020e+07    20.0  6.74972  9.275745e-19\n",
       "Residual       1.573614e+09  4617.0      NaN           NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => L.I.Insurance - Dosage Form\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Dosage Form\"))</th>\n",
       "      <td>1.933081e+08</td>\n",
       "      <td>14.0</td>\n",
       "      <td>44.753809</td>\n",
       "      <td>1.614800e-116</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>1.426316e+09</td>\n",
       "      <td>4623.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                           sum_sq      df          F         PR(>F)\n",
       "C(Q(\"Dosage Form\"))  1.933081e+08    14.0  44.753809  1.614800e-116\n",
       "Residual             1.426316e+09  4623.0        NaN            NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#anova\n",
    "y = scdf['Line Item Insurance (USD)']\n",
    "model = ols('y ~ C(Q(\"Country\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => L.I.Insurance - Country\")\n",
    "display(anova_table)\n",
    "\n",
    "model = ols('y ~ C(Q(\"Fulfill Via\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => L.I.Insurance - Fulfill Via\")\n",
    "display(anova_table)\n",
    "\n",
    "model = ols('y ~ C(Q(\"Shipment Mode\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => L.I.Insurance - Shipment Mode\")\n",
    "display(anova_table)\n",
    "\n",
    "model = ols('y ~ C(Q(\"Product Group\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => L.I.Insurance - Product Group\")\n",
    "display(anova_table)\n",
    "\n",
    "model = ols('y ~ C(Q(\"Sub Classification\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => L.I.Insurance - Sub Classification\")\n",
    "display(anova_table)\n",
    "\n",
    "model = ols('y ~ C(Q(\"Brand\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => L.I.Insurance - Brand\")\n",
    "display(anova_table)\n",
    "\n",
    "model = ols('y ~ C(Q(\"Dosage Form\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => L.I.Insurance - Dosage Form\")\n",
    "display(anova_table)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => L.I.Quantity - Country\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Country\"))</th>\n",
       "      <td>1.418326e+12</td>\n",
       "      <td>30.0</td>\n",
       "      <td>23.690888</td>\n",
       "      <td>2.557637e-120</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>9.193727e+12</td>\n",
       "      <td>4607.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                       sum_sq      df          F         PR(>F)\n",
       "C(Q(\"Country\"))  1.418326e+12    30.0  23.690888  2.557637e-120\n",
       "Residual         9.193727e+12  4607.0        NaN            NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => L.I.Quantity - Fulfill Via\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Fulfill Via\"))</th>\n",
       "      <td>1.182685e+10</td>\n",
       "      <td>1.0</td>\n",
       "      <td>5.172462</td>\n",
       "      <td>0.022993</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>1.060023e+13</td>\n",
       "      <td>4636.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                           sum_sq      df         F    PR(>F)\n",
       "C(Q(\"Fulfill Via\"))  1.182685e+10     1.0  5.172462  0.022993\n",
       "Residual             1.060023e+13  4636.0       NaN       NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => L.I.Quantity - Shipment Mode\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Shipment Mode\"))</th>\n",
       "      <td>1.501780e+12</td>\n",
       "      <td>3.0</td>\n",
       "      <td>254.630165</td>\n",
       "      <td>5.860156e-153</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>9.110273e+12</td>\n",
       "      <td>4634.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                             sum_sq      df           F         PR(>F)\n",
       "C(Q(\"Shipment Mode\"))  1.501780e+12     3.0  254.630165  5.860156e-153\n",
       "Residual               9.110273e+12  4634.0         NaN            NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => L.I.Quantity - Product Group\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Product Group\"))</th>\n",
       "      <td>1.871973e+10</td>\n",
       "      <td>2.0</td>\n",
       "      <td>4.09531</td>\n",
       "      <td>0.016711</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>1.059333e+13</td>\n",
       "      <td>4635.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                             sum_sq      df        F    PR(>F)\n",
       "C(Q(\"Product Group\"))  1.871973e+10     2.0  4.09531  0.016711\n",
       "Residual               1.059333e+13  4635.0      NaN       NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => L.I.Quantity - Sub Classification\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Sub Classification\"))</th>\n",
       "      <td>4.601167e+11</td>\n",
       "      <td>3.0</td>\n",
       "      <td>70.009</td>\n",
       "      <td>2.832091e-44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>1.015194e+13</td>\n",
       "      <td>4634.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                  sum_sq      df       F        PR(>F)\n",
       "C(Q(\"Sub Classification\"))  4.601167e+11     3.0  70.009  2.832091e-44\n",
       "Residual                    1.015194e+13  4634.0     NaN           NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => L.I.Quantity - Brand\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Brand\"))</th>\n",
       "      <td>4.017709e+11</td>\n",
       "      <td>20.0</td>\n",
       "      <td>9.083864</td>\n",
       "      <td>1.873609e-27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>1.021028e+13</td>\n",
       "      <td>4617.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     sum_sq      df         F        PR(>F)\n",
       "C(Q(\"Brand\"))  4.017709e+11    20.0  9.083864  1.873609e-27\n",
       "Residual       1.021028e+13  4617.0       NaN           NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => L.I.Quantity - Dosage Form\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Dosage Form\"))</th>\n",
       "      <td>8.227691e+11</td>\n",
       "      <td>14.0</td>\n",
       "      <td>27.753829</td>\n",
       "      <td>4.632454e-71</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>9.789284e+12</td>\n",
       "      <td>4623.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                           sum_sq      df          F        PR(>F)\n",
       "C(Q(\"Dosage Form\"))  8.227691e+11    14.0  27.753829  4.632454e-71\n",
       "Residual             9.789284e+12  4623.0        NaN           NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#anova\n",
    "y = scdf['Line Item Quantity']\n",
    "model = ols('y ~ C(Q(\"Country\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => L.I.Quantity - Country\")\n",
    "display(anova_table)\n",
    "\n",
    "model = ols('y ~ C(Q(\"Fulfill Via\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => L.I.Quantity - Fulfill Via\")\n",
    "display(anova_table)\n",
    "\n",
    "model = ols('y ~ C(Q(\"Shipment Mode\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => L.I.Quantity - Shipment Mode\")\n",
    "display(anova_table)\n",
    "\n",
    "model = ols('y ~ C(Q(\"Product Group\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => L.I.Quantity - Product Group\")\n",
    "display(anova_table)\n",
    "\n",
    "model = ols('y ~ C(Q(\"Sub Classification\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => L.I.Quantity - Sub Classification\")\n",
    "display(anova_table)\n",
    "\n",
    "model = ols('y ~ C(Q(\"Brand\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => L.I.Quantity - Brand\")\n",
    "display(anova_table)\n",
    "\n",
    "model = ols('y ~ C(Q(\"Dosage Form\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => L.I.Quantity - Dosage Form\")\n",
    "display(anova_table)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => Pack Price - Country\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Country\"))</th>\n",
       "      <td>1.270844e+05</td>\n",
       "      <td>30.0</td>\n",
       "      <td>12.695047</td>\n",
       "      <td>1.217899e-59</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>1.537286e+06</td>\n",
       "      <td>4607.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                       sum_sq      df          F        PR(>F)\n",
       "C(Q(\"Country\"))  1.270844e+05    30.0  12.695047  1.217899e-59\n",
       "Residual         1.537286e+06  4607.0        NaN           NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => Pack Price - Fulfill Via\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Fulfill Via\"))</th>\n",
       "      <td>7.091715e+04</td>\n",
       "      <td>1.0</td>\n",
       "      <td>206.326639</td>\n",
       "      <td>8.262644e-46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>1.593454e+06</td>\n",
       "      <td>4636.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                           sum_sq      df           F        PR(>F)\n",
       "C(Q(\"Fulfill Via\"))  7.091715e+04     1.0  206.326639  8.262644e-46\n",
       "Residual             1.593454e+06  4636.0         NaN           NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => Pack Price - Shipment Mode\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Shipment Mode\"))</th>\n",
       "      <td>6.656995e+04</td>\n",
       "      <td>3.0</td>\n",
       "      <td>64.356201</td>\n",
       "      <td>9.199227e-41</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>1.597801e+06</td>\n",
       "      <td>4634.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                             sum_sq      df          F        PR(>F)\n",
       "C(Q(\"Shipment Mode\"))  6.656995e+04     3.0  64.356201  9.199227e-41\n",
       "Residual               1.597801e+06  4634.0        NaN           NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => Pack Price - Product Group\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Product Group\"))</th>\n",
       "      <td>1.061631e+04</td>\n",
       "      <td>2.0</td>\n",
       "      <td>14.877241</td>\n",
       "      <td>3.626991e-07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>1.653754e+06</td>\n",
       "      <td>4635.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                             sum_sq      df          F        PR(>F)\n",
       "C(Q(\"Product Group\"))  1.061631e+04     2.0  14.877241  3.626991e-07\n",
       "Residual               1.653754e+06  4635.0        NaN           NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => Pack Price - Sub Classification\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Sub Classification\"))</th>\n",
       "      <td>2.719307e+04</td>\n",
       "      <td>3.0</td>\n",
       "      <td>25.656487</td>\n",
       "      <td>1.865123e-16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>1.637178e+06</td>\n",
       "      <td>4634.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                  sum_sq      df          F        PR(>F)\n",
       "C(Q(\"Sub Classification\"))  2.719307e+04     3.0  25.656487  1.865123e-16\n",
       "Residual                    1.637178e+06  4634.0        NaN           NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => Pack Price - Brand\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Brand\"))</th>\n",
       "      <td>923715.254581</td>\n",
       "      <td>20.0</td>\n",
       "      <td>287.906697</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>740655.457018</td>\n",
       "      <td>4617.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                      sum_sq      df           F  PR(>F)\n",
       "C(Q(\"Brand\"))  923715.254581    20.0  287.906697     0.0\n",
       "Residual       740655.457018  4617.0         NaN     NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Anova => Pack Price - Dosage Form\n"
     ]
    },
    {
     "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>sum_sq</th>\n",
       "      <th>df</th>\n",
       "      <th>F</th>\n",
       "      <th>PR(&gt;F)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>C(Q(\"Dosage Form\"))</th>\n",
       "      <td>8.665382e+04</td>\n",
       "      <td>14.0</td>\n",
       "      <td>18.136543</td>\n",
       "      <td>9.434559e-45</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Residual</th>\n",
       "      <td>1.577717e+06</td>\n",
       "      <td>4623.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                           sum_sq      df          F        PR(>F)\n",
       "C(Q(\"Dosage Form\"))  8.665382e+04    14.0  18.136543  9.434559e-45\n",
       "Residual             1.577717e+06  4623.0        NaN           NaN"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#anova\n",
    "y = scdf['Pack Price']\n",
    "model = ols('y ~ C(Q(\"Country\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => Pack Price - Country\")\n",
    "display(anova_table)\n",
    "\n",
    "model = ols('y ~ C(Q(\"Fulfill Via\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => Pack Price - Fulfill Via\")\n",
    "display(anova_table)\n",
    "\n",
    "model = ols('y ~ C(Q(\"Shipment Mode\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => Pack Price - Shipment Mode\")\n",
    "display(anova_table)\n",
    "\n",
    "model = ols('y ~ C(Q(\"Product Group\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => Pack Price - Product Group\")\n",
    "display(anova_table)\n",
    "\n",
    "model = ols('y ~ C(Q(\"Sub Classification\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => Pack Price - Sub Classification\")\n",
    "display(anova_table)\n",
    "\n",
    "model = ols('y ~ C(Q(\"Brand\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => Pack Price - Brand\")\n",
    "display(anova_table)\n",
    "\n",
    "model = ols('y ~ C(Q(\"Dosage Form\"))', data=scdf).fit()\n",
    "anova_table = sm.stats.anova_lm(model, typ=2)\n",
    "print (\"\\nAnova => Pack Price - Dosage Form\")\n",
    "display(anova_table)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "significance=0.050, p=0.000\n",
      "Dependent (reject H0)\n"
     ]
    }
   ],
   "source": [
    "data_crosstab = pd.crosstab(scdf['Dosage Form'], scdf['Vendor INCO Term'], \n",
    "margins = False) \n",
    "#print(data_crosstab) \n",
    "\n",
    "stat, p, dof, expected = chi2_contingency(data_crosstab)\n",
    "#print('dof=%d' % dof)\n",
    "#print(expected)\n",
    "\n",
    "# interpret p-value\n",
    "alpha = 0.05\n",
    "print('significance=%.3f, p=%.3f' % (alpha, p))\n",
    "if p <= alpha:\n",
    "    print('Dependent (reject H0)')\n",
    "else:\n",
    "    print('Independent (fail to reject H0)')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "significance=0.050, p=0.000\n",
      "Dependent (reject H0)\n"
     ]
    }
   ],
   "source": [
    "data_crosstab = pd.crosstab(scdf['Dosage Form'], scdf['Fulfill Via'], \n",
    "margins = False) \n",
    "#print(data_crosstab) \n",
    "\n",
    "stat, p, dof, expected = chi2_contingency(data_crosstab)\n",
    "#print('dof=%d' % dof)\n",
    "#print(expected)\n",
    "\n",
    "# interpret p-value\n",
    "alpha = 0.05\n",
    "print('significance=%.3f, p=%.3f' % (alpha, p))\n",
    "if p <= alpha:\n",
    "    print('Dependent (reject H0)')\n",
    "else:\n",
    "    print('Independent (fail to reject H0)')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "significance=0.050, p=0.000\n",
      "Dependent (reject H0)\n"
     ]
    }
   ],
   "source": [
    "data_crosstab = pd.crosstab(scdf['Dosage Form'], scdf['Shipment Mode'], \n",
    "margins = False) \n",
    "#print(data_crosstab) \n",
    "\n",
    "stat, p, dof, expected = chi2_contingency(data_crosstab)\n",
    "#print('dof=%d' % dof)\n",
    "#print(expected)\n",
    "\n",
    "# interpret p-value\n",
    "alpha = 0.05\n",
    "print('significance=%.3f, p=%.3f' % (alpha, p))\n",
    "if p <= alpha:\n",
    "    print('Dependent (reject H0)')\n",
    "else:\n",
    "    print('Independent (fail to reject H0)')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 14980 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 15060 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 14128 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 16616 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 12888 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 13824 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "qqplot(scdf['Freight Cost (USD)'], line='s')\n",
    "pyplot.show()\n",
    "\n",
    "qqplot(scdf['Weight (Kilograms)'], line='s')\n",
    "pyplot.show()\n",
    "\n",
    "qqplot(scdf['Line Item Insurance (USD)'], line='s')\n",
    "pyplot.show()\n",
    "\n",
    "qqplot(scdf['Line Item Quantity'], line='s')\n",
    "pyplot.show()\n",
    "\n",
    "qqplot(scdf['Line Item Value'], line='s')\n",
    "pyplot.show()\n",
    "\n",
    "qqplot(scdf['Pack Price'], line='s')\n",
    "pyplot.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "metadata": {},
   "outputs": [],
   "source": [
    "scdf.to_csv('scdf.clean.csv')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "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.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
