{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "83260f6b",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "4e3ef9eb",
   "metadata": {},
   "outputs": [],
   "source": [
    "alott = pd.read_csv('alloted.csv')\n",
    "paid= pd.read_csv('paid.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "4cb2dcf6",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Product</th>\n",
       "      <th>Loan Type</th>\n",
       "      <th>TOTAL OD ( OD + CHARGES )</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>TW</td>\n",
       "      <td>Two wheeler loan</td>\n",
       "      <td>37186.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>CA</td>\n",
       "      <td>Car Loan</td>\n",
       "      <td>670641.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>TW</td>\n",
       "      <td>Two wheeler loan</td>\n",
       "      <td>15930.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>TW</td>\n",
       "      <td>Two wheeler loan</td>\n",
       "      <td>15815.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>TW</td>\n",
       "      <td>Two wheeler loan</td>\n",
       "      <td>9410.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Product         Loan Type  TOTAL OD ( OD + CHARGES )\n",
       "0      TW  Two wheeler loan                    37186.0\n",
       "1      CA          Car Loan                   670641.0\n",
       "2      TW  Two wheeler loan                    15930.0\n",
       "3      TW  Two wheeler loan                    15815.0\n",
       "4      TW  Two wheeler loan                     9410.0"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "alott.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "0104d88e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>AMOUNT COLLECTED</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2577.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2165.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>5000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1825.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2300.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   AMOUNT COLLECTED\n",
       "0            2577.0\n",
       "1            2165.0\n",
       "2            5000.0\n",
       "3            1825.0\n",
       "4            2300.0"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "paid.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "0284f198",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-8612"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(alott[(alott.iloc[:,-1]<5000) &  (alott[(alott.iloc[:,-1]>3000)  ]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "9ef5d9f3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "24"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len( alott[(alott.iloc[:,-1]>= 0)  & (alott.iloc[:,-1]<1000)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "82846b4d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4594"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len( alott[(alott.iloc[:,-1]>= 1000)  & (alott.iloc[:,-1]<3000)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "8fb9d8ad",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "686"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len( alott[(alott.iloc[:,-1]>= 3000)  & (alott.iloc[:,-1]<5000)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "24808de7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "477"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len( alott[(alott.iloc[:,-1]>= 5000)  & (alott.iloc[:,-1]<10000)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "e1c0533e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5832"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len( alott[(alott.iloc[:,-1]>= 10000)  & (alott.iloc[:,-1]<20000)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "3c0db91b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "6942"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len( alott[(alott.iloc[:,-1]>= 20000)  ])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "e9d4aeba",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "18555"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "6942+5832+477+686+4594+24"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "7f8dd703",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.19757477768795473"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(paid)/len(alott)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "id": "f10cfd83",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Loan Type</th>\n",
       "      <th>TOTAL OD ( OD + CHARGES )</th>\n",
       "      <th>paid</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Product</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>CA</th>\n",
       "      <td>512</td>\n",
       "      <td>512</td>\n",
       "      <td>512</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>CT</th>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>TW</th>\n",
       "      <td>2821</td>\n",
       "      <td>2821</td>\n",
       "      <td>2821</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>UT</th>\n",
       "      <td>319</td>\n",
       "      <td>319</td>\n",
       "      <td>319</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         Loan Type  TOTAL OD ( OD + CHARGES )  paid\n",
       "Product                                            \n",
       "CA             512                        512   512\n",
       "CT              14                         14    14\n",
       "TW            2821                       2821  2821\n",
       "UT             319                        319   319"
      ]
     },
     "execution_count": 98,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "alott.groupby('Product').count()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "34078f46",
   "metadata": {},
   "outputs": [],
   "source": [
    "alott['paid']= pd.Series(paid.iloc[:,-1].to_list())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "f7cb77ab",
   "metadata": {},
   "outputs": [],
   "source": [
    "alott.dropna(inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "id": "25b48a13",
   "metadata": {},
   "outputs": [],
   "source": [
    "a=alott.groupby('Loan Type').sum().astype(int)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "id": "774005cf",
   "metadata": {},
   "outputs": [],
   "source": [
    "a['%']= round(a.iloc[:,1].div(a.iloc[:,0])*100, 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "id": "8391cff9",
   "metadata": {},
   "outputs": [],
   "source": [
    "a.to_csv('F.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "id": "69a8c461",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Product</th>\n",
       "      <th>Loan Type</th>\n",
       "      <th>TOTAL OD ( OD + CHARGES )</th>\n",
       "      <th>paid</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>TW</td>\n",
       "      <td>Two wheeler loan</td>\n",
       "      <td>37186.0</td>\n",
       "      <td>2577.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>CA</td>\n",
       "      <td>Car Loan</td>\n",
       "      <td>670641.0</td>\n",
       "      <td>2165.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>TW</td>\n",
       "      <td>Two wheeler loan</td>\n",
       "      <td>15930.0</td>\n",
       "      <td>5000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>TW</td>\n",
       "      <td>Two wheeler loan</td>\n",
       "      <td>15815.0</td>\n",
       "      <td>1825.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>TW</td>\n",
       "      <td>Two wheeler loan</td>\n",
       "      <td>9410.0</td>\n",
       "      <td>2300.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3561</th>\n",
       "      <td>TW</td>\n",
       "      <td>Two wheeler loan</td>\n",
       "      <td>23070.0</td>\n",
       "      <td>21000.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3562</th>\n",
       "      <td>TW</td>\n",
       "      <td>Two wheeler loan</td>\n",
       "      <td>16376.0</td>\n",
       "      <td>100.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3563</th>\n",
       "      <td>TW</td>\n",
       "      <td>Two wheeler loan</td>\n",
       "      <td>23236.0</td>\n",
       "      <td>3652.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3564</th>\n",
       "      <td>TW</td>\n",
       "      <td>Two wheeler loan</td>\n",
       "      <td>30772.0</td>\n",
       "      <td>83.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3565</th>\n",
       "      <td>UT</td>\n",
       "      <td>Two wheeler top up loan</td>\n",
       "      <td>25631.0</td>\n",
       "      <td>100.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3566 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     Product                Loan Type  TOTAL OD ( OD + CHARGES )     paid\n",
       "0         TW         Two wheeler loan                    37186.0   2577.0\n",
       "1         CA                 Car Loan                   670641.0   2165.0\n",
       "2         TW         Two wheeler loan                    15930.0   5000.0\n",
       "3         TW         Two wheeler loan                    15815.0   1825.0\n",
       "4         TW         Two wheeler loan                     9410.0   2300.0\n",
       "...      ...                      ...                        ...      ...\n",
       "3561      TW         Two wheeler loan                    23070.0  21000.0\n",
       "3562      TW         Two wheeler loan                    16376.0    100.0\n",
       "3563      TW         Two wheeler loan                    23236.0   3652.0\n",
       "3564      TW         Two wheeler loan                    30772.0     83.0\n",
       "3565      UT  Two wheeler top up loan                    25631.0    100.0\n",
       "\n",
       "[3566 rows x 4 columns]"
      ]
     },
     "execution_count": 88,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "alott.head(-100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "id": "e1148e04",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "318"
      ]
     },
     "execution_count": 85,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len( paid[(paid.iloc[:,-1]>= 0)  & (paid.iloc[:,-1]<1000)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "id": "e0be2298",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1861"
      ]
     },
     "execution_count": 87,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len( paid[(paid.iloc[:,-1]>= 1000)  & (paid.iloc[:,-1]<3000)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "id": "aa803d27",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1144"
      ]
     },
     "execution_count": 89,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len( paid[(paid.iloc[:,-1]>= 3000)  & (paid.iloc[:,-1]<5000)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "id": "ec371195",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "250"
      ]
     },
     "execution_count": 90,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len( paid[(paid.iloc[:,-1]>= 5000)  & (paid.iloc[:,-1]<10000)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "id": "6a9a2824",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "63"
      ]
     },
     "execution_count": 96,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len( paid[(paid.iloc[:,-1]>= 10000)  & (paid.iloc[:,-1]<20000)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "id": "d33880b8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "30"
      ]
     },
     "execution_count": 97,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len( paid[(paid.iloc[:,-1]>= 20000) ])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "487ab3d7",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "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.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
