{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "59b61714",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "05b4de3b",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "e0861ca3",
   "metadata": {},
   "outputs": [],
   "source": [
    "texts= pd.read_csv('Final1.0.tsv', sep='\\t').dropna(axis=0).iloc[:,-2].values.reshape(-1,).astype('object')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b8b9f9dd",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "35dbfd76",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c0215db5",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "f1d3aa7e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'prison,warden,inmate,solitary,parole,cell,rock,library,prisoner,hammer,guard,state,wall,poster,red,remark,diploma,book,job,infirmary,financial,record,hope,banker,shoe,stone,project,night,several,senate,fat,oak,commemorate,beam,work,cold,hole,halfway,wooden,office,salvation,scheme,letter,contractor,expertise,morning,promise,giant,order,tax,month'"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "texts[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "dae810d8",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "12644df4",
   "metadata": {},
   "outputs": [],
   "source": [
    "corpus=[]\n",
    "for text in texts:\n",
    "    text=text.replace(',',' ').split(' ')\n",
    "    corpus.append(text)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "d8fdbf16",
   "metadata": {},
   "outputs": [],
   "source": [
    "df=pd.DataFrame(corpus)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "c23457ab",
   "metadata": {},
   "outputs": [],
   "source": [
    "df=df.iloc[:,:51]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "c9a463ad",
   "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>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>...</th>\n",
       "      <th>41</th>\n",
       "      <th>42</th>\n",
       "      <th>43</th>\n",
       "      <th>44</th>\n",
       "      <th>45</th>\n",
       "      <th>46</th>\n",
       "      <th>47</th>\n",
       "      <th>48</th>\n",
       "      <th>49</th>\n",
       "      <th>50</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>prison</td>\n",
       "      <td>warden</td>\n",
       "      <td>inmate</td>\n",
       "      <td>solitary</td>\n",
       "      <td>parole</td>\n",
       "      <td>cell</td>\n",
       "      <td>rock</td>\n",
       "      <td>library</td>\n",
       "      <td>prisoner</td>\n",
       "      <td>hammer</td>\n",
       "      <td>...</td>\n",
       "      <td>scheme</td>\n",
       "      <td>letter</td>\n",
       "      <td>contractor</td>\n",
       "      <td>expertise</td>\n",
       "      <td>morning</td>\n",
       "      <td>promise</td>\n",
       "      <td>giant</td>\n",
       "      <td>order</td>\n",
       "      <td>tax</td>\n",
       "      <td>month</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>mob</td>\n",
       "      <td>coin</td>\n",
       "      <td>clown</td>\n",
       "      <td>ferry</td>\n",
       "      <td>member</td>\n",
       "      <td>building</td>\n",
       "      <td>cell</td>\n",
       "      <td>detonator</td>\n",
       "      <td>police</td>\n",
       "      <td>mayor</td>\n",
       "      <td>...</td>\n",
       "      <td>clean</td>\n",
       "      <td>citizen</td>\n",
       "      <td>scarred</td>\n",
       "      <td>cancel</td>\n",
       "      <td>raiser</td>\n",
       "      <td>people</td>\n",
       "      <td>convoy</td>\n",
       "      <td>tell</td>\n",
       "      <td>fight</td>\n",
       "      <td>family</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>dream</td>\n",
       "      <td>limbo</td>\n",
       "      <td>team</td>\n",
       "      <td>subconscious</td>\n",
       "      <td>projection</td>\n",
       "      <td>kick</td>\n",
       "      <td>top</td>\n",
       "      <td>level</td>\n",
       "      <td>father</td>\n",
       "      <td>mind</td>\n",
       "      <td>...</td>\n",
       "      <td>guard</td>\n",
       "      <td>mob</td>\n",
       "      <td>subjective</td>\n",
       "      <td>idea</td>\n",
       "      <td>architect</td>\n",
       "      <td>spin</td>\n",
       "      <td>extractor</td>\n",
       "      <td>access</td>\n",
       "      <td>combination</td>\n",
       "      <td>train</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>narrator</td>\n",
       "      <td>soap</td>\n",
       "      <td>member</td>\n",
       "      <td>fight</td>\n",
       "      <td>club</td>\n",
       "      <td>consumerism</td>\n",
       "      <td>insomnia</td>\n",
       "      <td>testicular</td>\n",
       "      <td>building</td>\n",
       "      <td>burn</td>\n",
       "      <td>...</td>\n",
       "      <td>gynecomastia</td>\n",
       "      <td>glistened</td>\n",
       "      <td>detriment</td>\n",
       "      <td>cancer</td>\n",
       "      <td>fighting</td>\n",
       "      <td>destruction</td>\n",
       "      <td>period</td>\n",
       "      <td>substandard</td>\n",
       "      <td>liposuction</td>\n",
       "      <td>lag</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>watch</td>\n",
       "      <td>tyranny</td>\n",
       "      <td>apartment</td>\n",
       "      <td>strip</td>\n",
       "      <td>pawn</td>\n",
       "      <td>miracle</td>\n",
       "      <td>car</td>\n",
       "      <td>briefcase</td>\n",
       "      <td>wallet</td>\n",
       "      <td>gang</td>\n",
       "      <td>...</td>\n",
       "      <td>leave</td>\n",
       "      <td>rectum</td>\n",
       "      <td>evil</td>\n",
       "      <td>travel</td>\n",
       "      <td>offscreen</td>\n",
       "      <td>talk</td>\n",
       "      <td>pow</td>\n",
       "      <td>suit</td>\n",
       "      <td>passersby</td>\n",
       "      <td>discreet</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7133</th>\n",
       "      <td>donkey</td>\n",
       "      <td>voice</td>\n",
       "      <td>manger</td>\n",
       "      <td>camel</td>\n",
       "      <td>messiah</td>\n",
       "      <td>dog</td>\n",
       "      <td>animal</td>\n",
       "      <td>baby</td>\n",
       "      <td>cart</td>\n",
       "      <td>cliff</td>\n",
       "      <td>...</td>\n",
       "      <td>outcome</td>\n",
       "      <td>belong</td>\n",
       "      <td>kindness</td>\n",
       "      <td>liking</td>\n",
       "      <td>well</td>\n",
       "      <td>cow</td>\n",
       "      <td>awe</td>\n",
       "      <td>guidance</td>\n",
       "      <td>diversion</td>\n",
       "      <td>save</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7134</th>\n",
       "      <td>memory</td>\n",
       "      <td>asylum</td>\n",
       "      <td>lapse</td>\n",
       "      <td>amnesia</td>\n",
       "      <td>marriage</td>\n",
       "      <td>sensing</td>\n",
       "      <td>town</td>\n",
       "      <td>married</td>\n",
       "      <td>loveless</td>\n",
       "      <td>revel</td>\n",
       "      <td>...</td>\n",
       "      <td>first</td>\n",
       "      <td>rich</td>\n",
       "      <td>famous</td>\n",
       "      <td>staff</td>\n",
       "      <td>interview</td>\n",
       "      <td>remember</td>\n",
       "      <td>quiet</td>\n",
       "      <td>shock</td>\n",
       "      <td>career</td>\n",
       "      <td>begin</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7135</th>\n",
       "      <td>blimp</td>\n",
       "      <td>helicopter</td>\n",
       "      <td>gondola</td>\n",
       "      <td>stadium</td>\n",
       "      <td>israeli</td>\n",
       "      <td>compound</td>\n",
       "      <td>shrapnel</td>\n",
       "      <td>commando</td>\n",
       "      <td>mission</td>\n",
       "      <td>captain</td>\n",
       "      <td>...</td>\n",
       "      <td>offset</td>\n",
       "      <td>hospital</td>\n",
       "      <td>underbelly</td>\n",
       "      <td>repression</td>\n",
       "      <td>nurse</td>\n",
       "      <td>wounding</td>\n",
       "      <td>wording</td>\n",
       "      <td>piloting</td>\n",
       "      <td>rifle</td>\n",
       "      <td>bazaar</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7136</th>\n",
       "      <td>computer</td>\n",
       "      <td>musical</td>\n",
       "      <td>talent</td>\n",
       "      <td>human</td>\n",
       "      <td>sexology</td>\n",
       "      <td>romance</td>\n",
       "      <td>prodigious</td>\n",
       "      <td>cellist</td>\n",
       "      <td>neo</td>\n",
       "      <td>accessible</td>\n",
       "      <td>...</td>\n",
       "      <td>less</td>\n",
       "      <td>identity</td>\n",
       "      <td>card</td>\n",
       "      <td>thank</td>\n",
       "      <td>personal</td>\n",
       "      <td>revenge</td>\n",
       "      <td>beautiful</td>\n",
       "      <td>suicide</td>\n",
       "      <td>credit</td>\n",
       "      <td>state</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7137</th>\n",
       "      <td>hotel</td>\n",
       "      <td>win</td>\n",
       "      <td>contest</td>\n",
       "      <td>affection</td>\n",
       "      <td>necessary</td>\n",
       "      <td>talent</td>\n",
       "      <td>engine</td>\n",
       "      <td>nubile</td>\n",
       "      <td>cash</td>\n",
       "      <td>pool</td>\n",
       "      <td>...</td>\n",
       "      <td>main</td>\n",
       "      <td>song</td>\n",
       "      <td>need</td>\n",
       "      <td>form</td>\n",
       "      <td>table</td>\n",
       "      <td>say</td>\n",
       "      <td>hour</td>\n",
       "      <td>event</td>\n",
       "      <td>city</td>\n",
       "      <td>attempt</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>7138 rows × 51 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            0           1          2             3           4            5   \\\n",
       "0       prison      warden     inmate      solitary      parole         cell   \n",
       "1          mob        coin      clown         ferry      member     building   \n",
       "2        dream       limbo       team  subconscious  projection         kick   \n",
       "3     narrator        soap     member         fight        club  consumerism   \n",
       "4        watch     tyranny  apartment         strip        pawn      miracle   \n",
       "...        ...         ...        ...           ...         ...          ...   \n",
       "7133    donkey       voice     manger         camel     messiah          dog   \n",
       "7134    memory      asylum      lapse       amnesia    marriage      sensing   \n",
       "7135     blimp  helicopter    gondola       stadium     israeli     compound   \n",
       "7136  computer     musical     talent         human    sexology      romance   \n",
       "7137     hotel         win    contest     affection   necessary       talent   \n",
       "\n",
       "              6           7         8           9   ...            41  \\\n",
       "0           rock     library  prisoner      hammer  ...        scheme   \n",
       "1           cell   detonator    police       mayor  ...         clean   \n",
       "2            top       level    father        mind  ...         guard   \n",
       "3       insomnia  testicular  building        burn  ...  gynecomastia   \n",
       "4            car   briefcase    wallet        gang  ...         leave   \n",
       "...          ...         ...       ...         ...  ...           ...   \n",
       "7133      animal        baby      cart       cliff  ...       outcome   \n",
       "7134        town     married  loveless       revel  ...         first   \n",
       "7135    shrapnel    commando   mission     captain  ...        offset   \n",
       "7136  prodigious     cellist       neo  accessible  ...          less   \n",
       "7137      engine      nubile      cash        pool  ...          main   \n",
       "\n",
       "             42          43          44         45           46         47  \\\n",
       "0        letter  contractor   expertise    morning      promise      giant   \n",
       "1       citizen     scarred      cancel     raiser       people     convoy   \n",
       "2           mob  subjective        idea  architect         spin  extractor   \n",
       "3     glistened   detriment      cancer   fighting  destruction     period   \n",
       "4        rectum        evil      travel  offscreen         talk        pow   \n",
       "...         ...         ...         ...        ...          ...        ...   \n",
       "7133     belong    kindness      liking       well          cow        awe   \n",
       "7134       rich      famous       staff  interview     remember      quiet   \n",
       "7135   hospital  underbelly  repression      nurse     wounding    wording   \n",
       "7136   identity        card       thank   personal      revenge  beautiful   \n",
       "7137       song        need        form      table          say       hour   \n",
       "\n",
       "               48           49        50  \n",
       "0           order          tax     month  \n",
       "1            tell        fight    family  \n",
       "2          access  combination     train  \n",
       "3     substandard  liposuction       lag  \n",
       "4            suit    passersby  discreet  \n",
       "...           ...          ...       ...  \n",
       "7133     guidance    diversion      save  \n",
       "7134        shock       career     begin  \n",
       "7135     piloting        rifle    bazaar  \n",
       "7136      suicide       credit     state  \n",
       "7137        event         city   attempt  \n",
       "\n",
       "[7138 rows x 51 columns]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "a7d18f13",
   "metadata": {},
   "outputs": [],
   "source": [
    "movies= pd.read_csv('Final1.0.tsv', sep='\\t').dropna(axis=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "8f2a8d42",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "204"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(np.where(df=='detective')[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cb9c6af8",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "b14d43f3",
   "metadata": {},
   "outputs": [],
   "source": [
    "def count_f(array):\n",
    "    global movies\n",
    "    unique, counts = np.unique(array, return_counts=True)\n",
    "    array=dict(zip(unique, counts))\n",
    "    array={movies.iloc[k,3]: v for k, v in sorted(array.items(), key=lambda item: item[1], reverse=True)} #set to true\n",
    "    #print(array)\n",
    "    return array"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "ad4b9498",
   "metadata": {},
   "outputs": [],
   "source": [
    "def check(word):\n",
    "    global df\n",
    "    array= np.where(df== word)[0]\n",
    "    array= count_f(array)\n",
    "    return array"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "96ee49f5",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a4658f04",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "b4ea4bbf",
   "metadata": {},
   "outputs": [],
   "source": [
    "scores=pd.read_csv('Final1.0.tsv', sep='\\t').dropna(axis=0).iloc[:,-1].values.reshape(-1,).astype('object')\n",
    "Scores=[]\n",
    "for score in scores:\n",
    "    score=score.replace(',',' ').split(' ')\n",
    "    Scores.append(score)\n",
    "scores= Scores\n",
    "del Scores"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "4984247e",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_scores= pd.DataFrame(scores)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "c959211d",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_scores= pd.DataFrame(df_scores.values.astype('float64'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "7f06cd24",
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.preprocessing import MinMaxScaler\n",
    "scaler=MinMaxScaler()\n",
    "df_scores= pd.DataFrame(scaler.fit_transform(df_scores.T).T)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "4550c660",
   "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>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>...</th>\n",
       "      <th>41</th>\n",
       "      <th>42</th>\n",
       "      <th>43</th>\n",
       "      <th>44</th>\n",
       "      <th>45</th>\n",
       "      <th>46</th>\n",
       "      <th>47</th>\n",
       "      <th>48</th>\n",
       "      <th>49</th>\n",
       "      <th>50</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1.0</td>\n",
       "      <td>0.755548</td>\n",
       "      <td>0.516569</td>\n",
       "      <td>0.370019</td>\n",
       "      <td>0.354113</td>\n",
       "      <td>0.346381</td>\n",
       "      <td>0.265516</td>\n",
       "      <td>0.223706</td>\n",
       "      <td>0.207225</td>\n",
       "      <td>0.203137</td>\n",
       "      <td>...</td>\n",
       "      <td>0.019495</td>\n",
       "      <td>0.019415</td>\n",
       "      <td>0.012939</td>\n",
       "      <td>0.011900</td>\n",
       "      <td>0.003119</td>\n",
       "      <td>0.001927</td>\n",
       "      <td>0.001265</td>\n",
       "      <td>0.001077</td>\n",
       "      <td>0.000897</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1.0</td>\n",
       "      <td>0.982025</td>\n",
       "      <td>0.674399</td>\n",
       "      <td>0.475043</td>\n",
       "      <td>0.440328</td>\n",
       "      <td>0.334633</td>\n",
       "      <td>0.270100</td>\n",
       "      <td>0.255652</td>\n",
       "      <td>0.250846</td>\n",
       "      <td>0.247755</td>\n",
       "      <td>...</td>\n",
       "      <td>0.030026</td>\n",
       "      <td>0.021776</td>\n",
       "      <td>0.015622</td>\n",
       "      <td>0.015045</td>\n",
       "      <td>0.010921</td>\n",
       "      <td>0.003817</td>\n",
       "      <td>0.001934</td>\n",
       "      <td>0.000669</td>\n",
       "      <td>0.000344</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1.0</td>\n",
       "      <td>0.487479</td>\n",
       "      <td>0.374296</td>\n",
       "      <td>0.312861</td>\n",
       "      <td>0.258648</td>\n",
       "      <td>0.202134</td>\n",
       "      <td>0.172212</td>\n",
       "      <td>0.152482</td>\n",
       "      <td>0.136579</td>\n",
       "      <td>0.133342</td>\n",
       "      <td>...</td>\n",
       "      <td>0.012002</td>\n",
       "      <td>0.011735</td>\n",
       "      <td>0.011297</td>\n",
       "      <td>0.010592</td>\n",
       "      <td>0.010362</td>\n",
       "      <td>0.008763</td>\n",
       "      <td>0.008363</td>\n",
       "      <td>0.006293</td>\n",
       "      <td>0.005252</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1.0</td>\n",
       "      <td>0.072752</td>\n",
       "      <td>0.053369</td>\n",
       "      <td>0.047452</td>\n",
       "      <td>0.046559</td>\n",
       "      <td>0.045987</td>\n",
       "      <td>0.034223</td>\n",
       "      <td>0.022402</td>\n",
       "      <td>0.022392</td>\n",
       "      <td>0.020933</td>\n",
       "      <td>...</td>\n",
       "      <td>0.002023</td>\n",
       "      <td>0.002023</td>\n",
       "      <td>0.002023</td>\n",
       "      <td>0.001170</td>\n",
       "      <td>0.000895</td>\n",
       "      <td>0.000426</td>\n",
       "      <td>0.000205</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1.0</td>\n",
       "      <td>0.941521</td>\n",
       "      <td>0.759417</td>\n",
       "      <td>0.703850</td>\n",
       "      <td>0.616894</td>\n",
       "      <td>0.591422</td>\n",
       "      <td>0.563199</td>\n",
       "      <td>0.525677</td>\n",
       "      <td>0.495557</td>\n",
       "      <td>0.421539</td>\n",
       "      <td>...</td>\n",
       "      <td>0.022274</td>\n",
       "      <td>0.017472</td>\n",
       "      <td>0.016766</td>\n",
       "      <td>0.010472</td>\n",
       "      <td>0.008152</td>\n",
       "      <td>0.008037</td>\n",
       "      <td>0.003949</td>\n",
       "      <td>0.003300</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7133</th>\n",
       "      <td>1.0</td>\n",
       "      <td>0.704797</td>\n",
       "      <td>0.470819</td>\n",
       "      <td>0.375715</td>\n",
       "      <td>0.311371</td>\n",
       "      <td>0.262565</td>\n",
       "      <td>0.212278</td>\n",
       "      <td>0.169312</td>\n",
       "      <td>0.147401</td>\n",
       "      <td>0.115342</td>\n",
       "      <td>...</td>\n",
       "      <td>0.003842</td>\n",
       "      <td>0.003842</td>\n",
       "      <td>0.003421</td>\n",
       "      <td>0.003214</td>\n",
       "      <td>0.002768</td>\n",
       "      <td>0.001836</td>\n",
       "      <td>0.001836</td>\n",
       "      <td>0.001648</td>\n",
       "      <td>0.000740</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7134</th>\n",
       "      <td>1.0</td>\n",
       "      <td>0.598847</td>\n",
       "      <td>0.498366</td>\n",
       "      <td>0.431530</td>\n",
       "      <td>0.318833</td>\n",
       "      <td>0.234392</td>\n",
       "      <td>0.203699</td>\n",
       "      <td>0.186739</td>\n",
       "      <td>0.185623</td>\n",
       "      <td>0.179766</td>\n",
       "      <td>...</td>\n",
       "      <td>0.027961</td>\n",
       "      <td>0.022676</td>\n",
       "      <td>0.019717</td>\n",
       "      <td>0.015482</td>\n",
       "      <td>0.014677</td>\n",
       "      <td>0.014577</td>\n",
       "      <td>0.014379</td>\n",
       "      <td>0.011021</td>\n",
       "      <td>0.010102</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7135</th>\n",
       "      <td>1.0</td>\n",
       "      <td>0.215165</td>\n",
       "      <td>0.193208</td>\n",
       "      <td>0.164044</td>\n",
       "      <td>0.159077</td>\n",
       "      <td>0.098998</td>\n",
       "      <td>0.098932</td>\n",
       "      <td>0.089912</td>\n",
       "      <td>0.075984</td>\n",
       "      <td>0.071009</td>\n",
       "      <td>...</td>\n",
       "      <td>0.002979</td>\n",
       "      <td>0.002253</td>\n",
       "      <td>0.001864</td>\n",
       "      <td>0.001864</td>\n",
       "      <td>0.000957</td>\n",
       "      <td>0.000880</td>\n",
       "      <td>0.000880</td>\n",
       "      <td>0.000880</td>\n",
       "      <td>0.000717</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7136</th>\n",
       "      <td>1.0</td>\n",
       "      <td>0.978077</td>\n",
       "      <td>0.856738</td>\n",
       "      <td>0.772813</td>\n",
       "      <td>0.540052</td>\n",
       "      <td>0.496046</td>\n",
       "      <td>0.418116</td>\n",
       "      <td>0.398489</td>\n",
       "      <td>0.357148</td>\n",
       "      <td>0.346789</td>\n",
       "      <td>...</td>\n",
       "      <td>0.041341</td>\n",
       "      <td>0.038359</td>\n",
       "      <td>0.036330</td>\n",
       "      <td>0.035050</td>\n",
       "      <td>0.028916</td>\n",
       "      <td>0.022444</td>\n",
       "      <td>0.016875</td>\n",
       "      <td>0.013717</td>\n",
       "      <td>0.003678</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7137</th>\n",
       "      <td>1.0</td>\n",
       "      <td>0.644272</td>\n",
       "      <td>0.556504</td>\n",
       "      <td>0.541436</td>\n",
       "      <td>0.497082</td>\n",
       "      <td>0.471457</td>\n",
       "      <td>0.463579</td>\n",
       "      <td>0.451180</td>\n",
       "      <td>0.384809</td>\n",
       "      <td>0.361875</td>\n",
       "      <td>...</td>\n",
       "      <td>0.062042</td>\n",
       "      <td>0.061583</td>\n",
       "      <td>0.050700</td>\n",
       "      <td>0.048053</td>\n",
       "      <td>0.037763</td>\n",
       "      <td>0.033963</td>\n",
       "      <td>0.025048</td>\n",
       "      <td>0.015810</td>\n",
       "      <td>0.009114</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>7138 rows × 51 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       0         1         2         3         4         5         6   \\\n",
       "0     1.0  0.755548  0.516569  0.370019  0.354113  0.346381  0.265516   \n",
       "1     1.0  0.982025  0.674399  0.475043  0.440328  0.334633  0.270100   \n",
       "2     1.0  0.487479  0.374296  0.312861  0.258648  0.202134  0.172212   \n",
       "3     1.0  0.072752  0.053369  0.047452  0.046559  0.045987  0.034223   \n",
       "4     1.0  0.941521  0.759417  0.703850  0.616894  0.591422  0.563199   \n",
       "...   ...       ...       ...       ...       ...       ...       ...   \n",
       "7133  1.0  0.704797  0.470819  0.375715  0.311371  0.262565  0.212278   \n",
       "7134  1.0  0.598847  0.498366  0.431530  0.318833  0.234392  0.203699   \n",
       "7135  1.0  0.215165  0.193208  0.164044  0.159077  0.098998  0.098932   \n",
       "7136  1.0  0.978077  0.856738  0.772813  0.540052  0.496046  0.418116   \n",
       "7137  1.0  0.644272  0.556504  0.541436  0.497082  0.471457  0.463579   \n",
       "\n",
       "            7         8         9   ...        41        42        43  \\\n",
       "0     0.223706  0.207225  0.203137  ...  0.019495  0.019415  0.012939   \n",
       "1     0.255652  0.250846  0.247755  ...  0.030026  0.021776  0.015622   \n",
       "2     0.152482  0.136579  0.133342  ...  0.012002  0.011735  0.011297   \n",
       "3     0.022402  0.022392  0.020933  ...  0.002023  0.002023  0.002023   \n",
       "4     0.525677  0.495557  0.421539  ...  0.022274  0.017472  0.016766   \n",
       "...        ...       ...       ...  ...       ...       ...       ...   \n",
       "7133  0.169312  0.147401  0.115342  ...  0.003842  0.003842  0.003421   \n",
       "7134  0.186739  0.185623  0.179766  ...  0.027961  0.022676  0.019717   \n",
       "7135  0.089912  0.075984  0.071009  ...  0.002979  0.002253  0.001864   \n",
       "7136  0.398489  0.357148  0.346789  ...  0.041341  0.038359  0.036330   \n",
       "7137  0.451180  0.384809  0.361875  ...  0.062042  0.061583  0.050700   \n",
       "\n",
       "            44        45        46        47        48        49   50  \n",
       "0     0.011900  0.003119  0.001927  0.001265  0.001077  0.000897  0.0  \n",
       "1     0.015045  0.010921  0.003817  0.001934  0.000669  0.000344  0.0  \n",
       "2     0.010592  0.010362  0.008763  0.008363  0.006293  0.005252  0.0  \n",
       "3     0.001170  0.000895  0.000426  0.000205  0.000000  0.000000  0.0  \n",
       "4     0.010472  0.008152  0.008037  0.003949  0.003300  0.000000  0.0  \n",
       "...        ...       ...       ...       ...       ...       ...  ...  \n",
       "7133  0.003214  0.002768  0.001836  0.001836  0.001648  0.000740  0.0  \n",
       "7134  0.015482  0.014677  0.014577  0.014379  0.011021  0.010102  0.0  \n",
       "7135  0.001864  0.000957  0.000880  0.000880  0.000880  0.000717  0.0  \n",
       "7136  0.035050  0.028916  0.022444  0.016875  0.013717  0.003678  0.0  \n",
       "7137  0.048053  0.037763  0.033963  0.025048  0.015810  0.009114  0.0  \n",
       "\n",
       "[7138 rows x 51 columns]"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_scores"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 155,
   "id": "e4057031",
   "metadata": {},
   "outputs": [],
   "source": [
    "def apply( row, idx,n=20):\n",
    "    c,s,cc=0,0,0\n",
    "    keys=df.iloc[idx,:][:n]\n",
    "    k= set(keys)\n",
    "    ch_k=df.iloc[row.name,:]\n",
    "    ch_keys= set(ch_k)\n",
    "    scores= df_scores.iloc[idx,:]\n",
    "    ch_scores= df_scores.iloc[idx,:]\n",
    "    k=list(k.intersection(ch_keys))\n",
    "    #print(scores)\n",
    "    if len(k)>0:\n",
    "        s=0\n",
    "        for i in k:\n",
    "            #print(i)\n",
    "            #print(ch_keys)\n",
    "            c=np.where( np.array(list(ch_k))== i)[0][0]\n",
    "            cc=np.where( keys== i)[0][0]\n",
    "            #print(movies.title[row.name],c,cc, i)\n",
    "            s=s+ pow(ch_scores[c]*scores[cc],0.5)\n",
    "            \n",
    "            #print(movies.title[row.name], ch_scores[c],scores[cc],s, i)\n",
    "        return movies.title[row.name],s, ' '.join(k), len(k)\n",
    "    else:\n",
    "        return movies.title[row.name],0, 0,0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 156,
   "id": "9f1313c8",
   "metadata": {},
   "outputs": [],
   "source": [
    "t= df.T"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 159,
   "id": "cbb4a56f",
   "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>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>58</th>\n",
       "      <td>The Sixth Sense</td>\n",
       "      <td>6.322532</td>\n",
       "      <td>continual failure patient second unfinished pr...</td>\n",
       "      <td>20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1828</th>\n",
       "      <td>Gothika</td>\n",
       "      <td>1.751718</td>\n",
       "      <td>boy patient ghost illness</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2024</th>\n",
       "      <td>Volver</td>\n",
       "      <td>1.711314</td>\n",
       "      <td>funeral asleep ghost mother</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2770</th>\n",
       "      <td>A Ghost Story</td>\n",
       "      <td>1.597113</td>\n",
       "      <td>ghost wife</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4804</th>\n",
       "      <td>Rose Red</td>\n",
       "      <td>1.472727</td>\n",
       "      <td>ability sick ghost mother</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1466</th>\n",
       "      <td>Crimson Peak</td>\n",
       "      <td>1.438085</td>\n",
       "      <td>ghost mother</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6717</th>\n",
       "      <td>Ringu 0</td>\n",
       "      <td>1.3394</td>\n",
       "      <td>second ability ghost mother</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6065</th>\n",
       "      <td>Backtrack</td>\n",
       "      <td>1.323586</td>\n",
       "      <td>patient ghost wife</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1714</th>\n",
       "      <td>Scary Movie 4</td>\n",
       "      <td>1.318869</td>\n",
       "      <td>second boy ghost</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2781</th>\n",
       "      <td>The Devil's Backbone</td>\n",
       "      <td>1.285802</td>\n",
       "      <td>boy ghost gun</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1050</th>\n",
       "      <td>The Darjeeling Limited</td>\n",
       "      <td>1.248182</td>\n",
       "      <td>boy funeral mother wife</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2752</th>\n",
       "      <td>The Awakening</td>\n",
       "      <td>1.244946</td>\n",
       "      <td>boy ghost</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6714</th>\n",
       "      <td>Bag of Bones</td>\n",
       "      <td>1.239956</td>\n",
       "      <td>ghost wife</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3067</th>\n",
       "      <td>Macbeth</td>\n",
       "      <td>1.223319</td>\n",
       "      <td>boy ghost wife</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3599</th>\n",
       "      <td>The Ward</td>\n",
       "      <td>1.208044</td>\n",
       "      <td>patient ghost</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6753</th>\n",
       "      <td>Golmaal Again</td>\n",
       "      <td>1.201297</td>\n",
       "      <td>boy ghost</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6533</th>\n",
       "      <td>Noel</td>\n",
       "      <td>1.184068</td>\n",
       "      <td>patient mother wife</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5792</th>\n",
       "      <td>The Canal</td>\n",
       "      <td>1.180173</td>\n",
       "      <td>ghost wife</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2996</th>\n",
       "      <td>1922</td>\n",
       "      <td>1.169989</td>\n",
       "      <td>ghost mother wife</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2580</th>\n",
       "      <td>Who's Afraid of Virginia Woolf?</td>\n",
       "      <td>1.155451</td>\n",
       "      <td>boy wife</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5088</th>\n",
       "      <td>Lake Mungo</td>\n",
       "      <td>1.129981</td>\n",
       "      <td>videotape ghost mother</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2512</th>\n",
       "      <td>Awake</td>\n",
       "      <td>1.123247</td>\n",
       "      <td>wedding patient mother wife</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6160</th>\n",
       "      <td>Eternity and a Day</td>\n",
       "      <td>1.123246</td>\n",
       "      <td>boy unfinished wedding mother</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6855</th>\n",
       "      <td>Haunt</td>\n",
       "      <td>1.119474</td>\n",
       "      <td>patient ghost</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7083</th>\n",
       "      <td>Panic in the Streets</td>\n",
       "      <td>1.119224</td>\n",
       "      <td>illness sick wife</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5908</th>\n",
       "      <td>Paheli</td>\n",
       "      <td>1.110892</td>\n",
       "      <td>ghost wife</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2283</th>\n",
       "      <td>The Frighteners</td>\n",
       "      <td>1.071822</td>\n",
       "      <td>funeral gun wife ghost mother</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>512</th>\n",
       "      <td>50/50</td>\n",
       "      <td>1.068239</td>\n",
       "      <td>patient illness</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4613</th>\n",
       "      <td>The Prodigy</td>\n",
       "      <td>1.061415</td>\n",
       "      <td>boy unfinished gun</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5272</th>\n",
       "      <td>The Young and Prodigious T.S. Spivet</td>\n",
       "      <td>1.054648</td>\n",
       "      <td>boy mother gun</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7035</th>\n",
       "      <td>Our House</td>\n",
       "      <td>1.027646</td>\n",
       "      <td>ghost wife</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>504</th>\n",
       "      <td>Jojo Rabbit</td>\n",
       "      <td>1.017616</td>\n",
       "      <td>boy mother</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2914</th>\n",
       "      <td>A Tale of Two Sisters</td>\n",
       "      <td>1.014947</td>\n",
       "      <td>ghost mother wife</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1416</th>\n",
       "      <td>The Grudge</td>\n",
       "      <td>1.014368</td>\n",
       "      <td>boy ghost wife</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4753</th>\n",
       "      <td>Badlapur</td>\n",
       "      <td>1.001836</td>\n",
       "      <td>second mother wife</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>433</th>\n",
       "      <td>Ghostbusters</td>\n",
       "      <td>1.0</td>\n",
       "      <td>ghost</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>915</th>\n",
       "      <td>Ghostbusters</td>\n",
       "      <td>1.0</td>\n",
       "      <td>ghost</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1305</th>\n",
       "      <td>Scary Movie 2</td>\n",
       "      <td>1.0</td>\n",
       "      <td>ghost</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1601</th>\n",
       "      <td>Casper</td>\n",
       "      <td>1.0</td>\n",
       "      <td>ghost</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2335</th>\n",
       "      <td>Thir13en Ghosts</td>\n",
       "      <td>1.0</td>\n",
       "      <td>ghost</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5242</th>\n",
       "      <td>Kairo</td>\n",
       "      <td>1.0</td>\n",
       "      <td>ghost</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5424</th>\n",
       "      <td>The Ghost and Mrs. Muir</td>\n",
       "      <td>1.0</td>\n",
       "      <td>ghost</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5453</th>\n",
       "      <td>No Retreat, No Surrender</td>\n",
       "      <td>1.0</td>\n",
       "      <td>ghost</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5491</th>\n",
       "      <td>Hamlet</td>\n",
       "      <td>1.0</td>\n",
       "      <td>ghost</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6477</th>\n",
       "      <td>Scrooge</td>\n",
       "      <td>1.0</td>\n",
       "      <td>ghost</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6747</th>\n",
       "      <td>Bhoothnath</td>\n",
       "      <td>1.0</td>\n",
       "      <td>ghost</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6911</th>\n",
       "      <td>Ghost Story</td>\n",
       "      <td>1.0</td>\n",
       "      <td>ghost</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2893</th>\n",
       "      <td>Fanny and Alexander</td>\n",
       "      <td>0.998165</td>\n",
       "      <td>ability ghost mother</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4845</th>\n",
       "      <td>Mars Needs Moms</td>\n",
       "      <td>0.996341</td>\n",
       "      <td>boy asleep mother</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3051</th>\n",
       "      <td>House on Haunted Hill</td>\n",
       "      <td>0.99189</td>\n",
       "      <td>patient ghost wife</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                         0         1  \\\n",
       "58                         The Sixth Sense  6.322532   \n",
       "1828                               Gothika  1.751718   \n",
       "2024                                Volver  1.711314   \n",
       "2770                         A Ghost Story  1.597113   \n",
       "4804                              Rose Red  1.472727   \n",
       "1466                          Crimson Peak  1.438085   \n",
       "6717                               Ringu 0    1.3394   \n",
       "6065                             Backtrack  1.323586   \n",
       "1714                         Scary Movie 4  1.318869   \n",
       "2781                  The Devil's Backbone  1.285802   \n",
       "1050                The Darjeeling Limited  1.248182   \n",
       "2752                         The Awakening  1.244946   \n",
       "6714                          Bag of Bones  1.239956   \n",
       "3067                               Macbeth  1.223319   \n",
       "3599                              The Ward  1.208044   \n",
       "6753                         Golmaal Again  1.201297   \n",
       "6533                                  Noel  1.184068   \n",
       "5792                             The Canal  1.180173   \n",
       "2996                                  1922  1.169989   \n",
       "2580       Who's Afraid of Virginia Woolf?  1.155451   \n",
       "5088                            Lake Mungo  1.129981   \n",
       "2512                                 Awake  1.123247   \n",
       "6160                    Eternity and a Day  1.123246   \n",
       "6855                                 Haunt  1.119474   \n",
       "7083                  Panic in the Streets  1.119224   \n",
       "5908                                Paheli  1.110892   \n",
       "2283                       The Frighteners  1.071822   \n",
       "512                                  50/50  1.068239   \n",
       "4613                           The Prodigy  1.061415   \n",
       "5272  The Young and Prodigious T.S. Spivet  1.054648   \n",
       "7035                             Our House  1.027646   \n",
       "504                            Jojo Rabbit  1.017616   \n",
       "2914                 A Tale of Two Sisters  1.014947   \n",
       "1416                            The Grudge  1.014368   \n",
       "4753                              Badlapur  1.001836   \n",
       "433                           Ghostbusters       1.0   \n",
       "915                           Ghostbusters       1.0   \n",
       "1305                         Scary Movie 2       1.0   \n",
       "1601                                Casper       1.0   \n",
       "2335                       Thir13en Ghosts       1.0   \n",
       "5242                                 Kairo       1.0   \n",
       "5424               The Ghost and Mrs. Muir       1.0   \n",
       "5453              No Retreat, No Surrender       1.0   \n",
       "5491                                Hamlet       1.0   \n",
       "6477                               Scrooge       1.0   \n",
       "6747                            Bhoothnath       1.0   \n",
       "6911                           Ghost Story       1.0   \n",
       "2893                   Fanny and Alexander  0.998165   \n",
       "4845                       Mars Needs Moms  0.996341   \n",
       "3051                 House on Haunted Hill   0.99189   \n",
       "\n",
       "                                                      2   3  \n",
       "58    continual failure patient second unfinished pr...  20  \n",
       "1828                          boy patient ghost illness   4  \n",
       "2024                        funeral asleep ghost mother   4  \n",
       "2770                                         ghost wife   2  \n",
       "4804                          ability sick ghost mother   4  \n",
       "1466                                       ghost mother   2  \n",
       "6717                        second ability ghost mother   4  \n",
       "6065                                 patient ghost wife   3  \n",
       "1714                                   second boy ghost   3  \n",
       "2781                                      boy ghost gun   3  \n",
       "1050                            boy funeral mother wife   4  \n",
       "2752                                          boy ghost   2  \n",
       "6714                                         ghost wife   2  \n",
       "3067                                     boy ghost wife   3  \n",
       "3599                                      patient ghost   2  \n",
       "6753                                          boy ghost   2  \n",
       "6533                                patient mother wife   3  \n",
       "5792                                         ghost wife   2  \n",
       "2996                                  ghost mother wife   3  \n",
       "2580                                           boy wife   2  \n",
       "5088                             videotape ghost mother   3  \n",
       "2512                        wedding patient mother wife   4  \n",
       "6160                      boy unfinished wedding mother   4  \n",
       "6855                                      patient ghost   2  \n",
       "7083                                  illness sick wife   3  \n",
       "5908                                         ghost wife   2  \n",
       "2283                      funeral gun wife ghost mother   5  \n",
       "512                                     patient illness   2  \n",
       "4613                                 boy unfinished gun   3  \n",
       "5272                                     boy mother gun   3  \n",
       "7035                                         ghost wife   2  \n",
       "504                                          boy mother   2  \n",
       "2914                                  ghost mother wife   3  \n",
       "1416                                     boy ghost wife   3  \n",
       "4753                                 second mother wife   3  \n",
       "433                                               ghost   1  \n",
       "915                                               ghost   1  \n",
       "1305                                              ghost   1  \n",
       "1601                                              ghost   1  \n",
       "2335                                              ghost   1  \n",
       "5242                                              ghost   1  \n",
       "5424                                              ghost   1  \n",
       "5453                                              ghost   1  \n",
       "5491                                              ghost   1  \n",
       "6477                                              ghost   1  \n",
       "6747                                              ghost   1  \n",
       "6911                                              ghost   1  \n",
       "2893                               ability ghost mother   3  \n",
       "4845                                  boy asleep mother   3  \n",
       "3051                                 patient ghost wife   3  "
      ]
     },
     "execution_count": 159,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "t.apply(lambda x : apply(x,58)).T.sort_values(by=[1,3], ascending= [False,False]).head(50)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b94f792d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0fe94160",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 117,
   "id": "d06f3342",
   "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>titleId</th>\n",
       "      <th>averageRating</th>\n",
       "      <th>numVotes</th>\n",
       "      <th>title</th>\n",
       "      <th>startYear</th>\n",
       "      <th>runtimeMinutes</th>\n",
       "      <th>genres</th>\n",
       "      <th>synopsis</th>\n",
       "      <th>synopsis_allowed_pos</th>\n",
       "      <th>keywords</th>\n",
       "      <th>scores</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1012</th>\n",
       "      <td>tt1127180</td>\n",
       "      <td>6.5</td>\n",
       "      <td>190958</td>\n",
       "      <td>Drag Me to Hell</td>\n",
       "      <td>2009</td>\n",
       "      <td>99</td>\n",
       "      <td>Horror</td>\n",
       "      <td>In Pasadena, California in 1969, a young Mexic...</td>\n",
       "      <td>young mexican couple home medium son jewelry g...</td>\n",
       "      <td>button,loan,envelope,clay,assistant,cake,goat,...</td>\n",
       "      <td>0.36904204918723854,0.2306283305898838,0.22358...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        titleId  averageRating  numVotes            title  startYear  \\\n",
       "1012  tt1127180            6.5    190958  Drag Me to Hell       2009   \n",
       "\n",
       "     runtimeMinutes  genres  \\\n",
       "1012             99  Horror   \n",
       "\n",
       "                                               synopsis  \\\n",
       "1012  In Pasadena, California in 1969, a young Mexic...   \n",
       "\n",
       "                                   synopsis_allowed_pos  \\\n",
       "1012  young mexican couple home medium son jewelry g...   \n",
       "\n",
       "                                               keywords  \\\n",
       "1012  button,loan,envelope,clay,assistant,cake,goat,...   \n",
       "\n",
       "                                                 scores  \n",
       "1012  0.36904204918723854,0.2306283305898838,0.22358...  "
      ]
     },
     "execution_count": 117,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "movies[movies.title=='Drag Me to Hell']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7a8900d3",
   "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
}
