{ "cells": [ { "cell_type": "code", "execution_count": 36, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[nltk_data] Downloading package stopwords to\n", "[nltk_data] C:\\Users\\Maren\\AppData\\Roaming\\nltk_data...\n", "[nltk_data] Unzipping corpora\\stopwords.zip.\n" ] }, { "data": { "text/plain": [ "True" ] }, "execution_count": 36, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import pandas as pd\n", "import nltk\n", "nltk.download('stopwords')" ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [], "source": [ "table = pd.read_csv(\"emoji_descriptions.csv\")" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Unnamed: 0codecharacterdescriptionUnnamed: 4
00126980๐Ÿ€„MAHJONG TILE RED DRAGONNaN
11129525๐ŸงตSPOOL OF THREADNaN
22129526๐ŸงถBALL OF YARNNaN
33127183๐ŸƒPLAYING CARD BLACK JOKERNaN
44129296๐ŸคZIPPER-MOUTH FACENaN
\n", "
" ], "text/plain": [ " Unnamed: 0 code character description Unnamed: 4\n", "0 0 126980 ๐Ÿ€„ MAHJONG TILE RED DRAGON NaN\n", "1 1 129525 ๐Ÿงต SPOOL OF THREAD NaN\n", "2 2 129526 ๐Ÿงถ BALL OF YARN NaN\n", "3 3 127183 ๐Ÿƒ PLAYING CARD BLACK JOKER NaN\n", "4 4 129296 ๐Ÿค ZIPPER-MOUTH FACE NaN" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "table.head()" ] }, { "cell_type": "code", "execution_count": 46, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\Users\\Maren\\Anaconda3\\lib\\site-packages\\ipykernel_launcher.py:5: SettingWithCopyWarning: \n", "A value is trying to be set on a copy of a slice from a DataFrame\n", "\n", "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n", " \"\"\"\n", "C:\\Users\\Maren\\Anaconda3\\lib\\site-packages\\ipykernel_launcher.py:10: SettingWithCopyWarning: \n", "A value is trying to be set on a copy of a slice from a DataFrame\n", "\n", "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n", " # Remove the CWD from sys.path while we load stuff.\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Unnamed: 0codecharacterdescriptionUnnamed: 4
00126980๐Ÿ€„mahjong tile red dragonNaN
11129525๐Ÿงตspool threadNaN
22129526๐Ÿงถball yarnNaN
33127183๐Ÿƒplaying card black jokerNaN
44129296๐Ÿคzipper-mouth faceNaN
\n", "
" ], "text/plain": [ " Unnamed: 0 code character description Unnamed: 4\n", "0 0 126980 ๐Ÿ€„ mahjong tile red dragon NaN\n", "1 1 129525 ๐Ÿงต spool thread NaN\n", "2 2 129526 ๐Ÿงถ ball yarn NaN\n", "3 3 127183 ๐Ÿƒ playing card black joker NaN\n", "4 4 129296 ๐Ÿค zipper-mouth face NaN" ] }, "execution_count": 46, "metadata": {}, "output_type": "execute_result" } ], "source": [ "prepStep1Table = table\n", "\n", "# lowercasing and stopword removal\n", "for entry in range(len(table[\"description\"][1:])):\n", " table[\"description\"][entry] = table[\"description\"][entry].lower()\n", " newEntry = []\n", " for word in table[\"description\"][entry].split(\" \"):\n", " if word not in set(stopwords.words('english')):\n", " newEntry.append(word)\n", " table[\"description\"][entry] = (\" \").join(newEntry).lower()\n", " \n", "table.head()" ] }, { "cell_type": "code", "execution_count": null, "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.6.4" } }, "nbformat": 4, "nbformat_minor": 2 }