Team Ai
Apppublic

Decoder2704/python-chatbot-jay

sourceHugging Faceupdated 7mo agoView on Hugging Face
0likes
Preprocessing.ipynb289 linesDownload Raw Back to root
1{2 "cells": [3  {4   "cell_type": "code",5   "execution_count": 1,6   "metadata": {},7   "outputs": [8    {9     "data": {10      "text/html": [11       "<div>\n",12       "<style scoped>\n",13       "    .dataframe tbody tr th:only-of-type {\n",14       "        vertical-align: middle;\n",15       "    }\n",16       "\n",17       "    .dataframe tbody tr th {\n",18       "        vertical-align: top;\n",19       "    }\n",20       "\n",21       "    .dataframe thead th {\n",22       "        text-align: right;\n",23       "    }\n",24       "</style>\n",25       "<table border=\"1\" class=\"dataframe\">\n",26       "  <thead>\n",27       "    <tr style=\"text-align: right;\">\n",28       "      <th></th>\n",29       "      <th>Id</th>\n",30       "      <th>OwnerUserId</th>\n",31       "      <th>CreationDate</th>\n",32       "      <th>ParentId</th>\n",33       "      <th>Score</th>\n",34       "      <th>Body</th>\n",35       "    </tr>\n",36       "  </thead>\n",37       "  <tbody>\n",38       "    <tr>\n",39       "      <th>0</th>\n",40       "      <td>497</td>\n",41       "      <td>50.0</td>\n",42       "      <td>2008-08-02T16:56:53Z</td>\n",43       "      <td>469</td>\n",44       "      <td>4</td>\n",45       "      <td>&lt;p&gt;open up a terminal (Applications-&amp;gt;Utilit...</td>\n",46       "    </tr>\n",47       "    <tr>\n",48       "      <th>1</th>\n",49       "      <td>518</td>\n",50       "      <td>153.0</td>\n",51       "      <td>2008-08-02T17:42:28Z</td>\n",52       "      <td>469</td>\n",53       "      <td>2</td>\n",54       "      <td>&lt;p&gt;I haven't been able to find anything that d...</td>\n",55       "    </tr>\n",56       "    <tr>\n",57       "      <th>2</th>\n",58       "      <td>536</td>\n",59       "      <td>161.0</td>\n",60       "      <td>2008-08-02T18:49:07Z</td>\n",61       "      <td>502</td>\n",62       "      <td>9</td>\n",63       "      <td>&lt;p&gt;You can use ImageMagick's convert utility f...</td>\n",64       "    </tr>\n",65       "    <tr>\n",66       "      <th>3</th>\n",67       "      <td>538</td>\n",68       "      <td>156.0</td>\n",69       "      <td>2008-08-02T18:56:56Z</td>\n",70       "      <td>535</td>\n",71       "      <td>23</td>\n",72       "      <td>&lt;p&gt;One possibility is Hudson.  It's written in...</td>\n",73       "    </tr>\n",74       "    <tr>\n",75       "      <th>4</th>\n",76       "      <td>541</td>\n",77       "      <td>157.0</td>\n",78       "      <td>2008-08-02T19:06:40Z</td>\n",79       "      <td>535</td>\n",80       "      <td>20</td>\n",81       "      <td>&lt;p&gt;We run &lt;a href=\"http://buildbot.net/trac\"&gt;B...</td>\n",82       "    </tr>\n",83       "  </tbody>\n",84       "</table>\n",85       "</div>"86      ],87      "text/plain": [88       "    Id  OwnerUserId          CreationDate  ParentId  Score  \\\n",89       "0  497         50.0  2008-08-02T16:56:53Z       469      4   \n",90       "1  518        153.0  2008-08-02T17:42:28Z       469      2   \n",91       "2  536        161.0  2008-08-02T18:49:07Z       502      9   \n",92       "3  538        156.0  2008-08-02T18:56:56Z       535     23   \n",93       "4  541        157.0  2008-08-02T19:06:40Z       535     20   \n",94       "\n",95       "                                                Body  \n",96       "0  <p>open up a terminal (Applications-&gt;Utilit...  \n",97       "1  <p>I haven't been able to find anything that d...  \n",98       "2  <p>You can use ImageMagick's convert utility f...  \n",99       "3  <p>One possibility is Hudson.  It's written in...  \n",100       "4  <p>We run <a href=\"http://buildbot.net/trac\">B...  "101      ]102     },103     "execution_count": 1,104     "metadata": {},105     "output_type": "execute_result"106    }107   ],108   "source": [109    "import pandas as pd\n",110    "\n",111    "an = pd.read_csv(\"Dataset/Answers.csv\",encoding='latin-1')\n",112    "an.head()"113   ]114  },115  {116   "cell_type": "code",117   "execution_count": 2,118   "metadata": {},119   "outputs": [120    {121     "data": {122      "text/html": [123       "<div>\n",124       "<style scoped>\n",125       "    .dataframe tbody tr th:only-of-type {\n",126       "        vertical-align: middle;\n",127       "    }\n",128       "\n",129       "    .dataframe tbody tr th {\n",130       "        vertical-align: top;\n",131       "    }\n",132       "\n",133       "    .dataframe thead th {\n",134       "        text-align: right;\n",135       "    }\n",136       "</style>\n",137       "<table border=\"1\" class=\"dataframe\">\n",138       "  <thead>\n",139       "    <tr style=\"text-align: right;\">\n",140       "      <th></th>\n",141       "      <th>Id</th>\n",142       "      <th>OwnerUserId</th>\n",143       "      <th>CreationDate</th>\n",144       "      <th>ParentId</th>\n",145       "      <th>Score</th>\n",146       "      <th>Body</th>\n",147       "      <th>latest_score</th>\n",148       "      <th>alternate</th>\n",149       "      <th>date</th>\n",150       "    </tr>\n",151       "  </thead>\n",152       "  <tbody>\n",153       "    <tr>\n",154       "      <th>0</th>\n",155       "      <td>497</td>\n",156       "      <td>50.0</td>\n",157       "      <td>2008-08-02T16:56:53Z</td>\n",158       "      <td>469</td>\n",159       "      <td>4</td>\n",160       "      <td>&lt;p&gt;open up a terminal (Applications-&amp;gt;Utilit...</td>\n",161       "      <td>4</td>\n",162       "      <td>4</td>\n",163       "      <td>2024-02-14</td>\n",164       "    </tr>\n",165       "    <tr>\n",166       "      <th>1</th>\n",167       "      <td>518</td>\n",168       "      <td>153.0</td>\n",169       "      <td>2008-08-02T17:42:28Z</td>\n",170       "      <td>469</td>\n",171       "      <td>2</td>\n",172       "      <td>&lt;p&gt;I haven't been able to find anything that d...</td>\n",173       "      <td>2</td>\n",174       "      <td>2</td>\n",175       "      <td>2024-02-14</td>\n",176       "    </tr>\n",177       "    <tr>\n",178       "      <th>2</th>\n",179       "      <td>536</td>\n",180       "      <td>161.0</td>\n",181       "      <td>2008-08-02T18:49:07Z</td>\n",182       "      <td>502</td>\n",183       "      <td>9</td>\n",184       "      <td>&lt;p&gt;You can use ImageMagick's convert utility f...</td>\n",185       "      <td>9</td>\n",186       "      <td>9</td>\n",187       "      <td>2024-02-14</td>\n",188       "    </tr>\n",189       "    <tr>\n",190       "      <th>3</th>\n",191       "      <td>538</td>\n",192       "      <td>156.0</td>\n",193       "      <td>2008-08-02T18:56:56Z</td>\n",194       "      <td>535</td>\n",195       "      <td>23</td>\n",196       "      <td>&lt;p&gt;One possibility is Hudson.  It's written in...</td>\n",197       "      <td>23</td>\n",198       "      <td>23</td>\n",199       "      <td>2024-02-14</td>\n",200       "    </tr>\n",201       "    <tr>\n",202       "      <th>4</th>\n",203       "      <td>541</td>\n",204       "      <td>157.0</td>\n",205       "      <td>2008-08-02T19:06:40Z</td>\n",206       "      <td>535</td>\n",207       "      <td>20</td>\n",208       "      <td>&lt;p&gt;We run &lt;a href=\"http://buildbot.net/trac\"&gt;B...</td>\n",209       "      <td>20</td>\n",210       "      <td>20</td>\n",211       "      <td>2024-02-14</td>\n",212       "    </tr>\n",213       "  </tbody>\n",214       "</table>\n",215       "</div>"216      ],217      "text/plain": [218       "    Id  OwnerUserId          CreationDate  ParentId  Score  \\\n",219       "0  497         50.0  2008-08-02T16:56:53Z       469      4   \n",220       "1  518        153.0  2008-08-02T17:42:28Z       469      2   \n",221       "2  536        161.0  2008-08-02T18:49:07Z       502      9   \n",222       "3  538        156.0  2008-08-02T18:56:56Z       535     23   \n",223       "4  541        157.0  2008-08-02T19:06:40Z       535     20   \n",224       "\n",225       "                                                Body  latest_score  alternate  \\\n",226       "0  <p>open up a terminal (Applications-&gt;Utilit...             4          4   \n",227       "1  <p>I haven't been able to find anything that d...             2          2   \n",228       "2  <p>You can use ImageMagick's convert utility f...             9          9   \n",229       "3  <p>One possibility is Hudson.  It's written in...            23         23   \n",230       "4  <p>We run <a href=\"http://buildbot.net/trac\">B...            20         20   \n",231       "\n",232       "         date  \n",233       "0  2024-02-14  \n",234       "1  2024-02-14  \n",235       "2  2024-02-14  \n",236       "3  2024-02-14  \n",237       "4  2024-02-14  "238      ]239     },240     "execution_count": 2,241     "metadata": {},242     "output_type": "execute_result"243    }244   ],245   "source": [246    "from datetime import date\n",247    "\n",248    "\n",249    "# datetime.datetime.today()\n",250    "an[\"latest_score\"] = an[\"Score\"]\n",251    "\n",252    "an[\"alternate\"] = an[\"Score\"]\n",253    "an[\"date\"] = date.today()\n",254    "an.head()"255   ]256  },257  {258   "cell_type": "code",259   "execution_count": 3,260   "metadata": {},261   "outputs": [],262   "source": [263    "an.to_csv(\"Dataset/AnswersV2.csv\",index=False)"264   ]265  }266 ],267 "metadata": {268  "kernelspec": {269   "display_name": "Python 3 (ipykernel)",270   "language": "python",271   "name": "python3"272  },273  "language_info": {274   "codemirror_mode": {275    "name": "ipython",276    "version": 3277   },278   "file_extension": ".py",279   "mimetype": "text/x-python",280   "name": "python",281   "nbconvert_exporter": "python",282   "pygments_lexer": "ipython3",283   "version": "3.9.12"284  }285 },286 "nbformat": 4,287 "nbformat_minor": 2288}289