diff --git a/your-code/challenge-1.ipynb b/your-code/challenge-1.ipynb index 2e59d77..a059cc3 100755 --- a/your-code/challenge-1.ipynb +++ b/your-code/challenge-1.ipynb @@ -15,11 +15,12 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ - "# Your code here\n" + "# Your code here\n", + "tup=\"I\"," ] }, { @@ -33,11 +34,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n" + ] + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "print(type(tup))" ] }, { @@ -55,13 +65,27 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "AttributeError", + "evalue": "'tuple' object has no attribute 'append'", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[1;31m# Your code here\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mtup\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"r\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m\"o\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m\"n\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m\"h\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m\"a\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m\"c\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m\"k\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 3\u001b[0m \u001b[1;31m# Your explanation here\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;31mAttributeError\u001b[0m: 'tuple' object has no attribute 'append'" + ] + } + ], "source": [ "# Your code here\n", - "\n", - "# Your explanation here\n" + "tup.add(\"r\", \"o\", \"n\", \"h\", \"a\", \"c\", \"k\")\n", + "# Your explanation here\n", + "# Tuple objects are inmutable, they cannot be changed unless the tuple is defined again\n", + "# With the new elements included" ] }, { @@ -79,13 +103,14 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "# Your code here\n", - "\n", - "# Your explanation here\n" + "tup=(\"I\", \"r\", \"o\", \"n\", \"h\", \"a\", \"c\", \"k\")\n", + "# Your explanation here\n", + "# I was able to do it since I was not modifying the tuple, I was re-definying the same tuple" ] }, { @@ -103,11 +128,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('I', 'r', 'o', 'n')\n", + "('h', 'a', 'c', 'k')\n" + ] + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "tup1=tup[:4]\n", + "print(tup1)\n", + "tup2=tup[4:]\n", + "print(tup2)" ] }, { @@ -121,11 +159,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('I', 'r', 'o', 'n', 'h', 'a', 'c', 'k')\n" + ] + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "tup3=tup1+tup2\n", + "print(tup3)" ] }, { @@ -137,11 +185,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Math Works\n" + ] + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "if len(tup1)+len(tup2)==len(tup3):\n", + " print(\"Math Works\")\n", + "else:\n", + " print(\"Not the same bro...\")" ] }, { @@ -153,11 +213,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "4" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "tup3.index(\"h\")" ] }, { @@ -177,11 +249,29 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 21, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n", + "False\n", + "True\n", + "False\n", + "False\n" + ] + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "letters = [\"a\", \"b\", \"c\", \"d\", \"e\"]\n", + "for letter in letters:\n", + " if letter in tup3:\n", + " print(\"True\")\n", + " else:\n", + " print(\"False\") " ] }, { @@ -195,11 +285,29 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 32, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "{'a': 1, 'b': 0, 'c': 1, 'd': 0, 'e': 0}" + ] + }, + "execution_count": 32, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "freq = {} \n", + "for letter in letters:\n", + " if letter in tup3:\n", + " freq[letter]=1\n", + " else:\n", + " freq[letter]=0\n", + "freq" ] } ], @@ -219,7 +327,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.2" + "version": "3.8.8" } }, "nbformat": 4, diff --git a/your-code/challenge-2.ipynb b/your-code/challenge-2.ipynb index 41d6911..bb68f6d 100755 --- a/your-code/challenge-2.ipynb +++ b/your-code/challenge-2.ipynb @@ -13,7 +13,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -38,11 +38,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[61, 65, 24, 4, 77, 71, 49, 18, 51, 10, 19, 32, 79, 30, 1, 35, 23, 67, 13, 56, 47, 28, 12, 98, 90, 80, 64, 94, 33, 62, 3, 46, 99, 87, 85, 36, 82, 2, 7, 17, 20, 93, 57, 15, 16, 6, 45, 48, 9, 54, 31, 26, 96, 95, 41, 78, 76, 34, 97, 11, 44, 91, 39, 27, 37, 89, 81, 70, 59, 40, 5, 0, 42, 55, 25, 69, 86, 29, 92, 72]\n" + ] + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "sample_list_1=random.sample(range(100), 80)\n", + "print(sample_list_1)" ] }, { @@ -54,11 +64,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "80\n", + "Hell Yeah, is the same\n" + ] + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "set1=set(sample_list_1)\n", + "print(len(set1))\n", + "if len(set1)==len(sample_list_1):\n", + " print(\"Hell Yeah, is the same\")\n", + "else:\n", + " print(\"Dude... It is not the same\")" ] }, { @@ -77,11 +102,14 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ - "# Your code here\n" + "# Your code here\n", + "sample_list_2=[]\n", + "for i in range(80):\n", + " sample_list_2.append(random.choice(range(100)))" ] }, { @@ -93,11 +121,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "53\n", + "Dude... It is not the same\n" + ] + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "set2=set(sample_list_2)\n", + "print(len(set2))\n", + "if len(set2)==len(sample_list_2):\n", + " print(\"Hell Yeah, is the same\")\n", + "else:\n", + " print(\"Dude... It is not the same\")" ] }, { @@ -109,11 +152,12 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ - "# Your code here\n" + "# Your code here\n", + "set3=set1-set2" ] }, { @@ -125,11 +169,12 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ - "# Your code here\n" + "# Your code here\n", + "set4=set2-set1" ] }, { @@ -141,11 +186,12 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ - "# Your code here\n" + "# Your code here\n", + "set5=set1.intersection(set2)" ] }, { @@ -165,11 +211,33 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Your code here\n" + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "80\n", + "53\n", + "36\n", + "9\n", + "44\n", + "Math worked\n" + ] + } + ], + "source": [ + "# Your code here\n", + "print(len(set1))\n", + "print(len(set2))\n", + "print(len(set3))\n", + "print(len(set4))\n", + "print(len(set5))\n", + "if set3.union(set4,set5)==set1.union(set2):\n", + " print(\"Math worked\")\n", + "else:\n", + " print(\"Mathn't\")" ] }, { @@ -181,11 +249,12 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ - "# Your code here\n" + "# Your code here\n", + "set6=set()" ] }, { @@ -197,11 +266,12 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ - "# Your code here\n" + "# Your code here\n", + "set6.update(set3,set5,set6)" ] }, { @@ -213,11 +283,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Math worked\n" + ] + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "if set1==set6:\n", + " print(\"Math worked\")\n", + "else:\n", + " print(\"Mathn't\")" ] }, { @@ -229,11 +311,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "False\n", + "False\n" + ] + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "print(set2.issubset(set1))\n", + "print(set1.issubset(set2))" ] }, { @@ -247,11 +340,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Math worked\n" + ] + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "if set3.union(set4,set5)==set1.union(set2):\n", + " print(\"Math worked\")\n", + "else:\n", + " print(\"Mathn't\") " ] }, { @@ -263,11 +368,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "set1.pop()" ] }, { @@ -283,11 +400,22 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Your code here\n" + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{2, 3, 4, 5, 6, 7, 10, 12, 13, 15, 16, 17, 18, 20, 23, 24, 25, 26, 27, 28, 30, 32, 33, 34, 35, 36, 37, 40, 42, 44, 45, 46, 47, 48, 54, 55, 56, 57, 62, 64, 65, 67, 70, 72, 76, 77, 78, 80, 82, 85, 86, 87, 90, 92, 93, 94, 95, 96, 97, 98}\n" + ] + } + ], + "source": [ + "# Your code here\n", + "list_to_remove = [1, 9, 11, 19, 21, 29, 31, 39, 41, 49, 51, 59, 61, 69, 71, 79, 81, 89, 91, 99]\n", + "list_to_remove = set(list_to_remove)\n", + "print(set1-list_to_remove)" ] } ], @@ -307,7 +435,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.2" + "version": "3.8.8" } }, "nbformat": 4, diff --git a/your-code/challenge-3.ipynb b/your-code/challenge-3.ipynb index 7ab8ea5..e345841 100755 --- a/your-code/challenge-3.ipynb +++ b/your-code/challenge-3.ipynb @@ -15,7 +15,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 25, "metadata": {}, "outputs": [], "source": [ @@ -49,11 +49,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[('a', 8), ('about', 1), ('all', 1), ('although', 3), ('and', 23), ('are', 1), ('at', 1), ('baby', 14), ('backseat', 1), ('bag', 1), ('bar', 1), ('be', 16), ('bedsheets', 3), ('begin', 1), ('best', 1), ('body', 17), ('boy', 2), ('brand', 6), ('can', 1), ('chance', 1), ('club', 1), ('come', 37), ('conversation', 1), ('crazy', 2), ('dance', 1), ('date', 1), ('day', 6), ('discovering', 6), ('do', 3), ('doing', 2), (\"don't\", 2), ('drinking', 1), ('driver', 1), ('eat', 1), ('every', 6), ('falling', 3), ('family', 1), ('fast', 1), ('fill', 2), ('find', 1), ('first', 1), ('follow', 6), ('for', 3), ('friends', 1), ('get', 1), ('girl', 2), ('give', 1), ('go', 2), ('going', 1), ('grab', 2), ('hand', 1), ('handmade', 2), ('heart', 3), ('hours', 2), ('how', 1), ('i', 6), (\"i'll\", 1), (\"i'm\", 23), ('in', 27), ('is', 5), (\"isn't\", 1), ('it', 1), ('jukebox', 1), ('just', 1), ('kiss', 1), ('know', 2), ('last', 3), ('lead', 6), ('leave', 1), ('let', 1), (\"let's\", 2), ('like', 10), ('love', 25), ('lover', 1), ('magnet', 3), ('make', 1), ('man', 1), ('may', 2), ('me', 10), ('mind', 2), ('much', 2), ('my', 33), ('new', 6), ('night', 3), ('not', 2), ('now', 11), ('of', 6), ('okay', 1), ('on', 40), ('one', 1), ('our', 1), ('out', 1), ('over', 1), ('place', 1), ('plate', 1), ('play', 1), ('pull', 3), ('push', 3), ('put', 3), ('radio', 1), ('room', 3), ('say', 2), ('shape', 6), ('shots', 1), ('singing', 2), ('slow', 1), ('smell', 3), ('so', 2), ('somebody', 2), ('something', 6), ('sour', 1), ('start', 2), ('stop', 1), ('story', 1), ('sweet', 1), ('table', 1), ('take', 1), ('talk', 4), ('taxi', 1), ('tell', 1), ('that', 2), ('the', 18), ('then', 3), ('thrifty', 1), ('to', 2), ('too', 5), ('trust', 1), ('up', 3), ('van', 1), ('waist', 2), ('want', 2), ('was', 2), ('we', 7), (\"we're\", 1), ('week', 1), ('were', 3), ('where', 1), ('with', 22), ('you', 16), ('your', 21)]\n" + ] + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "import operator\n", + "word_freq2=sorted(word_freq.items(),key=operator.itemgetter(0))\n", + "print(word_freq2)" ] }, { @@ -90,11 +101,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 22, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'conversation': 1, \"we're\": 1, 'plate': 1, 'sour': 1, 'jukebox': 1, 'taxi': 1, 'fast': 1, 'bag': 1, 'man': 1, 'going': 1, 'one': 1, 'backseat': 1, 'friends': 1, 'take': 1, 'play': 1, 'okay': 1, 'begin': 1, 'over': 1, 'just': 1, 'are': 1, 'tell': 1, 'drinking': 1, 'our': 1, 'where': 1, \"i'll\": 1, 'all': 1, \"isn't\": 1, 'make': 1, 'lover': 1, 'get': 1, 'radio': 1, 'give': 1, 'can': 1, 'club': 1, 'it': 1, 'out': 1, 'chance': 1, 'first': 1, 'table': 1, 'thrifty': 1, 'driver': 1, 'slow': 1, 'dance': 1, 'trust': 1, 'family': 1, 'week': 1, 'date': 1, 'leave': 1, 'at': 1, 'hand': 1, 'how': 1, 'eat': 1, 'about': 1, 'story': 1, 'sweet': 1, 'best': 1, 'let': 1, 'van': 1, 'shots': 1, 'place': 1, 'find': 1, 'kiss': 1, 'stop': 1, 'bar': 1, \"don't\": 2, 'mind': 2, 'know': 2, 'so': 2, 'start': 2, 'boy': 2, 'girl': 2, 'singing': 2, 'doing': 2, 'somebody': 2, 'handmade': 2, 'may': 2, 'that': 2, 'much': 2, 'grab': 2, 'was': 2, 'say': 2, 'waist': 2, 'want': 2, \"let's\": 2, 'not': 2, 'crazy': 2, 'go': 2, 'to': 2, 'fill': 2, 'hours': 2, 'push': 3, 'then': 3, 'put': 3, 'room': 3, 'magnet': 3, 'up': 3, 'pull': 3, 'last': 3, 'do': 3, 'smell': 3, 'although': 3, 'falling': 3, 'were': 3, 'night': 3, 'heart': 3, 'for': 3, 'bedsheets': 3, 'talk': 4, 'too': 5, 'is': 5, 'every': 6, 'new': 6, 'follow': 6, 'brand': 6, 'of': 6, 'i': 6, 'day': 6, 'lead': 6, 'shape': 6, 'discovering': 6, 'something': 6, 'we': 7, 'a': 8, 'like': 10, 'me': 10, 'now': 11, 'baby': 14, 'you': 16, 'be': 16, 'body': 17, 'the': 18, 'your': 21, 'with': 22, \"i'm\": 23, 'and': 23, 'love': 25, 'in': 27, 'my': 33, 'come': 37, 'on': 40}\n" + ] + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "sorted_tups=sorted(word_freq.items(),key=operator.itemgetter(1))\n", + "word_freq2={}\n", + "for i in sorted_tups:\n", + " word_freq2[i[0]]=i[1]\n", + "print(word_freq2)" ] }, { @@ -110,7 +134,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 26, "metadata": {}, "outputs": [], "source": [ @@ -132,11 +156,121 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 32, "metadata": {}, - "outputs": [], + "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", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
wordfreq
0love25
1conversation1
2every6
3we're1
4plate1
.........
135bedsheets3
136fill2
137hours2
138stop1
139bar1
\n", + "

140 rows × 2 columns

\n", + "
" + ], + "text/plain": [ + " word freq\n", + "0 love 25\n", + "1 conversation 1\n", + "2 every 6\n", + "3 we're 1\n", + "4 plate 1\n", + ".. ... ...\n", + "135 bedsheets 3\n", + "136 fill 2\n", + "137 hours 2\n", + "138 stop 1\n", + "139 bar 1\n", + "\n", + "[140 rows x 2 columns]" + ] + }, + "execution_count": 32, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "df=pd.DataFrame(word_freq.items(), columns=['word', 'freq'])\n", + "df" ] }, { @@ -150,11 +284,120 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 33, "metadata": {}, - "outputs": [], + "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", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
wordfreq
120a8
109about1
43all1
96although3
72and23
.........
128were3
41where1
54with22
15you16
97your21
\n", + "

140 rows × 2 columns

\n", + "
" + ], + "text/plain": [ + " word freq\n", + "120 a 8\n", + "109 about 1\n", + "43 all 1\n", + "96 although 3\n", + "72 and 23\n", + ".. ... ...\n", + "128 were 3\n", + "41 where 1\n", + "54 with 22\n", + "15 you 16\n", + "97 your 21\n", + "\n", + "[140 rows x 2 columns]" + ] + }, + "execution_count": 33, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "df.sort_values(by=['word'])" ] }, { @@ -166,11 +409,120 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 34, "metadata": {}, - "outputs": [], + "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", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
wordfreq
139bar1
114let1
116van1
60out1
57it1
.........
0love25
65in27
121my33
56come37
126on40
\n", + "

140 rows × 2 columns

\n", + "
" + ], + "text/plain": [ + " word freq\n", + "139 bar 1\n", + "114 let 1\n", + "116 van 1\n", + "60 out 1\n", + "57 it 1\n", + ".. ... ...\n", + "0 love 25\n", + "65 in 27\n", + "121 my 33\n", + "56 come 37\n", + "126 on 40\n", + "\n", + "[140 rows x 2 columns]" + ] + }, + "execution_count": 34, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "df.sort_values(by=['freq'])" ] } ], @@ -190,7 +542,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.2" + "version": "3.8.8" } }, "nbformat": 4,