diff --git a/rschenck.ipynb b/rschenck.ipynb new file mode 100644 index 0000000..757a70a --- /dev/null +++ b/rschenck.ipynb @@ -0,0 +1,95 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 33, + "id": "871b9b47", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The least used word is carews\n", + "It was used 1 times\n", + "The most used word is to\n", + "It was used 238375 times\n" + ] + } + ], + "source": [ + "import pandas as pd\n", + "\n", + "data = pd.read_csv('/home/robert/Desktop/abcnews-date-text.csv')\n", + "headlines = data['headline_text']\n", + "test = {}\n", + "\n", + "for strObject in headlines.values:\n", + " words = strObject.split()\n", + " for word in words:\n", + " if word.isdigit() or word == '5;919' or word == '2;093':\n", + " continue\n", + " if word in test:\n", + " num = test.get(word)\n", + " test[word] = num + 1\n", + " else:\n", + " test[word] = 1\n", + " \n", + "mostUsed = 0\n", + "leastUsed = 1000000\n", + "mostUsedWord = ''\n", + "leastUsedWord = ''\n", + "\n", + "for word in test:\n", + " if test[word] < leastUsed:\n", + " leastUsedWord = word\n", + " leastUsed = test[word]\n", + " if test[word] > mostUsed:\n", + " mostUsedWord = word\n", + " mostUsed = test[word]\n", + " \n", + "print('The least used word is', leastUsedWord)\n", + "print('It was used', leastUsed, 'times')\n", + "print('The most used word is', mostUsedWord)\n", + "print('It was used', mostUsed, 'times')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c142ecef", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "597d8216", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}