├── .DS_Store ├── Life Quest.pdf ├── Police Ordinance.pdf ├── Dunn Transportation.pdf ├── Simple Python Dashboard Part 1 └── Goals.csv ├── LICENSE ├── Pandas_Profiling.ipynb ├── Query_Big_Query_from_Python_Notebook.ipynb ├── LOF.ipynb ├── WordCloud.ipynb ├── Query.ipynb ├── Categorical_Encoding.ipynb ├── Binning.ipynb ├── Univariate_Outlier_Detection.ipynb ├── OpenAI_API_in_Python.ipynb ├── Working_with_APIs_Covid.ipynb ├── Sentiment_Analysis_OpenAI_API.ipynb ├── Web_Scraping_from_TrustPilot_v3.ipynb ├── Data ├── heart.csv └── euro2016goals.csv ├── Pull_all_Comments_and_Replies_for_YouTube_Playlists.ipynb ├── Dummy_Data.ipynb ├── Lambda.ipynb ├── YouTubeComments.ipynb ├── Apex_Connect.ipynb └── Web_Scraping_from_TrustPilot.ipynb /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/analyticswithadam/Python/HEAD/.DS_Store -------------------------------------------------------------------------------- /Life Quest.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/analyticswithadam/Python/HEAD/Life Quest.pdf -------------------------------------------------------------------------------- /Police Ordinance.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/analyticswithadam/Python/HEAD/Police Ordinance.pdf -------------------------------------------------------------------------------- /Dunn Transportation.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/analyticswithadam/Python/HEAD/Dunn Transportation.pdf -------------------------------------------------------------------------------- /Simple Python Dashboard Part 1/Goals.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/analyticswithadam/Python/HEAD/Simple Python Dashboard Part 1/Goals.csv -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 SuperDataWorld 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Pandas_Profiling.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "Pandas Profiling.ipynb", 7 | "private_outputs": true, 8 | "provenance": [], 9 | "collapsed_sections": [], 10 | "include_colab_link": true 11 | }, 12 | "kernelspec": { 13 | "name": "python3", 14 | "display_name": "Python 3" 15 | }, 16 | "language_info": { 17 | "name": "python" 18 | }, 19 | "accelerator": "GPU" 20 | }, 21 | "cells": [ 22 | { 23 | "cell_type": "markdown", 24 | "metadata": { 25 | "id": "view-in-github", 26 | "colab_type": "text" 27 | }, 28 | "source": [ 29 | "\"Open" 30 | ] 31 | }, 32 | { 33 | "cell_type": "markdown", 34 | "metadata": { 35 | "id": "C5he_jAvzM_Q" 36 | }, 37 | "source": [ 38 | "## 1. Import Pandas, Pyplot and Read Data\n", 39 | "\n" 40 | ] 41 | }, 42 | { 43 | "cell_type": "code", 44 | "metadata": { 45 | "id": "olx6o0tuRFVm" 46 | }, 47 | "source": [ 48 | "!pip install https://github.com/pandas-profiling/pandas-profiling/archive/master.zip" 49 | ], 50 | "execution_count": null, 51 | "outputs": [] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "metadata": { 56 | "id": "MDfXkCh2zD4v" 57 | }, 58 | "source": [ 59 | "import pandas as pd\n", 60 | "import matplotlib.pyplot as plt\n", 61 | "from pandas_profiling import ProfileReport\n", 62 | "%matplotlib inline\n", 63 | "pd.set_option('display.max_colwidth', None)" 64 | ], 65 | "execution_count": null, 66 | "outputs": [] 67 | }, 68 | { 69 | "cell_type": "code", 70 | "metadata": { 71 | "id": "0tA2cpynEzLU" 72 | }, 73 | "source": [ 74 | "df = pd.read_csv('heart.csv')" 75 | ], 76 | "execution_count": null, 77 | "outputs": [] 78 | }, 79 | { 80 | "cell_type": "markdown", 81 | "metadata": { 82 | "id": "hG6wXb4KO8Lt" 83 | }, 84 | "source": [ 85 | "## 2. Exploratory Data Analysis \n", 86 | "\n", 87 | "---" 88 | ] 89 | }, 90 | { 91 | "cell_type": "code", 92 | "metadata": { 93 | "id": "2tz3KKg3Qseu" 94 | }, 95 | "source": [ 96 | "# Pandas profiling report\n", 97 | "profile = ProfileReport(df, title='Heart Data', explorative=True)" 98 | ], 99 | "execution_count": null, 100 | "outputs": [] 101 | }, 102 | { 103 | "cell_type": "code", 104 | "metadata": { 105 | "id": "ARiCWwedUzBd" 106 | }, 107 | "source": [ 108 | "# For notebook exploration\n", 109 | "profile.to_notebook_iframe()" 110 | ], 111 | "execution_count": null, 112 | "outputs": [] 113 | }, 114 | { 115 | "cell_type": "code", 116 | "metadata": { 117 | "id": "A8xQo0RMWJDy" 118 | }, 119 | "source": [ 120 | "# export analysis results to an html page, for sharing to a wider audience and non-Jupyter users.\n", 121 | "profile.to_file('Heart Data.html')" 122 | ], 123 | "execution_count": null, 124 | "outputs": [] 125 | } 126 | ] 127 | } -------------------------------------------------------------------------------- /Query_Big_Query_from_Python_Notebook.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "provenance": [], 7 | "authorship_tag": "ABX9TyOtdIzYDE8gUyle84xKEEeT", 8 | "include_colab_link": true 9 | }, 10 | "kernelspec": { 11 | "name": "python3", 12 | "display_name": "Python 3" 13 | }, 14 | "language_info": { 15 | "name": "python" 16 | } 17 | }, 18 | "cells": [ 19 | { 20 | "cell_type": "markdown", 21 | "metadata": { 22 | "id": "view-in-github", 23 | "colab_type": "text" 24 | }, 25 | "source": [ 26 | "\"Open" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "source": [ 32 | "!pip install --upgrade google-cloud-bigquery" 33 | ], 34 | "metadata": { 35 | "id": "n4LvC5cZK3x2" 36 | }, 37 | "execution_count": null, 38 | "outputs": [] 39 | }, 40 | { 41 | "cell_type": "code", 42 | "source": [ 43 | "from google.colab import auth\n", 44 | "auth.authenticate_user()\n", 45 | "print('Authenticated')" 46 | ], 47 | "metadata": { 48 | "id": "mrdyqZ1CKTcD" 49 | }, 50 | "execution_count": null, 51 | "outputs": [] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "source": [ 56 | "# Set your Google Cloud Project ID\n", 57 | "project_id = 'sqlcourse-352110'" 58 | ], 59 | "metadata": { 60 | "id": "z3T36Uz5O1gS" 61 | }, 62 | "execution_count": null, 63 | "outputs": [] 64 | }, 65 | { 66 | "cell_type": "code", 67 | "source": [ 68 | "from google.cloud import bigquery\n", 69 | "import pandas as pd\n", 70 | "\n", 71 | "# Create a BigQuery client\n", 72 | "client = bigquery.Client(project=project_id)" 73 | ], 74 | "metadata": { 75 | "id": "A842uhabLhK1" 76 | }, 77 | "execution_count": null, 78 | "outputs": [] 79 | }, 80 | { 81 | "cell_type": "code", 82 | "source": [ 83 | "query = \"\"\"\n", 84 | " SELECT name, SUM(number) as count\n", 85 | " FROM `bigquery-public-data.usa_names.usa_1910_current`\n", 86 | " GROUP BY name\n", 87 | " ORDER BY count DESC\n", 88 | " LIMIT 10\n", 89 | " \"\"\"\n", 90 | "\n", 91 | "query_job = client.query(query)" 92 | ], 93 | "metadata": { 94 | "id": "7wObBCmuOQWW" 95 | }, 96 | "execution_count": null, 97 | "outputs": [] 98 | }, 99 | { 100 | "cell_type": "code", 101 | "source": [ 102 | "df = query_job.to_dataframe()\n", 103 | "df" 104 | ], 105 | "metadata": { 106 | "id": "8DKwm7WyOTqY" 107 | }, 108 | "execution_count": null, 109 | "outputs": [] 110 | }, 111 | { 112 | "cell_type": "code", 113 | "source": [ 114 | "%%bigquery df --project sqlcourse-352110\n", 115 | "SELECT name, SUM(number) as count\n", 116 | " FROM `bigquery-public-data.usa_names.usa_1910_current`\n", 117 | " GROUP BY name\n", 118 | " ORDER BY count DESC\n", 119 | " LIMIT 10" 120 | ], 121 | "metadata": { 122 | "id": "B1Lgc64LRW_V" 123 | }, 124 | "execution_count": null, 125 | "outputs": [] 126 | }, 127 | { 128 | "cell_type": "code", 129 | "source": [ 130 | "df" 131 | ], 132 | "metadata": { 133 | "id": "GMroggFISQsV" 134 | }, 135 | "execution_count": null, 136 | "outputs": [] 137 | } 138 | ] 139 | } -------------------------------------------------------------------------------- /LOF.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "LOF.ipynb", 7 | "provenance": [], 8 | "include_colab_link": true 9 | }, 10 | "kernelspec": { 11 | "name": "python3", 12 | "display_name": "Python 3" 13 | }, 14 | "language_info": { 15 | "name": "python" 16 | } 17 | }, 18 | "cells": [ 19 | { 20 | "cell_type": "markdown", 21 | "metadata": { 22 | "id": "view-in-github", 23 | "colab_type": "text" 24 | }, 25 | "source": [ 26 | "\"Open" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "source": [ 32 | "import random\n", 33 | "import pandas as pd\n", 34 | "\n", 35 | "pct = [.01,.08,.12]\n", 36 | "amounts = [1000, 2000, 3000]\n", 37 | "charges = pd.DataFrame()\n", 38 | "\n", 39 | "for i in range(0, 1000):\n", 40 | " amount = random.choice(amounts) * (random.uniform(.95, 1.05))\n", 41 | " bank_charge = amount * .04 * (random.uniform(.95, 1.05))\n", 42 | " linedict = {'Amount': [amount], 'Charge':[bank_charge]}\n", 43 | " line = pd.DataFrame(linedict)\n", 44 | " charges = pd.concat([charges, line])\n", 45 | "\n", 46 | "for i in range(0, 10):\n", 47 | " amount = random.choice(amounts) * (random.uniform(.95, 1.05))\n", 48 | " bank_charge = amount * random.choice(pct) * (random.uniform(.95, 1.05))\n", 49 | " linedict = {'Amount': [amount], 'Charge':[bank_charge]}\n", 50 | " line = pd.DataFrame(linedict)\n", 51 | " charges = pd.concat([charges, line])" 52 | ], 53 | "metadata": { 54 | "id": "xlnPkGURlaC1" 55 | }, 56 | "execution_count": null, 57 | "outputs": [] 58 | }, 59 | { 60 | "cell_type": "code", 61 | "source": [ 62 | "charges.head(10)" 63 | ], 64 | "metadata": { 65 | "id": "pRt8k3PRt5yN" 66 | }, 67 | "execution_count": null, 68 | "outputs": [] 69 | }, 70 | { 71 | "cell_type": "code", 72 | "source": [ 73 | "charges.tail(10)" 74 | ], 75 | "metadata": { 76 | "id": "AOe4Tn6qhUeP" 77 | }, 78 | "execution_count": null, 79 | "outputs": [] 80 | }, 81 | { 82 | "cell_type": "code", 83 | "source": [ 84 | "import numpy as np\n", 85 | "from sklearn.neighbors import LocalOutlierFactor\n", 86 | "clf = LocalOutlierFactor(n_neighbors=30)\n", 87 | "normalized_df=(charges-charges.mean())/charges.std()\n", 88 | "\n", 89 | "clf.fit_predict(normalized_df)\n", 90 | "results = clf.negative_outlier_factor_\n", 91 | "charges['LOF'] = results.tolist()\n", 92 | "charges['PCT'] = charges['Charge'] / charges['Amount']" 93 | ], 94 | "metadata": { 95 | "id": "PsljfQOGvjfq" 96 | }, 97 | "execution_count": null, 98 | "outputs": [] 99 | }, 100 | { 101 | "cell_type": "code", 102 | "source": [ 103 | "import matplotlib.pyplot as plt\n", 104 | "plt.scatter(charges.Amount, charges.Charge, c='black', s=charges.LOF * -1,label=\"Data Points\")\n", 105 | "radius = (results.max() - results) / (results.max() - results.min())\n", 106 | "plt.scatter(charges.Amount, charges.Charge, s=500 * radius,edgecolors=\"r\",facecolors=\"none\",label=\"Outlier scores\",)\n", 107 | "legend = plt.legend(loc=\"upper left\")\n", 108 | "legend.legendHandles[0]._sizes = [10]\n", 109 | "legend.legendHandles[1]._sizes = [20]\n", 110 | "plt.show()\n" 111 | ], 112 | "metadata": { 113 | "id": "gJoBLkrLlZ61" 114 | }, 115 | "execution_count": null, 116 | "outputs": [] 117 | }, 118 | { 119 | "cell_type": "code", 120 | "source": [ 121 | "charges.query('LOF < -1.5')" 122 | ], 123 | "metadata": { 124 | "id": "2vD1dpO3lCyC" 125 | }, 126 | "execution_count": null, 127 | "outputs": [] 128 | } 129 | ] 130 | } -------------------------------------------------------------------------------- /WordCloud.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "provenance": [], 7 | "authorship_tag": "ABX9TyMV4dzU5X0HHevhQb+jHILU", 8 | "include_colab_link": true 9 | }, 10 | "kernelspec": { 11 | "name": "python3", 12 | "display_name": "Python 3" 13 | }, 14 | "language_info": { 15 | "name": "python" 16 | } 17 | }, 18 | "cells": [ 19 | { 20 | "cell_type": "markdown", 21 | "metadata": { 22 | "id": "view-in-github", 23 | "colab_type": "text" 24 | }, 25 | "source": [ 26 | "\"Open" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": null, 32 | "metadata": { 33 | "id": "E3nWmsQ1jyNE" 34 | }, 35 | "outputs": [], 36 | "source": [ 37 | "# Install wordcloud if needed\n", 38 | "!pip install wordcloud\n", 39 | "\n", 40 | "# Imports \n", 41 | "from wordcloud import WordCloud, STOPWORDS\n", 42 | "import pandas as pd\n", 43 | "import matplotlib.pyplot as plt\n", 44 | "\n", 45 | "# URL for colormaps \n", 46 | "# https://matplotlib.org/stable/tutorials/colors/colormaps.html\n" 47 | ] 48 | }, 49 | { 50 | "cell_type": "code", 51 | "source": [ 52 | "# Import Data\n", 53 | "df = pd.read_csv('https://raw.githubusercontent.com/SuperDataWorld/Python/main/REF%20TWEETS.csv')" 54 | ], 55 | "metadata": { 56 | "id": "dle1j0ICkSqB" 57 | }, 58 | "execution_count": null, 59 | "outputs": [] 60 | }, 61 | { 62 | "cell_type": "code", 63 | "source": [ 64 | "# Unify Text from all weeks\n", 65 | "text = df['Tweet'].str.cat(sep=' ')" 66 | ], 67 | "metadata": { 68 | "id": "yP-gfk3MmUDU" 69 | }, 70 | "execution_count": null, 71 | "outputs": [] 72 | }, 73 | { 74 | "cell_type": "code", 75 | "source": [ 76 | "#set the stopwords list\n", 77 | "stopwords= set(STOPWORDS)\n", 78 | "new_words = []\n", 79 | "new_stopwords=stopwords.union(new_words)" 80 | ], 81 | "metadata": { 82 | "id": "ORtDDoURkSxT" 83 | }, 84 | "execution_count": null, 85 | "outputs": [] 86 | }, 87 | { 88 | "cell_type": "code", 89 | "source": [ 90 | "# Size of Word Cloud\n", 91 | "plt.rcParams[\"figure.figsize\"] = (10,10)\n", 92 | "\n", 93 | "# Make Wordcloud\n", 94 | "wordcloud = WordCloud(max_font_size=50, max_words=50, background_color=\"white\",stopwords=new_stopwords, colormap='flag').generate(text)\n", 95 | "\n", 96 | "# Plot Wordcloud\n", 97 | "plt.plot()\n", 98 | "plt.imshow(wordcloud, interpolation=\"bilinear\")\n", 99 | "plt.axis(\"off\")\n", 100 | "plt.show()" 101 | ], 102 | "metadata": { 103 | "id": "OMmb3X0AkSuI" 104 | }, 105 | "execution_count": null, 106 | "outputs": [] 107 | }, 108 | { 109 | "cell_type": "code", 110 | "source": [ 111 | "# Unify Text from tweets of different sentiment\n", 112 | "text = df[df['Sentiment']=='Negative']['Tweet'].str.cat(sep=' ')" 113 | ], 114 | "metadata": { 115 | "id": "0czKVYskotsY" 116 | }, 117 | "execution_count": null, 118 | "outputs": [] 119 | }, 120 | { 121 | "cell_type": "code", 122 | "source": [ 123 | "wordcloud = WordCloud(max_font_size=50, max_words=50, background_color=\"white\",stopwords=new_stopwords, colormap='flag').generate(text)\n", 124 | "plt.plot()\n", 125 | "plt.imshow(wordcloud, interpolation=\"bilinear\")\n", 126 | "plt.axis(\"off\")\n", 127 | "plt.show()" 128 | ], 129 | "metadata": { 130 | "id": "MjAp8u7Oo9xB" 131 | }, 132 | "execution_count": null, 133 | "outputs": [] 134 | }, 135 | { 136 | "cell_type": "code", 137 | "source": [], 138 | "metadata": { 139 | "id": "uJ0fgtW0pDWU" 140 | }, 141 | "execution_count": null, 142 | "outputs": [] 143 | } 144 | ] 145 | } -------------------------------------------------------------------------------- /Query.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "Query.ipynb", 7 | "provenance": [], 8 | "authorship_tag": "ABX9TyM9el45rKwsHbx33dJ/wsYf", 9 | "include_colab_link": true 10 | }, 11 | "kernelspec": { 12 | "name": "python3", 13 | "display_name": "Python 3" 14 | }, 15 | "language_info": { 16 | "name": "python" 17 | } 18 | }, 19 | "cells": [ 20 | { 21 | "cell_type": "markdown", 22 | "metadata": { 23 | "id": "view-in-github", 24 | "colab_type": "text" 25 | }, 26 | "source": [ 27 | "\"Open" 28 | ] 29 | }, 30 | { 31 | "cell_type": "markdown", 32 | "source": [ 33 | "#Data Import" 34 | ], 35 | "metadata": { 36 | "id": "dJC6Cu21Xc1Z" 37 | } 38 | }, 39 | { 40 | "cell_type": "code", 41 | "source": [ 42 | "import pandas as pd\n", 43 | "df = pd.read_csv('https://raw.githubusercontent.com/SuperDataWorld/Python/main/Data/euro2016goals.csv')" 44 | ], 45 | "metadata": { 46 | "id": "kS-UUCZLXgrp" 47 | }, 48 | "execution_count": null, 49 | "outputs": [] 50 | }, 51 | { 52 | "cell_type": "code", 53 | "source": [ 54 | "df.head()" 55 | ], 56 | "metadata": { 57 | "id": "HCFGf99qZiOf" 58 | }, 59 | "execution_count": null, 60 | "outputs": [] 61 | }, 62 | { 63 | "cell_type": "code", 64 | "source": [ 65 | "df = df[['FULL_NAME','AGE','POSITION','GOALS_OVERALL','ASSISTS_OVERALL','YELLOW_CARDS_OVERALL','PENALTY_GOALS','RED_CARDS_OVERALL']]\n", 66 | "df.columns = ['Name','AGE','Pos','Goals','Assists','YC','Pens','RC']\n", 67 | "df.head()" 68 | ], 69 | "metadata": { 70 | "id": "Jt0Uuh1VXdvv" 71 | }, 72 | "execution_count": null, 73 | "outputs": [] 74 | }, 75 | { 76 | "cell_type": "markdown", 77 | "source": [ 78 | "# Traditional Querying" 79 | ], 80 | "metadata": { 81 | "id": "rp3EfgqlXOBO" 82 | } 83 | }, 84 | { 85 | "cell_type": "code", 86 | "source": [ 87 | "df.AGE > 30" 88 | ], 89 | "metadata": { 90 | "id": "_yOzgEOYaEiD" 91 | }, 92 | "execution_count": null, 93 | "outputs": [] 94 | }, 95 | { 96 | "cell_type": "code", 97 | "source": [ 98 | "df['AGE'] > 30" 99 | ], 100 | "metadata": { 101 | "id": "EFUsTHkWcmJt" 102 | }, 103 | "execution_count": null, 104 | "outputs": [] 105 | }, 106 | { 107 | "cell_type": "code", 108 | "source": [ 109 | "df[df['AGE'] > 20]" 110 | ], 111 | "metadata": { 112 | "id": "1vIHq4T6aEui" 113 | }, 114 | "execution_count": null, 115 | "outputs": [] 116 | }, 117 | { 118 | "cell_type": "code", 119 | "execution_count": null, 120 | "metadata": { 121 | "id": "9cFjIloqW0fE" 122 | }, 123 | "outputs": [], 124 | "source": [ 125 | "df[(df['AGE'] > 25) & (df['Goals'] > 1) & (df['Pens'] == 1)]" 126 | ] 127 | }, 128 | { 129 | "cell_type": "code", 130 | "source": [ 131 | "df[(df['AGE'] > 25) & (df['Goals'] > 1) & (df['Pens'] == 1) & (df['Pos'] == 'Forward')]" 132 | ], 133 | "metadata": { 134 | "id": "8wbpZHAVdnWo" 135 | }, 136 | "execution_count": null, 137 | "outputs": [] 138 | }, 139 | { 140 | "cell_type": "markdown", 141 | "source": [ 142 | "# DF.Query" 143 | ], 144 | "metadata": { 145 | "id": "j7xLoTIlXO_0" 146 | } 147 | }, 148 | { 149 | "cell_type": "code", 150 | "source": [ 151 | "df.query('AGE > 20')" 152 | ], 153 | "metadata": { 154 | "id": "cOwday_xaFhT" 155 | }, 156 | "execution_count": null, 157 | "outputs": [] 158 | }, 159 | { 160 | "cell_type": "code", 161 | "source": [ 162 | "df.query('AGE > 20 & Goals > 1 & Pens == 1')" 163 | ], 164 | "metadata": { 165 | "id": "diOUhFBmaFaT" 166 | }, 167 | "execution_count": null, 168 | "outputs": [] 169 | }, 170 | { 171 | "cell_type": "code", 172 | "source": [ 173 | "df.query('AGE > 20 & Goals > 1 & Pens == 1 & Pos == \"Forward\"')" 174 | ], 175 | "metadata": { 176 | "id": "dFthlyLJXarx" 177 | }, 178 | "execution_count": null, 179 | "outputs": [] 180 | } 181 | ] 182 | } -------------------------------------------------------------------------------- /Categorical_Encoding.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "Categorical_Encoding.ipynb", 7 | "provenance": [], 8 | "authorship_tag": "ABX9TyPSJcA8vtQK+Vf9RPk7UAuB", 9 | "include_colab_link": true 10 | }, 11 | "kernelspec": { 12 | "name": "python3", 13 | "display_name": "Python 3" 14 | }, 15 | "language_info": { 16 | "name": "python" 17 | } 18 | }, 19 | "cells": [ 20 | { 21 | "cell_type": "markdown", 22 | "metadata": { 23 | "id": "view-in-github", 24 | "colab_type": "text" 25 | }, 26 | "source": [ 27 | "\"Open" 28 | ] 29 | }, 30 | { 31 | "cell_type": "markdown", 32 | "metadata": { 33 | "id": "eVbc2PHZVp-i" 34 | }, 35 | "source": [ 36 | "## Imports" 37 | ] 38 | }, 39 | { 40 | "cell_type": "code", 41 | "metadata": { 42 | "id": "ipCPKpl3U0q6" 43 | }, 44 | "source": [ 45 | "import pandas as pd\n", 46 | "import numpy as np" 47 | ], 48 | "execution_count": null, 49 | "outputs": [] 50 | }, 51 | { 52 | "cell_type": "markdown", 53 | "metadata": { 54 | "id": "Ex5FrY4zVvlo" 55 | }, 56 | "source": [ 57 | "## Import Data" 58 | ] 59 | }, 60 | { 61 | "cell_type": "code", 62 | "metadata": { 63 | "id": "PmD0nWFJvj6E" 64 | }, 65 | "source": [ 66 | "! wget https://raw.githubusercontent.com/SuperDataWorld/Python/main/Data/bmw.csv" 67 | ], 68 | "execution_count": null, 69 | "outputs": [] 70 | }, 71 | { 72 | "cell_type": "code", 73 | "metadata": { 74 | "id": "iaQxndU_uWXz" 75 | }, 76 | "source": [ 77 | "df = pd.read_csv('bmw.csv')\n", 78 | "df.head()" 79 | ], 80 | "execution_count": null, 81 | "outputs": [] 82 | }, 83 | { 84 | "cell_type": "markdown", 85 | "metadata": { 86 | "id": "1udURtgOWpCw" 87 | }, 88 | "source": [ 89 | "# Investigate Data" 90 | ] 91 | }, 92 | { 93 | "cell_type": "code", 94 | "metadata": { 95 | "id": "S91wvDtEWons" 96 | }, 97 | "source": [ 98 | "df.info()" 99 | ], 100 | "execution_count": null, 101 | "outputs": [] 102 | }, 103 | { 104 | "cell_type": "code", 105 | "metadata": { 106 | "id": "ysxj4Kf9WuCJ" 107 | }, 108 | "source": [ 109 | "col_list = df.columns\n", 110 | "\n", 111 | "for i in col_list:\n", 112 | " print(i+' values \\n')\n", 113 | " print(df[i].value_counts())" 114 | ], 115 | "execution_count": null, 116 | "outputs": [] 117 | }, 118 | { 119 | "cell_type": "markdown", 120 | "metadata": { 121 | "id": "81kQh9NhX12c" 122 | }, 123 | "source": [ 124 | "## Convert to Category" 125 | ] 126 | }, 127 | { 128 | "cell_type": "code", 129 | "metadata": { 130 | "id": "tQBjOl8XX5kk" 131 | }, 132 | "source": [ 133 | "conversion_list = ['engineSize','fuelType','year','model']\n", 134 | "for i in conversion_list:\n", 135 | " df[i] = df[i].astype('category')\n", 136 | "\n", 137 | "df.info()" 138 | ], 139 | "execution_count": null, 140 | "outputs": [] 141 | }, 142 | { 143 | "cell_type": "code", 144 | "metadata": { 145 | "id": "bV6Mk2h2YiA8" 146 | }, 147 | "source": [ 148 | "df.head()" 149 | ], 150 | "execution_count": null, 151 | "outputs": [] 152 | }, 153 | { 154 | "cell_type": "markdown", 155 | "metadata": { 156 | "id": "gfwqnoopY4kY" 157 | }, 158 | "source": [ 159 | "## Method 1 Get Dummies" 160 | ] 161 | }, 162 | { 163 | "cell_type": "code", 164 | "metadata": { 165 | "id": "xP9alx3zY0FW" 166 | }, 167 | "source": [ 168 | "df2 = pd.get_dummies(df)\n", 169 | "df2.head()" 170 | ], 171 | "execution_count": null, 172 | "outputs": [] 173 | }, 174 | { 175 | "cell_type": "markdown", 176 | "metadata": { 177 | "id": "-iJfsrJCZaYe" 178 | }, 179 | "source": [ 180 | "## Binning" 181 | ] 182 | }, 183 | { 184 | "cell_type": "code", 185 | "metadata": { 186 | "id": "iCn5nJkUZWRS" 187 | }, 188 | "source": [ 189 | "#df['engine_bin'] = pd.cut(df.engineSize, 4, labels = ['bin1','bin2','bin3','bin4'])\n", 190 | "df['engine_bin'] = pd.cut(df.engineSize, 4)\n", 191 | "df.head()\n", 192 | "df3 = df.drop(['engineSize'], axis = 1)\n", 193 | "pd.get_dummies(df3)" 194 | ], 195 | "execution_count": null, 196 | "outputs": [] 197 | }, 198 | { 199 | "cell_type": "code", 200 | "metadata": { 201 | "id": "03VkQYNqbQNO" 202 | }, 203 | "source": [ 204 | "" 205 | ], 206 | "execution_count": null, 207 | "outputs": [] 208 | } 209 | ] 210 | } -------------------------------------------------------------------------------- /Binning.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "Binning.ipynb", 7 | "provenance": [], 8 | "authorship_tag": "ABX9TyNkIYmu1JGWfSs1T/1yGaMp", 9 | "include_colab_link": true 10 | }, 11 | "kernelspec": { 12 | "name": "python3", 13 | "display_name": "Python 3" 14 | }, 15 | "language_info": { 16 | "name": "python" 17 | } 18 | }, 19 | "cells": [ 20 | { 21 | "cell_type": "markdown", 22 | "metadata": { 23 | "id": "view-in-github", 24 | "colab_type": "text" 25 | }, 26 | "source": [ 27 | "\"Open" 28 | ] 29 | }, 30 | { 31 | "cell_type": "code", 32 | "execution_count": null, 33 | "metadata": { 34 | "id": "siFijo0HbiPZ" 35 | }, 36 | "outputs": [], 37 | "source": [ 38 | "import pandas as pd\n", 39 | "df = pd.read_csv('https://raw.githubusercontent.com/SuperDataWorld/Python/main/Data/StudentsPerformance.csv')" 40 | ] 41 | }, 42 | { 43 | "cell_type": "code", 44 | "source": [ 45 | "df.head()" 46 | ], 47 | "metadata": { 48 | "id": "oTYCuxBTbsbX" 49 | }, 50 | "execution_count": null, 51 | "outputs": [] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "source": [ 56 | "df.columns" 57 | ], 58 | "metadata": { 59 | "id": "iZJPRWV6bseN" 60 | }, 61 | "execution_count": null, 62 | "outputs": [] 63 | }, 64 | { 65 | "cell_type": "code", 66 | "source": [ 67 | "df.columns = ['gender', 'ethnicity', 'parentaledu', 'lunch', 'prep', 'math', 'reading','writing']" 68 | ], 69 | "metadata": { 70 | "id": "dI2HH_obbsgQ" 71 | }, 72 | "execution_count": null, 73 | "outputs": [] 74 | }, 75 | { 76 | "cell_type": "code", 77 | "source": [ 78 | "df.head()" 79 | ], 80 | "metadata": { 81 | "id": "CjhvWkYvbsiC" 82 | }, 83 | "execution_count": null, 84 | "outputs": [] 85 | }, 86 | { 87 | "cell_type": "code", 88 | "source": [ 89 | "df.parentaledu.value_counts()" 90 | ], 91 | "metadata": { 92 | "id": "8c_bwK9pbska" 93 | }, 94 | "execution_count": null, 95 | "outputs": [] 96 | }, 97 | { 98 | "cell_type": "code", 99 | "source": [ 100 | "#Dummy Bins\n", 101 | "pd.get_dummies(df.parentaledu)" 102 | ], 103 | "metadata": { 104 | "id": "dmoOGbovkE7U" 105 | }, 106 | "execution_count": null, 107 | "outputs": [] 108 | }, 109 | { 110 | "cell_type": "code", 111 | "source": [ 112 | "# Numeric Bins\n", 113 | "\n", 114 | "df['parentaledu'] = pd.Categorical(df.parentaledu, ordered = True, \n", 115 | " categories = [\"some high school\",\"high school\",\"some college\",\"associate's degree\",\"bachelor's degree\",\"master's degree\"])\n", 116 | "\n", 117 | "print(df.parentaledu.min())\n", 118 | "print(df.parentaledu.max())\n", 119 | "df['parentaledu']\n" 120 | ], 121 | "metadata": { 122 | "id": "9Eze0LmRkDSI" 123 | }, 124 | "execution_count": null, 125 | "outputs": [] 126 | }, 127 | { 128 | "cell_type": "code", 129 | "source": [ 130 | "df['parentaledu'].cat.codes" 131 | ], 132 | "metadata": { 133 | "id": "5daZ708WE_0r" 134 | }, 135 | "execution_count": null, 136 | "outputs": [] 137 | }, 138 | { 139 | "cell_type": "code", 140 | "source": [ 141 | "df.reading.hist()" 142 | ], 143 | "metadata": { 144 | "id": "Tu2S-IdNdEt6" 145 | }, 146 | "execution_count": null, 147 | "outputs": [] 148 | }, 149 | { 150 | "cell_type": "code", 151 | "source": [ 152 | "lables = ['low','average','high']\n", 153 | "\n", 154 | "#Equi-width Bining\n", 155 | "\n", 156 | "df['readingrank'] = pd.cut(df.reading, bins = 3, labels = lables)\n", 157 | "df.readingrank.value_counts()" 158 | ], 159 | "metadata": { 160 | "id": "t_9T6IXIdRPj" 161 | }, 162 | "execution_count": null, 163 | "outputs": [] 164 | }, 165 | { 166 | "cell_type": "code", 167 | "source": [ 168 | "df.groupby('readingrank')['reading'].mean()" 169 | ], 170 | "metadata": { 171 | "id": "jUBewmYdhlcH" 172 | }, 173 | "execution_count": null, 174 | "outputs": [] 175 | }, 176 | { 177 | "cell_type": "code", 178 | "source": [ 179 | "#Equi-depth Bining\n", 180 | "df['readingrank2'] = pd.qcut(df.reading, q = 3, labels = lables)\n", 181 | "df.readingrank2.value_counts()" 182 | ], 183 | "metadata": { 184 | "id": "REOcP8Y4dgdO" 185 | }, 186 | "execution_count": null, 187 | "outputs": [] 188 | }, 189 | { 190 | "cell_type": "code", 191 | "source": [ 192 | "df.groupby('readingrank2')['reading'].mean()" 193 | ], 194 | "metadata": { 195 | "id": "HURmWIg5dRVE" 196 | }, 197 | "execution_count": null, 198 | "outputs": [] 199 | } 200 | ] 201 | } -------------------------------------------------------------------------------- /Univariate_Outlier_Detection.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "Univariate Outlier Detection.ipynb", 7 | "provenance": [], 8 | "authorship_tag": "ABX9TyN3D1T7tGc5nw9P9ik0zWCd", 9 | "include_colab_link": true 10 | }, 11 | "kernelspec": { 12 | "name": "python3", 13 | "display_name": "Python 3" 14 | }, 15 | "language_info": { 16 | "name": "python" 17 | } 18 | }, 19 | "cells": [ 20 | { 21 | "cell_type": "markdown", 22 | "metadata": { 23 | "id": "view-in-github", 24 | "colab_type": "text" 25 | }, 26 | "source": [ 27 | "\"Open" 28 | ] 29 | }, 30 | { 31 | "cell_type": "code", 32 | "execution_count": null, 33 | "metadata": { 34 | "id": "e5Hdn6y65LMr" 35 | }, 36 | "outputs": [], 37 | "source": [ 38 | "import pandas as pd\n", 39 | "import matplotlib.pyplot as plt\n", 40 | "import seaborn as sns\n", 41 | "%matplotlib inline" 42 | ] 43 | }, 44 | { 45 | "cell_type": "code", 46 | "source": [ 47 | "df = pd.read_csv('https://raw.githubusercontent.com/SuperDataWorld/Python/main/Data/bikerental.csv')" 48 | ], 49 | "metadata": { 50 | "id": "_Q0W1pdT5yHP" 51 | }, 52 | "execution_count": null, 53 | "outputs": [] 54 | }, 55 | { 56 | "cell_type": "code", 57 | "source": [ 58 | "df.describe()" 59 | ], 60 | "metadata": { 61 | "id": "kczTodol9mj9" 62 | }, 63 | "execution_count": null, 64 | "outputs": [] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "source": [ 69 | "df.head()" 70 | ], 71 | "metadata": { 72 | "id": "U2Y7onin8XVT" 73 | }, 74 | "execution_count": null, 75 | "outputs": [] 76 | }, 77 | { 78 | "cell_type": "code", 79 | "source": [ 80 | "sns.set_palette(\"bone_r\")\n", 81 | "f , axes = plt.subplots(nrows=1, ncols=3, figsize = (20,4))\n", 82 | "sns.set_style(\"darkgrid\")\n", 83 | "\n", 84 | "fig1 = sns.boxplot(y= df.windspeed, ax = axes[0] )\n", 85 | "fig2 = sns.boxplot(y= df.hum, ax = axes[1] )\n", 86 | "fig3 = sns.boxplot(y=df.casual, ax = axes[2] )\n", 87 | "plt.show()" 88 | ], 89 | "metadata": { 90 | "id": "j29b746T5jSj" 91 | }, 92 | "execution_count": null, 93 | "outputs": [] 94 | }, 95 | { 96 | "cell_type": "code", 97 | "source": [ 98 | "df.windspeed.quantile(.25)" 99 | ], 100 | "metadata": { 101 | "id": "exMkzpmv5jPu" 102 | }, 103 | "execution_count": null, 104 | "outputs": [] 105 | }, 106 | { 107 | "cell_type": "code", 108 | "source": [ 109 | "IQR = df.windspeed.quantile(.75) - df.windspeed.quantile(.25)\n", 110 | "IQR" 111 | ], 112 | "metadata": { 113 | "id": "HlJJmRgp5jLs" 114 | }, 115 | "execution_count": null, 116 | "outputs": [] 117 | }, 118 | { 119 | "cell_type": "code", 120 | "source": [ 121 | "whisker = (df.windspeed.quantile(.75) - df.windspeed.quantile(.25)) * 1.5\n", 122 | "whisker\n" 123 | ], 124 | "metadata": { 125 | "id": "Ln9tWtPi8hY5" 126 | }, 127 | "execution_count": null, 128 | "outputs": [] 129 | }, 130 | { 131 | "cell_type": "code", 132 | "source": [ 133 | "lower_range = df.windspeed.quantile(.25) - whisker \n", 134 | "upper_range = df.windspeed.quantile(.75) + whisker " 135 | ], 136 | "metadata": { 137 | "id": "iUTmOyng_T_o" 138 | }, 139 | "execution_count": null, 140 | "outputs": [] 141 | }, 142 | { 143 | "cell_type": "code", 144 | "source": [ 145 | "df.query('windspeed > @upper_range | windspeed < @lower_range' )" 146 | ], 147 | "metadata": { 148 | "id": "FkmocZzB_-KH" 149 | }, 150 | "execution_count": null, 151 | "outputs": [] 152 | }, 153 | { 154 | "cell_type": "code", 155 | "source": [ 156 | "def findoutliers(col):\n", 157 | " whisker = (col.quantile(.75) - col.quantile(.25)) * 1.5\n", 158 | " lower_range = col.quantile(.25) - whisker \n", 159 | " upper_range = col.quantile(.75) + whisker\n", 160 | " return df.query('@col > @upper_range | @col < @lower_range')" 161 | ], 162 | "metadata": { 163 | "id": "wpCrLGE-Bm38" 164 | }, 165 | "execution_count": null, 166 | "outputs": [] 167 | }, 168 | { 169 | "cell_type": "code", 170 | "source": [ 171 | "findoutliers(df.hum)" 172 | ], 173 | "metadata": { 174 | "id": "AQ9zNDdpB6SQ" 175 | }, 176 | "execution_count": null, 177 | "outputs": [] 178 | }, 179 | { 180 | "cell_type": "code", 181 | "source": [ 182 | "cas = findoutliers(df.casual)" 183 | ], 184 | "metadata": { 185 | "id": "yQ46dhD-CdVi" 186 | }, 187 | "execution_count": null, 188 | "outputs": [] 189 | }, 190 | { 191 | "cell_type": "code", 192 | "source": [ 193 | "cas" 194 | ], 195 | "metadata": { 196 | "id": "m60lEUO9EEc-" 197 | }, 198 | "execution_count": null, 199 | "outputs": [] 200 | } 201 | ] 202 | } -------------------------------------------------------------------------------- /OpenAI_API_in_Python.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "provenance": [], 7 | "include_colab_link": true 8 | }, 9 | "kernelspec": { 10 | "name": "python3", 11 | "display_name": "Python 3" 12 | }, 13 | "language_info": { 14 | "name": "python" 15 | } 16 | }, 17 | "cells": [ 18 | { 19 | "cell_type": "markdown", 20 | "metadata": { 21 | "id": "view-in-github", 22 | "colab_type": "text" 23 | }, 24 | "source": [ 25 | "\"Open" 26 | ] 27 | }, 28 | { 29 | "cell_type": "code", 30 | "execution_count": null, 31 | "metadata": { 32 | "id": "1YP6-sABwTEv" 33 | }, 34 | "outputs": [], 35 | "source": [ 36 | "# get the openai secret key\n", 37 | "import getpass\n", 38 | "\n", 39 | "# https://platform.openai.com/account/api-keys\n", 40 | "secret_key = getpass.getpass('Please enter your openai key: ')" 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "source": [ 46 | "!pip install openai" 47 | ], 48 | "metadata": { 49 | "id": "pUl4Xe2FwYJ1" 50 | }, 51 | "execution_count": null, 52 | "outputs": [] 53 | }, 54 | { 55 | "cell_type": "code", 56 | "source": [ 57 | "from openai import OpenAI\n", 58 | "client = OpenAI(api_key=secret_key)\n", 59 | "\n", 60 | "def get_response(role, prompt):\n", 61 | " response = client.chat.completions.create(\n", 62 | " model=\"gpt-3.5-turbo\",\n", 63 | " messages=[\n", 64 | " {\n", 65 | " \"role\": \"system\",\n", 66 | " \"content\": f\"\"\" {role} \"\"\"\n", 67 | " },\n", 68 | " {\n", 69 | " \"role\": \"user\",\n", 70 | " \"content\": f\"\"\"{prompt} \"\"\"\n", 71 | " }\n", 72 | " ],\n", 73 | " temperature=.25,\n", 74 | " max_tokens=1000,\n", 75 | " top_p=1,\n", 76 | " frequency_penalty=0,\n", 77 | " presence_penalty=0\n", 78 | " )\n", 79 | " return response.choices[0].message.content" 80 | ], 81 | "metadata": { 82 | "id": "416nypIKwYEv" 83 | }, 84 | "execution_count": null, 85 | "outputs": [] 86 | }, 87 | { 88 | "cell_type": "code", 89 | "source": [ 90 | "# Collect Info\n", 91 | "Role = \"\"\"You are an expert in business. I want you to classify\n", 92 | "these companies in to their industries in one word\"\"\"\n", 93 | "Companies = \"IBM, Netflix, Chase, Meta\"\n" 94 | ], 95 | "metadata": { 96 | "id": "Alr4sMQUzChH" 97 | }, 98 | "execution_count": null, 99 | "outputs": [] 100 | }, 101 | { 102 | "cell_type": "code", 103 | "source": [ 104 | "print(get_response(Role, Companies))" 105 | ], 106 | "metadata": { 107 | "id": "yGv6KAyP4p5p" 108 | }, 109 | "execution_count": null, 110 | "outputs": [] 111 | }, 112 | { 113 | "cell_type": "code", 114 | "source": [ 115 | "\n", 116 | "def get_response(role, example, examplea, prompt):\n", 117 | " response = client.chat.completions.create(\n", 118 | " model=\"gpt-3.5-turbo\",\n", 119 | " messages=[\n", 120 | " {\n", 121 | " \"role\": \"system\",\n", 122 | " \"content\": f\"\"\" {role} \"\"\"\n", 123 | " },\n", 124 | " {\n", 125 | " \"role\": \"user\",\n", 126 | " \"content\": f\"\"\" {example} \"\"\"\n", 127 | " },\n", 128 | " {\n", 129 | " \"role\": \"assistant\",\n", 130 | " \"content\": f\"\"\" {examplea} \"\"\"\n", 131 | " },\n", 132 | " {\n", 133 | " \"role\": \"user\",\n", 134 | " \"content\": f\"\"\"{prompt} \"\"\"\n", 135 | " }\n", 136 | " ],\n", 137 | " temperature=.25,\n", 138 | " max_tokens=1000,\n", 139 | " top_p=1,\n", 140 | " frequency_penalty=0,\n", 141 | " presence_penalty=0\n", 142 | " )\n", 143 | " return response.choices[0].message.content" 144 | ], 145 | "metadata": { 146 | "id": "PoX_L2qnAbHR" 147 | }, 148 | "execution_count": null, 149 | "outputs": [] 150 | }, 151 | { 152 | "cell_type": "code", 153 | "source": [ 154 | "# Collect Info\n", 155 | "\n", 156 | "Role = \"\"\"You are an expert in business. I want you to classify\n", 157 | "these companies in to their industries in one word\"\"\"\n", 158 | "ExampleQ = \"Apple, Microsoft, JP Morgan\"\n", 159 | "ExampleA = \"Tech, Tech, FS\"\n", 160 | "Companies = \"IBM, Netflix, Meta, Citi\"" 161 | ], 162 | "metadata": { 163 | "id": "XKABfKsQAftb" 164 | }, 165 | "execution_count": null, 166 | "outputs": [] 167 | }, 168 | { 169 | "cell_type": "markdown", 170 | "source": [], 171 | "metadata": { 172 | "id": "b3qHoUwBCF_k" 173 | } 174 | }, 175 | { 176 | "cell_type": "code", 177 | "source": [ 178 | "print(get_response(Role, ExampleQ, ExampleA, Companies))" 179 | ], 180 | "metadata": { 181 | "id": "i7MWraIcAimy" 182 | }, 183 | "execution_count": null, 184 | "outputs": [] 185 | } 186 | ] 187 | } -------------------------------------------------------------------------------- /Working_with_APIs_Covid.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "provenance": [], 7 | "include_colab_link": true 8 | }, 9 | "kernelspec": { 10 | "name": "python3", 11 | "display_name": "Python 3" 12 | }, 13 | "language_info": { 14 | "name": "python" 15 | } 16 | }, 17 | "cells": [ 18 | { 19 | "cell_type": "markdown", 20 | "metadata": { 21 | "id": "view-in-github", 22 | "colab_type": "text" 23 | }, 24 | "source": [ 25 | "\"Open" 26 | ] 27 | }, 28 | { 29 | "cell_type": "markdown", 30 | "source": [ 31 | "\n", 32 | "## Public API \n", 33 | "Data can retrieved from an API publically or with a key
A publically avaliable example is the covid API (https://api.covid19api.com/summary)\n", 34 | "\n" 35 | ], 36 | "metadata": { 37 | "id": "xqkvfYt7gIP_" 38 | } 39 | }, 40 | { 41 | "cell_type": "code", 42 | "source": [ 43 | "# Request Liabrary can pull a reponse from an API \n", 44 | "import requests\n", 45 | "response = requests.get('https://api.covid19api.com/summary').text" 46 | ], 47 | "metadata": { 48 | "id": "GZqLW9Rhex4y" 49 | }, 50 | "execution_count": null, 51 | "outputs": [] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "source": [ 56 | "# This response is in JSON \n", 57 | "response" 58 | ], 59 | "metadata": { 60 | "id": "xTPEYNihe02o" 61 | }, 62 | "execution_count": null, 63 | "outputs": [] 64 | }, 65 | { 66 | "cell_type": "code", 67 | "source": [ 68 | "# We can use the JSON library to parse this in to a dictionary\n", 69 | "import json \n", 70 | "y = json.loads(response)" 71 | ], 72 | "metadata": { 73 | "id": "zugv_VNnf5ap" 74 | }, 75 | "execution_count": null, 76 | "outputs": [] 77 | }, 78 | { 79 | "cell_type": "code", 80 | "source": [ 81 | "# We can confirm this is a dictionary with the type function \n", 82 | "type(y)" 83 | ], 84 | "metadata": { 85 | "id": "tykMQLhcgrMo" 86 | }, 87 | "execution_count": null, 88 | "outputs": [] 89 | }, 90 | { 91 | "cell_type": "code", 92 | "source": [ 93 | "# This is a large dictionary but follows a pattern - We are interested in Country level details\n", 94 | "y" 95 | ], 96 | "metadata": { 97 | "id": "3TW9R7_8syJN" 98 | }, 99 | "execution_count": null, 100 | "outputs": [] 101 | }, 102 | { 103 | "cell_type": "code", 104 | "source": [ 105 | "# We can count the number of countries by using the len function \n", 106 | "len(y['Countries'])" 107 | ], 108 | "metadata": { 109 | "id": "RK83MxoXhN3v" 110 | }, 111 | "execution_count": null, 112 | "outputs": [] 113 | }, 114 | { 115 | "cell_type": "code", 116 | "source": [ 117 | "\n", 118 | "# The first element with country has a country of Afghanistan\n", 119 | "y['Countries'][0]['Country']" 120 | ], 121 | "metadata": { 122 | "id": "VGnQcxaWh2zP" 123 | }, 124 | "execution_count": null, 125 | "outputs": [] 126 | }, 127 | { 128 | "cell_type": "code", 129 | "source": [ 130 | "# We can see how many deaths have taken place \n", 131 | "y['Countries'][0]['NewDeaths']" 132 | ], 133 | "metadata": { 134 | "id": "pgrL-KDzikqm" 135 | }, 136 | "execution_count": null, 137 | "outputs": [] 138 | }, 139 | { 140 | "cell_type": "code", 141 | "source": [ 142 | "# We can use f'strings to format a print statement containing elements\n", 143 | "f\"{y['Countries'][0]['Country']} has had {y['Countries'][0]['TotalDeaths']} total deaths from COVID 19\"" 144 | ], 145 | "metadata": { 146 | "id": "v7V8J_-_iy1H" 147 | }, 148 | "execution_count": null, 149 | "outputs": [] 150 | }, 151 | { 152 | "cell_type": "code", 153 | "source": [ 154 | "# We can do this a number of countries using range\n", 155 | "for i in range(10):\n", 156 | " print(f\"{y['Countries'][i]['Country']} has had {y['Countries'][i]['TotalDeaths']} total deaths from COVID 19\")" 157 | ], 158 | "metadata": { 159 | "id": "gzVnauQWjV1p" 160 | }, 161 | "execution_count": null, 162 | "outputs": [] 163 | }, 164 | { 165 | "cell_type": "code", 166 | "source": [ 167 | "# This data can all be added to a dataframe\n", 168 | "import pandas as pd\n", 169 | "df = pd.DataFrame(data=y['Countries'])" 170 | ], 171 | "metadata": { 172 | "id": "W-VI3OwHksmO" 173 | }, 174 | "execution_count": null, 175 | "outputs": [] 176 | }, 177 | { 178 | "cell_type": "code", 179 | "source": [ 180 | "df.head(10)" 181 | ], 182 | "metadata": { 183 | "id": "tH2u0D3llanW" 184 | }, 185 | "execution_count": null, 186 | "outputs": [] 187 | }, 188 | { 189 | "cell_type": "code", 190 | "source": [ 191 | "# From the dataframe we can get the index of the country with the maximum deaths and cases \n", 192 | "most_new_cases = df['NewConfirmed'].idxmax()\n", 193 | "most_new_deaths = df['NewDeaths'].idxmax()" 194 | ], 195 | "metadata": { 196 | "id": "YvdO0pfclbbH" 197 | }, 198 | "execution_count": null, 199 | "outputs": [] 200 | }, 201 | { 202 | "cell_type": "code", 203 | "source": [ 204 | "# We can display this automatically \n", 205 | "print(f\" Good Morning here is your daily covid report.\\n \n", 206 | "The most daily confirmed cases look place in {df['Country'].loc[most_new_cases]} \n", 207 | "with {df['NewConfirmed'].loc[most_new_cases]} new cases.\\n The most deaths occured \n", 208 | "in {df['Country'].loc[most_new_deaths]} with {df['NewDeaths'].loc[most_new_deaths]} new deaths.\")" 209 | ], 210 | "metadata": { 211 | "id": "qjar1BwlmFKV" 212 | }, 213 | "execution_count": null, 214 | "outputs": [] 215 | } 216 | ] 217 | } -------------------------------------------------------------------------------- /Sentiment_Analysis_OpenAI_API.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "provenance": [], 7 | "include_colab_link": true 8 | }, 9 | "kernelspec": { 10 | "name": "python3", 11 | "display_name": "Python 3" 12 | }, 13 | "language_info": { 14 | "name": "python" 15 | } 16 | }, 17 | "cells": [ 18 | { 19 | "cell_type": "markdown", 20 | "metadata": { 21 | "id": "view-in-github", 22 | "colab_type": "text" 23 | }, 24 | "source": [ 25 | "\"Open" 26 | ] 27 | }, 28 | { 29 | "cell_type": "code", 30 | "source": [ 31 | "!pip install openai" 32 | ], 33 | "metadata": { 34 | "id": "15uaY-Y8QBE9" 35 | }, 36 | "execution_count": null, 37 | "outputs": [] 38 | }, 39 | { 40 | "cell_type": "code", 41 | "execution_count": null, 42 | "metadata": { 43 | "id": "1YP6-sABwTEv" 44 | }, 45 | "outputs": [], 46 | "source": [ 47 | "# get the openai secret key\n", 48 | "import getpass\n", 49 | "import pandas as pd\n", 50 | "\n", 51 | "\n", 52 | "# https://platform.openai.com/account/api-keys\n", 53 | "secret_key = getpass.getpass('Please enter your openai key: ')" 54 | ] 55 | }, 56 | { 57 | "cell_type": "code", 58 | "source": [ 59 | "from openai import OpenAI\n", 60 | "client = OpenAI(api_key=secret_key)" 61 | ], 62 | "metadata": { 63 | "id": "Jl9pTctvATwa" 64 | }, 65 | "execution_count": null, 66 | "outputs": [] 67 | }, 68 | { 69 | "cell_type": "code", 70 | "source": [ 71 | "def get_response(example):\n", 72 | " response = client.chat.completions.create(\n", 73 | " model=\"gpt-3.5-turbo\",\n", 74 | " messages=[\n", 75 | " {\n", 76 | " \"role\": \"system\",\n", 77 | " \"content\": \"You are an expert in restaurant marketing with a specialism in sentiment analysis. \\n\\nI will give you some reviews and I want you to return one word based on the sentiment. Positive, Negative or Neutral. \"\n", 78 | " },\n", 79 | " {\n", 80 | " \"role\": \"user\",\n", 81 | " \"content\": \"With all the new upgrades everything looks great and clean great staff\"\n", 82 | " },\n", 83 | " {\n", 84 | " \"role\": \"assistant\",\n", 85 | " \"content\": \"Positive\"\n", 86 | " },\n", 87 | " {\n", 88 | " \"role\": \"user\",\n", 89 | " \"content\": \"It'd McDonalds. It is what it is as far as the food and atmosphere go. The staff here does make a difference. They are all friendly, accommodating and always smiling. Makes for a more pleasant experience than many other fast food places.\"\n", 90 | " },\n", 91 | " {\n", 92 | " \"role\": \"assistant\",\n", 93 | " \"content\": \"Positive\"\n", 94 | " },\n", 95 | " {\n", 96 | " \"role\": \"user\",\n", 97 | " \"content\": \"We stopped by for a quick breakfast. It was not crowded inside, but there was a pretty long drive thru.\\nOur order was supposed to have 3 food items and 2 drinks. They missed a food item. The lady ignored me when I told her.My husband went to get it, she finished her task then handed it to him without a word or smile or anything.\"\n", 98 | " },\n", 99 | " {\n", 100 | " \"role\": \"assistant\",\n", 101 | " \"content\": \"Negative\"\n", 102 | " },\n", 103 | " {\n", 104 | " \"role\": \"user\",\n", 105 | " \"content\": \"The morning crew seems fast and efficient. Night crew is a whole different experience, lines down the street, hour long waits. If this was a one time occurrence it wouldn't be so bad but this is a nightly problem. Beyond this the staff is so highly rude you leave wanting to crash your car through the building. Don't forget they will mistake your order almost every single time as well and serve it to you cold.\"\n", 106 | " },\n", 107 | " {\n", 108 | " \"role\": \"assistant\",\n", 109 | " \"content\": \"Negative\"\n", 110 | " },\n", 111 | " {\n", 112 | " \"role\": \"user\",\n", 113 | " \"content\": \"Me and my girlfriend came tonight to pick up our food after 11pm for a mobile order, they need a better system if you are walking on foot. The food tasted great, loved the McDonald's deal ordering from the app.\"\n", 114 | " },\n", 115 | " {\n", 116 | " \"role\": \"assistant\",\n", 117 | " \"content\": \"Neutral\"\n", 118 | " },\n", 119 | " {\n", 120 | " \"role\": \"user\",\n", 121 | " \"content\": \"Been frequenting this location for a few years.Morning,mid-day and night,the food is always hot,fresh and served with a smile.\"\n", 122 | " },\n", 123 | " {\n", 124 | " \"role\": \"assistant\",\n", 125 | " \"content\": \"Positive\"\n", 126 | " },\n", 127 | " {\n", 128 | " \"role\": \"user\",\n", 129 | " \"content\": f\"\"\"{example} \"\"\"\n", 130 | " }\n", 131 | " ],\n", 132 | " temperature=1,\n", 133 | " max_tokens=256,\n", 134 | " top_p=1,\n", 135 | " frequency_penalty=0,\n", 136 | " presence_penalty=0\n", 137 | " )\n", 138 | " return response.choices[0].message.content" 139 | ], 140 | "metadata": { 141 | "id": "ch8VwFL__sOo" 142 | }, 143 | "execution_count": null, 144 | "outputs": [] 145 | }, 146 | { 147 | "cell_type": "code", 148 | "source": [ 149 | "#Test\n", 150 | "get_response(\"\"\"I work for door dash and they locked us all out to wait in a long line for no reason at 10. I tried to beg them to open it because I'm door dash and they refused. Covid is over get a new job\"\"\")" 151 | ], 152 | "metadata": { 153 | "id": "ayvYHml5AHNs" 154 | }, 155 | "execution_count": null, 156 | "outputs": [] 157 | }, 158 | { 159 | "cell_type": "code", 160 | "source": [ 161 | "df = pd.read_csv('https://raw.githubusercontent.com/analyticswithadam/Python/main/Data/McD%20Reviews.csv')\n", 162 | "df['Review'] = df['Review'].str.strip()" 163 | ], 164 | "metadata": { 165 | "id": "mABizQeYBo3t" 166 | }, 167 | "execution_count": null, 168 | "outputs": [] 169 | }, 170 | { 171 | "cell_type": "code", 172 | "source": [ 173 | "df.head()" 174 | ], 175 | "metadata": { 176 | "id": "rjBo8-UBEtat" 177 | }, 178 | "execution_count": null, 179 | "outputs": [] 180 | }, 181 | { 182 | "cell_type": "code", 183 | "source": [ 184 | "df['Review']" 185 | ], 186 | "metadata": { 187 | "id": "YS4_iuUtFtWB" 188 | }, 189 | "execution_count": null, 190 | "outputs": [] 191 | }, 192 | { 193 | "cell_type": "code", 194 | "source": [ 195 | "df2 = df[100:120].copy()" 196 | ], 197 | "metadata": { 198 | "id": "I3WGC4xlLhDh" 199 | }, 200 | "execution_count": null, 201 | "outputs": [] 202 | }, 203 | { 204 | "cell_type": "code", 205 | "source": [ 206 | "df2" 207 | ], 208 | "metadata": { 209 | "id": "pSwoWvFPLmGY" 210 | }, 211 | "execution_count": null, 212 | "outputs": [] 213 | }, 214 | { 215 | "cell_type": "code", 216 | "source": [ 217 | "df2['GPT Sentiment'] = df2['Review'].apply(get_response)" 218 | ], 219 | "metadata": { 220 | "id": "h9dSMyydLsHw" 221 | }, 222 | "execution_count": null, 223 | "outputs": [] 224 | }, 225 | { 226 | "cell_type": "code", 227 | "source": [ 228 | "df2" 229 | ], 230 | "metadata": { 231 | "id": "2lSEwyH9Nskr" 232 | }, 233 | "execution_count": null, 234 | "outputs": [] 235 | } 236 | ] 237 | } -------------------------------------------------------------------------------- /Web_Scraping_from_TrustPilot_v3.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "provenance": [], 7 | "authorship_tag": "ABX9TyP6RHkoCJa/xj34im0tCo30", 8 | "include_colab_link": true 9 | }, 10 | "kernelspec": { 11 | "name": "python3", 12 | "display_name": "Python 3" 13 | }, 14 | "language_info": { 15 | "name": "python" 16 | } 17 | }, 18 | "cells": [ 19 | { 20 | "cell_type": "markdown", 21 | "metadata": { 22 | "id": "view-in-github", 23 | "colab_type": "text" 24 | }, 25 | "source": [ 26 | "\"Open" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 1, 32 | "metadata": { 33 | "id": "JP6PLQnwDvlC", 34 | "outputId": "6e20d237-d6f5-4474-88c3-6cf7c08f4132", 35 | "colab": { 36 | "base_uri": "https://localhost:8080/" 37 | } 38 | }, 39 | "outputs": [ 40 | { 41 | "output_type": "stream", 42 | "name": "stdout", 43 | "text": [ 44 | "Scraping: https://www.trustpilot.com/review/pepsi.com?page=1\n", 45 | "Scraping: https://www.trustpilot.com/review/pepsi.com?page=2\n", 46 | "Scraping: https://www.trustpilot.com/review/pepsi.com?page=3\n", 47 | "Scraping: https://www.trustpilot.com/review/pepsi.com?page=4\n", 48 | "Scraping: https://www.trustpilot.com/review/pepsi.com?page=5\n", 49 | "Scraping: https://www.trustpilot.com/review/pepsi.com?page=6\n", 50 | " Review Text Review Date Rating\n", 51 | "0 None A day ago None\n", 52 | "1 None 3 days ago None\n", 53 | "2 None Mar 13, 2025 None\n", 54 | "3 None Mar 12, 2025 None\n", 55 | "4 Would give 0 if i could, pepsi classic used to... A day ago 1\n", 56 | ".. ... ... ...\n", 57 | "139 Used to be my favourite drink but now that the... Sep 16, 2023 1\n", 58 | "140 I have enjoyed Pepsi cherry max for years and ... Sep 11, 2023 1\n", 59 | "141 So I noticed for the last half year that Pepsi... Sep 10, 2023 1\n", 60 | "142 I want to write this review which is almost id... Sep 9, 2023 1\n", 61 | "143 In the past, lots of people know Pepsi was my ... Sep 8, 2023 1\n", 62 | "\n", 63 | "[144 rows x 3 columns]\n" 64 | ] 65 | } 66 | ], 67 | "source": [ 68 | "import requests\n", 69 | "from bs4 import BeautifulSoup\n", 70 | "import pandas as pd\n", 71 | "from time import sleep\n", 72 | "\n", 73 | "def extract_reviews(page_url):\n", 74 | " headers = {\"User-Agent\": \"Mozilla/5.0\"} # Mimic a browser\n", 75 | " response = requests.get(page_url, headers=headers)\n", 76 | " soup = BeautifulSoup(response.content, 'html.parser')\n", 77 | "\n", 78 | " # Find all articles that represent individual reviews.\n", 79 | " review_articles = soup.find_all('article', attrs={\"data-service-review-card-paper\": True})\n", 80 | "\n", 81 | " reviews_data = []\n", 82 | " for article in review_articles:\n", 83 | " review_text = None\n", 84 | " review_date = None\n", 85 | " rating = None\n", 86 | "\n", 87 | " # Extract the full review text from the

tag with the review text attribute.\n", 88 | " text_tag = article.find('p', attrs={\"data-service-review-text-typography\": True})\n", 89 | " if text_tag:\n", 90 | " review_text = text_tag.get_text(strip=True)\n", 91 | "\n", 92 | " # Extract the review date from the first

\n", 177 | "\n", 190 | "\n", 191 | " \n", 192 | " \n", 193 | " \n", 194 | " \n", 195 | " \n", 196 | " \n", 197 | " \n", 198 | " \n", 199 | " \n", 200 | " \n", 201 | " \n", 202 | " \n", 203 | " \n", 204 | " \n", 205 | " \n", 206 | " \n", 207 | " \n", 208 | " \n", 209 | " \n", 210 | " \n", 211 | " \n", 212 | " \n", 213 | " \n", 214 | " \n", 215 | " \n", 216 | " \n", 217 | " \n", 218 | " \n", 219 | " \n", 220 | " \n", 221 | " \n", 222 | " \n", 223 | " \n", 224 | " \n", 225 | " \n", 226 | " \n", 227 | " \n", 228 | " \n", 229 | " \n", 230 | " \n", 231 | " \n", 232 | " \n", 233 | " \n", 234 | " \n", 235 | " \n", 236 | " \n", 237 | " \n", 238 | " \n", 239 | " \n", 240 | " \n", 241 | " \n", 242 | " \n", 243 | " \n", 244 | " \n", 245 | " \n", 246 | " \n", 247 | " \n", 248 | " \n", 249 | " \n", 250 | " \n", 251 | " \n", 252 | " \n", 253 | " \n", 254 | " \n", 255 | " \n", 256 | " \n", 257 | " \n", 258 | " \n", 259 | " \n", 260 | " \n", 261 | " \n", 262 | " \n", 263 | " \n", 264 | " \n", 265 | " \n", 266 | " \n", 267 | " \n", 268 | " \n", 269 | " \n", 270 | " \n", 271 | " \n", 272 | " \n", 273 | " \n", 274 | " \n", 275 | " \n", 276 | " \n", 277 | " \n", 278 | " \n", 279 | " \n", 280 | " \n", 281 | " \n", 282 | " \n", 283 | " \n", 284 | " \n", 285 | " \n", 286 | " \n", 287 | " \n", 288 | " \n", 289 | " \n", 290 | " \n", 291 | " \n", 292 | " \n", 293 | " \n", 294 | " \n", 295 | " \n", 296 | " \n", 297 | " \n", 298 | " \n", 299 | " \n", 300 | " \n", 301 | " \n", 302 | " \n", 303 | " \n", 304 | " \n", 305 | " \n", 306 | " \n", 307 | " \n", 308 | " \n", 309 | " \n", 310 | " \n", 311 | " \n", 312 | " \n", 313 | " \n", 314 | " \n", 315 | " \n", 316 | " \n", 317 | " \n", 318 | " \n", 319 | " \n", 320 | " \n", 321 | " \n", 322 | " \n", 323 | " \n", 324 | " \n", 325 | " \n", 326 | " \n", 327 | " \n", 328 | " \n", 329 | " \n", 330 | " \n", 331 | " \n", 332 | " \n", 333 | " \n", 334 | " \n", 335 | " \n", 336 | " \n", 337 | " \n", 338 | " \n", 339 | " \n", 340 | " \n", 341 | " \n", 342 | " \n", 343 | " \n", 344 | " \n", 345 | " \n", 346 | " \n", 347 | " \n", 348 | " \n", 349 | " \n", 350 | " \n", 351 | "
MakeModelYearPurchase PriceRepair CostSales PriceProfitStock DaysDate SoldSales Person
0KiaRio201914721.941060.1817126.531344.41362021-10-01Mary Black
0AudiA5201732775.522850.4037672.372046.45522021-09-28Mary Black
0HondaAccord202132807.23515.7332895.45-427.51702021-09-11Tony Long
0KiaRio202016605.561221.5619088.201261.08672021-09-27Mary Black
0AudiA6201739002.051926.7143745.142816.3822021-09-16Santa Barry
.................................
0BMW1 Series202029735.492321.1031944.39-112.20322021-09-13Tony Long
0SkodaScala201710152.50191.7210982.91638.69792021-09-07Santa Barry
0SkodaCitigo202114243.961156.9916940.981540.03662021-09-19Tony Long
0AudiA1201925101.422280.1626370.38-1011.20872021-09-21Jimmy The Fly
0SkodaOctavia201822689.811683.9423565.83-807.92532021-09-27Jimmy The Fly
\n", 352 | "

250 rows × 10 columns

\n", 353 | "
" 354 | ], 355 | "text/plain": [ 356 | " Make Model Year ... Stock Days Date Sold Sales Person\n", 357 | "0 Kia Rio 2019 ... 36 2021-10-01 Mary Black\n", 358 | "0 Audi A5 2017 ... 52 2021-09-28 Mary Black\n", 359 | "0 Honda Accord 2021 ... 70 2021-09-11 Tony Long\n", 360 | "0 Kia Rio 2020 ... 67 2021-09-27 Mary Black\n", 361 | "0 Audi A6 2017 ... 2 2021-09-16 Santa Barry\n", 362 | ".. ... ... ... ... ... ... ...\n", 363 | "0 BMW 1 Series 2020 ... 32 2021-09-13 Tony Long\n", 364 | "0 Skoda Scala 2017 ... 79 2021-09-07 Santa Barry\n", 365 | "0 Skoda Citigo 2021 ... 66 2021-09-19 Tony Long\n", 366 | "0 Audi A1 2019 ... 87 2021-09-21 Jimmy The Fly\n", 367 | "0 Skoda Octavia 2018 ... 53 2021-09-27 Jimmy The Fly\n", 368 | "\n", 369 | "[250 rows x 10 columns]" 370 | ] 371 | }, 372 | "metadata": { 373 | "tags": [] 374 | }, 375 | "execution_count": 5 376 | } 377 | ] 378 | } 379 | ] 380 | } -------------------------------------------------------------------------------- /Lambda.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "Lambda.ipynb", 7 | "provenance": [], 8 | "include_colab_link": true 9 | }, 10 | "kernelspec": { 11 | "name": "python3", 12 | "display_name": "Python 3" 13 | }, 14 | "language_info": { 15 | "name": "python" 16 | } 17 | }, 18 | "cells": [ 19 | { 20 | "cell_type": "markdown", 21 | "metadata": { 22 | "id": "view-in-github", 23 | "colab_type": "text" 24 | }, 25 | "source": [ 26 | "\"Open" 27 | ] 28 | }, 29 | { 30 | "cell_type": "markdown", 31 | "metadata": { 32 | "id": "8ym3nBQ8TeFG" 33 | }, 34 | "source": [ 35 | "Lambda Expression V Regular Functions" 36 | ] 37 | }, 38 | { 39 | "cell_type": "code", 40 | "metadata": { 41 | "id": "66nLT6T1fdj6", 42 | "outputId": "37667e86-abc1-4c37-a906-57eb6f09f98a", 43 | "colab": { 44 | "base_uri": "https://localhost:8080/" 45 | } 46 | }, 47 | "source": [ 48 | "# Creating a function \n", 49 | "def squared(num):\n", 50 | " return num ** 2\n", 51 | "print(squared(4))\n", 52 | "\n", 53 | "# using a lambda expression\n", 54 | "(lambda x: x**2)(4)" 55 | ], 56 | "execution_count": 1, 57 | "outputs": [ 58 | { 59 | "output_type": "stream", 60 | "name": "stdout", 61 | "text": [ 62 | "16\n" 63 | ] 64 | }, 65 | { 66 | "output_type": "execute_result", 67 | "data": { 68 | "text/plain": [ 69 | "16" 70 | ] 71 | }, 72 | "metadata": {}, 73 | "execution_count": 1 74 | } 75 | ] 76 | }, 77 | { 78 | "cell_type": "markdown", 79 | "metadata": { 80 | "id": "Sh1zOHnMlG3D" 81 | }, 82 | "source": [ 83 | "Lambda Expression if If Statement" 84 | ] 85 | }, 86 | { 87 | "cell_type": "code", 88 | "metadata": { 89 | "id": "m5hfi561lMg4", 90 | "outputId": "08701972-f0ec-4a9d-8297-7103e3c5dfdd", 91 | "colab": { 92 | "base_uri": "https://localhost:8080/", 93 | "height": 53 94 | } 95 | }, 96 | "source": [ 97 | "num = 5\n", 98 | "\n", 99 | "if(num > 4):\n", 100 | " print('Greater') \n", 101 | "else: \n", 102 | " print('Less')\n", 103 | "\n", 104 | "(lambda x: 'Greater' if x > 4 else 'Less')(num)\n" 105 | ], 106 | "execution_count": 2, 107 | "outputs": [ 108 | { 109 | "output_type": "stream", 110 | "name": "stdout", 111 | "text": [ 112 | "Greater\n" 113 | ] 114 | }, 115 | { 116 | "output_type": "execute_result", 117 | "data": { 118 | "text/plain": [ 119 | "'Greater'" 120 | ], 121 | "application/vnd.google.colaboratory.intrinsic+json": { 122 | "type": "string" 123 | } 124 | }, 125 | "metadata": {}, 126 | "execution_count": 2 127 | } 128 | ] 129 | }, 130 | { 131 | "cell_type": "markdown", 132 | "metadata": { 133 | "id": "Eg9iUYYZTgKT" 134 | }, 135 | "source": [ 136 | "Lambda Expression in Dataframes with Apply" 137 | ] 138 | }, 139 | { 140 | "cell_type": "code", 141 | "metadata": { 142 | "id": "N217pIwxTf4k", 143 | "outputId": "1317f05f-3f70-4f3a-9972-9c9d03054e3b", 144 | "colab": { 145 | "base_uri": "https://localhost:8080/" 146 | } 147 | }, 148 | "source": [ 149 | "import pandas as pd\n", 150 | "\n", 151 | "df=pd.DataFrame({\n", 152 | " 'id':[1,2,3,4,5],\n", 153 | " 'name':['Paul','Tim','Mary','Tony','Sam'],\n", 154 | " 'age':[31,45,90,20,35],\n", 155 | " 'income':[50000,70000,25000,5000,100000],\n", 156 | " 'married':[True, False, True, False, True]\n", 157 | "})\n", 158 | "\n", 159 | "print(df.head())\n", 160 | "df['lamdba cat'] = df['income'].apply(lambda x: 'high income' if x > 30000 else ('medium income' if x > 7500 else 'low income'))\n", 161 | "\n", 162 | "print(df.head())\n" 163 | ], 164 | "execution_count": 3, 165 | "outputs": [ 166 | { 167 | "output_type": "stream", 168 | "name": "stdout", 169 | "text": [ 170 | " id name age income married\n", 171 | "0 1 Paul 31 50000 True\n", 172 | "1 2 Tim 45 70000 False\n", 173 | "2 3 Mary 90 25000 True\n", 174 | "3 4 Tony 20 5000 False\n", 175 | "4 5 Sam 35 100000 True\n", 176 | " id name age income married lamdba cat\n", 177 | "0 1 Paul 31 50000 True high income\n", 178 | "1 2 Tim 45 70000 False high income\n", 179 | "2 3 Mary 90 25000 True medium income\n", 180 | "3 4 Tony 20 5000 False low income\n", 181 | "4 5 Sam 35 100000 True high income\n" 182 | ] 183 | } 184 | ] 185 | }, 186 | { 187 | "cell_type": "markdown", 188 | "metadata": { 189 | "id": "trHST7vVThVV" 190 | }, 191 | "source": [ 192 | "Advanced Filtering " 193 | ] 194 | }, 195 | { 196 | "cell_type": "code", 197 | "metadata": { 198 | "id": "q-F0KmiGptM8", 199 | "outputId": "92971b33-5ad3-47ec-a6cb-527e11018254", 200 | "colab": { 201 | "base_uri": "https://localhost:8080/", 202 | "height": 143 203 | } 204 | }, 205 | "source": [ 206 | "df[(df['age'] > 20) & (df['income'] * 3.5 > 100000)]" 207 | ], 208 | "execution_count": 4, 209 | "outputs": [ 210 | { 211 | "output_type": "execute_result", 212 | "data": { 213 | "text/plain": [ 214 | " id name age income married lamdba cat\n", 215 | "0 1 Paul 31 50000 True high income\n", 216 | "1 2 Tim 45 70000 False high income\n", 217 | "4 5 Sam 35 100000 True high income" 218 | ], 219 | "text/html": [ 220 | "\n", 221 | "
\n", 222 | "
\n", 223 | "
\n", 224 | "\n", 237 | "\n", 238 | " \n", 239 | " \n", 240 | " \n", 241 | " \n", 242 | " \n", 243 | " \n", 244 | " \n", 245 | " \n", 246 | " \n", 247 | " \n", 248 | " \n", 249 | " \n", 250 | " \n", 251 | " \n", 252 | " \n", 253 | " \n", 254 | " \n", 255 | " \n", 256 | " \n", 257 | " \n", 258 | " \n", 259 | " \n", 260 | " \n", 261 | " \n", 262 | " \n", 263 | " \n", 264 | " \n", 265 | " \n", 266 | " \n", 267 | " \n", 268 | " \n", 269 | " \n", 270 | " \n", 271 | " \n", 272 | " \n", 273 | " \n", 274 | " \n", 275 | " \n", 276 | " \n", 277 | " \n", 278 | "
idnameageincomemarriedlamdba cat
01Paul3150000Truehigh income
12Tim4570000Falsehigh income
45Sam35100000Truehigh income
\n", 279 | "
\n", 280 | " \n", 290 | " \n", 291 | " \n", 328 | "\n", 329 | " \n", 353 | "
\n", 354 | "
\n", 355 | " " 356 | ] 357 | }, 358 | "metadata": {}, 359 | "execution_count": 4 360 | } 361 | ] 362 | }, 363 | { 364 | "cell_type": "code", 365 | "metadata": { 366 | "id": "p1rqtCVcptCR", 367 | "outputId": "8c075c3f-2194-4703-c2a4-8b64859a048a", 368 | "colab": { 369 | "base_uri": "https://localhost:8080/", 370 | "height": 143 371 | } 372 | }, 373 | "source": [ 374 | "df[df['name'].apply(len) > 3]" 375 | ], 376 | "execution_count": 31, 377 | "outputs": [ 378 | { 379 | "output_type": "execute_result", 380 | "data": { 381 | "text/plain": [ 382 | " id name age income married lamdba cat\n", 383 | "0 1 Paul 31 50000 True high income\n", 384 | "2 3 Mary 90 25000 True medium income\n", 385 | "3 4 Tony 20 5000 False low income" 386 | ], 387 | "text/html": [ 388 | "\n", 389 | "
\n", 390 | "
\n", 391 | "
\n", 392 | "\n", 405 | "\n", 406 | " \n", 407 | " \n", 408 | " \n", 409 | " \n", 410 | " \n", 411 | " \n", 412 | " \n", 413 | " \n", 414 | " \n", 415 | " \n", 416 | " \n", 417 | " \n", 418 | " \n", 419 | " \n", 420 | " \n", 421 | " \n", 422 | " \n", 423 | " \n", 424 | " \n", 425 | " \n", 426 | " \n", 427 | " \n", 428 | " \n", 429 | " \n", 430 | " \n", 431 | " \n", 432 | " \n", 433 | " \n", 434 | " \n", 435 | " \n", 436 | " \n", 437 | " \n", 438 | " \n", 439 | " \n", 440 | " \n", 441 | " \n", 442 | " \n", 443 | " \n", 444 | " \n", 445 | " \n", 446 | "
idnameageincomemarriedlamdba cat
01Paul3150000Truehigh income
23Mary9025000Truemedium income
34Tony205000Falselow income
\n", 447 | "
\n", 448 | " \n", 458 | " \n", 459 | " \n", 496 | "\n", 497 | " \n", 521 | "
\n", 522 | "
\n", 523 | " " 524 | ] 525 | }, 526 | "metadata": {}, 527 | "execution_count": 31 528 | } 529 | ] 530 | }, 531 | { 532 | "cell_type": "code", 533 | "metadata": { 534 | "id": "D-aveCQQTh8r" 535 | }, 536 | "source": [ 537 | "df[df.apply(lambda x : (x['age'] > 20) & (x['income'] * 3.5 > 100000) & (len(x['name']) <= 3),axis=1) & (df[\"age\"] < df[\"age\"].mean())]\n" 538 | ], 539 | "execution_count": null, 540 | "outputs": [] 541 | }, 542 | { 543 | "cell_type": "markdown", 544 | "metadata": { 545 | "id": "lN33xSFzk3FL" 546 | }, 547 | "source": [ 548 | "Change Case" 549 | ] 550 | }, 551 | { 552 | "cell_type": "code", 553 | "metadata": { 554 | "id": "RmOsxX3Xqv_P" 555 | }, 556 | "source": [ 557 | "df['name'].apply(lambda x: x.upper())" 558 | ], 559 | "execution_count": null, 560 | "outputs": [] 561 | }, 562 | { 563 | "cell_type": "code", 564 | "metadata": { 565 | "id": "zRKQtyTqkwB8" 566 | }, 567 | "source": [ 568 | "df['name'].apply(lambda x: x.lower())" 569 | ], 570 | "execution_count": null, 571 | "outputs": [] 572 | } 573 | ] 574 | } -------------------------------------------------------------------------------- /YouTubeComments.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "provenance": [], 7 | "authorship_tag": "ABX9TyP18S5koz98EuxKR0Vr96Kb", 8 | "include_colab_link": true 9 | }, 10 | "kernelspec": { 11 | "name": "python3", 12 | "display_name": "Python 3" 13 | }, 14 | "language_info": { 15 | "name": "python" 16 | } 17 | }, 18 | "cells": [ 19 | { 20 | "cell_type": "markdown", 21 | "metadata": { 22 | "id": "view-in-github", 23 | "colab_type": "text" 24 | }, 25 | "source": [ 26 | "\"Open" 27 | ] 28 | }, 29 | { 30 | "cell_type": "markdown", 31 | "source": [ 32 | "## Pull Comments" 33 | ], 34 | "metadata": { 35 | "id": "ExqBG7nOSzQZ" 36 | } 37 | }, 38 | { 39 | "cell_type": "code", 40 | "execution_count": 14, 41 | "metadata": { 42 | "colab": { 43 | "base_uri": "https://localhost:8080/" 44 | }, 45 | "id": "LtsUFbQJOv-5", 46 | "outputId": "4ec8d1cb-e23f-462c-a4dc-9ca194e45ae7" 47 | }, 48 | "outputs": [ 49 | { 50 | "output_type": "stream", 51 | "name": "stdout", 52 | "text": [ 53 | "ممنونم از به اشتراك گذاشتن اطلاعاتتون\n", 54 | "Hi Leila you are awesome ❤and I have a problem with this , I'm not able to find data type although I check data menu and my office is 2021\n", 55 | "hey Leila~,
Not sure how I got unSub~d,
sure glad I had U in my e-mail\n", 56 | "How do you make tutorials on features we don't yet have?\n", 57 | "An amazing insight; I'm not sure if i will be using this feature, but you've done a great job. I have noticed you have switched your laptop from Surface to hp.\n", 58 | "Those salaries!\n", 59 | "Thank you for this video. I have traveling and this was one of the first things I looked at. I always enjoy and learn something from your videos. I can't wait until it rolls out to me.\n", 60 | "I truly like all these ideas and suggestions from Leila, but I constantly run into issues when applying them in to a large corporate environment. Linking data via SharePoint gives enough trouble. But pivoting tables and images across multiple data sources and servers (SharePoint, which which are accessibly to everyone within the target audience) always gives an error message like: "This is not possible". Makes me feel like being back in 1998, which is also worth something.\n", 61 | "Hi. Im hoping if you can help pls. Having issues with conditional format

A1 = NOW(). example result 11:00
B1 = 7:00. On time format
Conditiinal format formula is highlight if a1 > b1.

May i ask why its not highlighting when the statement is true?\n", 62 | "Hi Leila, that's amazing, I have an issue: the Geography was not copied on pivot table. How can I fix it?\n", 63 | "This can be a life saver!👏🏼👏🏼👏🏼 My colleague just requested sth similar…will try when back in the office!🎊🎊🎊\n", 64 | "ok thanks so much on this explanation , as usual amazing work , and if i want to implement it on dashboard how can i proceed it\n", 65 | "Does this work on pivot chart as well?\n", 66 | "@LeilaGharani I hope you can really help me.
I have a csv file on excel and I have half-yearly data.
I want to have only yearly data so would you say I should cancel all the first half of the year data and keep the last one, or should I do like a merging of the two semesters?\n", 67 | "This is amazing!!!\n", 68 | "Brilliant!! I wish MS would hurry up and add these features to my 365!!\n", 69 | "i have a problem madam will u solve it? If C4=Holiday then merge cells C4:C10\n", 70 | "Good job.\n", 71 | "Let me know what I think???? Well, my jaw has dropped on the floor with rest of my brain to start with! Sorry I need to replay this again!!! Tell ya all later!! Ow! Yeah You’re magical!!! Unbelievable!!!!!❤\n", 72 | "if you please Leila share workbook of episode\n", 73 | "Excellent. Thanks for keeping us updated with the new features.\n", 74 | "Hey Leila just wanted to check if we have any similar kind of arrayformula function of Google sheets in excel as that gives us an option to enter formula in one cell which populates values in multiple rows and columns..\n", 75 | "Cool\n", 76 | "can ChatGPT do this???\n", 77 | "Thanks Leila :)\n", 78 | "Thank god this feature is finally coming to excel.\n", 79 | "Thank you sincerely\n", 80 | "I have an excel file that I use for work, specifically car parks. The data I use are the following, license plate number, time of entry, time of exit, duration of stay, and based on these the price is calculated.
Sometimes I mistakenly click on the classification, as a result of which the numbers get confused, i.e. they get mixed up. If I don't understand it right away to reverse it with undo, what options do I have?\n", 81 | "Very nice video 📹 with bramd new informstion\n", 82 | "i like power query but i feel the more data you have the quicker it would be to do it with formulas and creating everything yourself. especially with data sets that continually increase such as if you're tracking multiple KPI's for each month and adding all the data to an annual folder. I don't know if that can be helped though.\n", 83 | "I lav ya\n", 84 | "your example is so cluttered and keeps me from wanting to implement this.\n", 85 | "Thank you very much, I m going to use it immediately. Great tutorial.\n", 86 | "Great additions to Excel\n", 87 | "Hi Leila, Is there a way to export or Link these table with custom formatting and images to PowerPoint? I Know it can be done as Image or entire workbook can be embedded but both are not desirable.\n", 88 | "Wow, awesome Leila. You have left some great ideas that can be turned into others that will give the business potential and a better form of control, in order to increase the efficiency of all its collaborators. Just great.
Thank you very much, Leila, for sharing such valuable information.\n", 89 | "Thanks teacher👌👍👍 ❤❤\n", 90 | "Ma'am what is advance excel is any course is available at your website.
Please let me know ma'am.
Thank you.\n", 91 | "Excel seems so easy when you teach it step by step\n", 92 | "Brilliant!!\n", 93 | "This is amazing. Could you please help me out when I drag the flag into pivot table rows section. I am not getting the flag instead of that I am getting text like Image of India, Image of United States etc..\n", 94 | "Absolutely cool stuff\n", 95 | "Looks like fun\n", 96 | "Interesting names...\n", 97 | "这功能很实用\n", 98 | "In excel 365 can we have ease of updating in web browser like we love on Google sheets.\n", 99 | "Leila ji plz make more videos on google sheet features.\n", 100 | "Magic\n", 101 | "I always use dynamic tables and it works fine, and I never need (pivot T), is that ok? I mean, dynamic tables do almost everything\n", 102 | "Walter White bought your courses for data analysis!!!\n", 103 | "But only available for 365\n", 104 | "So cool, thanks Leila. Can't wait to get this feature!\n", 105 | "That's amazing Leila! Really can't wait to have this soon, and as usual you did what you EXCEL at; your way of explaining in the most simple yet effective manner! No wonder, you won an award at Global Excel Summit for all your great work! Keep growing!🙂\n", 106 | "Wow, this is so cool. It feels like big lifeline to Pivot Tables.\n", 107 | "Ok, a little longer and we'll have power bi in Excel :)\n", 108 | "Excellent video Leila

I will add lot of value with custom DATA TYPES 😀 🎉\n", 109 | "Very nice video, but a super tip at the end, thanks alot teacher\n", 110 | "Very much a welcome addition, this!

With regards to data types, I just remembered they removed Wolfram Data Types on 11 June 2023.\n", 111 | "Holy shit, I was just thinking about this yesterday!\n", 112 | "Well updated.......\n", 113 | "My only comment would be...
https://youtu.be/WNrB1Q9Rry0?t=497\n", 114 | "Love it! \n", 115 | "I don't fly in a jet stream where I need country flags ... but Client logo's might be a clever idea ... rather than displaying a lengthy client name repeatedly.

Which is precisely why "Thursdays With Leila' is always a 'must watch' for me ... ideas ... ideas ... ideas!!! ... 🤔 ... 💡💡💡💡

😍😍😍😍 ... thank you ... thank you ... thank you ...\n", 116 | "Thanks ma,am,\n", 117 | "Leila, is AI taking our jobs away...?\n", 118 | "Excellent, I’ve been missing your content for the longest in my algorithms but glad to see this recent video, Leila. 😊

Edit: I’d just be careful on the last section. Probably should’ve blurred out your employees’ PII data or used dummy data for this bit.\n", 119 | "Thank you Leila 🎉\n", 120 | "Nice job, mam. But please give me the files\n", 121 | "How to enable beta version?\n", 122 | "🤗\n" 123 | ] 124 | } 125 | ], 126 | "source": [ 127 | "import googleapiclient.discovery\n", 128 | "import googleapiclient.errors\n", 129 | "\n", 130 | "api_service_name = \"youtube\"\n", 131 | "api_version = \"v3\"\n", 132 | "DEVELOPER_KEY = \"\"\n", 133 | "\n", 134 | "youtube = googleapiclient.discovery.build(\n", 135 | " api_service_name, api_version, developerKey=DEVELOPER_KEY)\n", 136 | "\n", 137 | "request = youtube.commentThreads().list(\n", 138 | " part=\"snippet\",\n", 139 | " videoId=\"WNrB1Q9Rry0\",\n", 140 | " maxResults=100\n", 141 | ")\n", 142 | "response = request.execute()\n", 143 | "\n", 144 | "for item in response['items']:\n", 145 | " print(item['snippet']['topLevelComment']['snippet']['textDisplay'])\n" 146 | ] 147 | }, 148 | { 149 | "cell_type": "markdown", 150 | "source": [ 151 | "## Output as Pandas DataFrame" 152 | ], 153 | "metadata": { 154 | "id": "_6cNc7iWSfBS" 155 | } 156 | }, 157 | { 158 | "cell_type": "code", 159 | "source": [ 160 | "import googleapiclient.discovery\n", 161 | "import pandas as pd\n", 162 | "\n", 163 | "api_service_name = \"youtube\"\n", 164 | "api_version = \"v3\"\n", 165 | "DEVELOPER_KEY = \"\"\n", 166 | "\n", 167 | "youtube = googleapiclient.discovery.build(\n", 168 | " api_service_name, api_version, developerKey=DEVELOPER_KEY)\n", 169 | "\n", 170 | "request = youtube.commentThreads().list(\n", 171 | " part=\"snippet\",\n", 172 | " videoId=\"WNrB1Q9Rry0\",\n", 173 | " maxResults=100\n", 174 | ")\n", 175 | "response = request.execute()\n", 176 | "\n", 177 | "comments = []\n", 178 | "\n", 179 | "for item in response['items']:\n", 180 | " comment = item['snippet']['topLevelComment']['snippet']\n", 181 | " comments.append([\n", 182 | " comment['authorDisplayName'],\n", 183 | " comment['publishedAt'],\n", 184 | " comment['updatedAt'],\n", 185 | " comment['likeCount'],\n", 186 | " comment['textDisplay']\n", 187 | " ])\n", 188 | "\n", 189 | "df = pd.DataFrame(comments, columns=['author', 'published_at', 'updated_at', 'like_count', 'text'])\n", 190 | "\n", 191 | "df.head(10)\n" 192 | ], 193 | "metadata": { 194 | "colab": { 195 | "base_uri": "https://localhost:8080/", 196 | "height": 363 197 | }, 198 | "id": "lCdRNwqRRmbN", 199 | "outputId": "93017fc5-51bf-477f-fb9f-9895871dcdb6" 200 | }, 201 | "execution_count": 16, 202 | "outputs": [ 203 | { 204 | "output_type": "execute_result", 205 | "data": { 206 | "text/plain": [ 207 | " author published_at updated_at like_count \\\n", 208 | "0 Hadi Asghari 2023-07-10T02:44:43Z 2023-07-10T02:44:43Z 0 \n", 209 | "1 omid shirazi 2023-07-09T23:13:36Z 2023-07-09T23:13:36Z 0 \n", 210 | "2 Yachid _ 2023-07-09T16:56:39Z 2023-07-09T16:56:39Z 1 \n", 211 | "3 Enoch Arthur 2023-07-09T11:18:36Z 2023-07-09T11:18:36Z 0 \n", 212 | "4 Farhan Merchant 2023-07-09T10:13:32Z 2023-07-09T10:13:32Z 0 \n", 213 | "5 Jake Smith 2023-07-09T01:24:36Z 2023-07-09T01:24:36Z 0 \n", 214 | "6 Gary S 2023-07-08T19:56:56Z 2023-07-08T19:56:56Z 0 \n", 215 | "7 Moker_020 2023-07-08T19:31:12Z 2023-07-08T19:31:12Z 0 \n", 216 | "8 mrjaydp123 2023-07-08T19:20:31Z 2023-07-08T19:20:31Z 0 \n", 217 | "9 karim Tahernejad 2023-07-08T15:15:14Z 2023-07-08T15:15:14Z 1 \n", 218 | "\n", 219 | " text \n", 220 | "0 ممنونم از به اشتراك گذاشتن اطلاعاتتون \n", 221 | "1 Hi Leila you are awesome ❤and I have a problem... \n", 222 | "2 hey Leila~,
Not sure how I got unSub~d, \n", 234 | "
\n", 235 | "
\n", 236 | "\n", 249 | "\n", 250 | " \n", 251 | " \n", 252 | " \n", 253 | " \n", 254 | " \n", 255 | " \n", 256 | " \n", 257 | " \n", 258 | " \n", 259 | " \n", 260 | " \n", 261 | " \n", 262 | " \n", 263 | " \n", 264 | " \n", 265 | " \n", 266 | " \n", 267 | " \n", 268 | " \n", 269 | " \n", 270 | " \n", 271 | " \n", 272 | " \n", 273 | " \n", 274 | " \n", 275 | " \n", 276 | " \n", 277 | " \n", 278 | " \n", 279 | " \n", 280 | " \n", 281 | " \n", 282 | " \n", 283 | " \n", 284 | " \n", 285 | " \n", 286 | " \n", 287 | " \n", 288 | " \n", 289 | " \n", 290 | " \n", 291 | " \n", 292 | " \n", 293 | " \n", 294 | " \n", 295 | " \n", 296 | " \n", 297 | " \n", 298 | " \n", 299 | " \n", 300 | " \n", 301 | " \n", 302 | " \n", 303 | " \n", 304 | " \n", 305 | " \n", 306 | " \n", 307 | " \n", 308 | " \n", 309 | " \n", 310 | " \n", 311 | " \n", 312 | " \n", 313 | " \n", 314 | " \n", 315 | " \n", 316 | " \n", 317 | " \n", 318 | " \n", 319 | " \n", 320 | " \n", 321 | " \n", 322 | " \n", 323 | " \n", 324 | " \n", 325 | " \n", 326 | " \n", 327 | " \n", 328 | " \n", 329 | " \n", 330 | " \n", 331 | " \n", 332 | " \n", 333 | " \n", 334 | " \n", 335 | " \n", 336 | " \n", 337 | " \n", 338 | " \n", 339 | " \n", 340 | " \n", 341 | " \n", 342 | "
authorpublished_atupdated_atlike_counttext
0Hadi Asghari2023-07-10T02:44:43Z2023-07-10T02:44:43Z0ممنونم از به اشتراك گذاشتن اطلاعاتتون
1omid shirazi2023-07-09T23:13:36Z2023-07-09T23:13:36Z0Hi Leila you are awesome ❤and I have a problem...
2Yachid _2023-07-09T16:56:39Z2023-07-09T16:56:39Z1hey Leila~,<br>Not sure how I got unSub~d, <br...
3Enoch Arthur2023-07-09T11:18:36Z2023-07-09T11:18:36Z0How do you make tutorials on features we don&#...
4Farhan Merchant2023-07-09T10:13:32Z2023-07-09T10:13:32Z0An amazing insight; I&#39;m not sure if i will...
5Jake Smith2023-07-09T01:24:36Z2023-07-09T01:24:36Z0Those salaries!
6Gary S2023-07-08T19:56:56Z2023-07-08T19:56:56Z0Thank you for this video. I have traveling an...
7Moker_0202023-07-08T19:31:12Z2023-07-08T19:31:12Z0I truly like all these ideas and suggestions f...
8mrjaydp1232023-07-08T19:20:31Z2023-07-08T19:20:31Z0Hi. Im hoping if you can help pls. Having issu...
9karim Tahernejad2023-07-08T15:15:14Z2023-07-08T15:15:14Z1Hi Leila, that&#39;s amazing, I have an issue:...
\n", 343 | "
\n", 344 | " \n", 354 | " \n", 355 | " \n", 392 | "\n", 393 | " \n", 417 | "
\n", 418 | " \n", 419 | " " 420 | ] 421 | }, 422 | "metadata": {}, 423 | "execution_count": 16 424 | } 425 | ] 426 | }, 427 | { 428 | "cell_type": "code", 429 | "source": [ 430 | "df.head()" 431 | ], 432 | "metadata": { 433 | "id": "0LV_QAezR0nc" 434 | }, 435 | "execution_count": null, 436 | "outputs": [] 437 | } 438 | ] 439 | } -------------------------------------------------------------------------------- /Apex_Connect.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "Apex_Connect.ipynb", 7 | "provenance": [], 8 | "authorship_tag": "ABX9TyMMyXHwzDIKtM/V90RqOOPo", 9 | "include_colab_link": true 10 | }, 11 | "kernelspec": { 12 | "name": "python3", 13 | "display_name": "Python 3" 14 | }, 15 | "language_info": { 16 | "name": "python" 17 | } 18 | }, 19 | "cells": [ 20 | { 21 | "cell_type": "markdown", 22 | "metadata": { 23 | "id": "view-in-github", 24 | "colab_type": "text" 25 | }, 26 | "source": [ 27 | "\"Open" 28 | ] 29 | }, 30 | { 31 | "cell_type": "markdown", 32 | "metadata": { 33 | "id": "SQtcB2XRxVAz" 34 | }, 35 | "source": [ 36 | "## Imports" 37 | ] 38 | }, 39 | { 40 | "cell_type": "code", 41 | "metadata": { 42 | "id": "9xe3X80_t6Kg" 43 | }, 44 | "source": [ 45 | "import pandas as pd\n", 46 | "import requests\n", 47 | "import matplotlib.pyplot as plt\n", 48 | "%matplotlib inline" 49 | ], 50 | "execution_count": 1, 51 | "outputs": [] 52 | }, 53 | { 54 | "cell_type": "markdown", 55 | "metadata": { 56 | "id": "Fv01ucEKxa1V" 57 | }, 58 | "source": [ 59 | "## Request Data" 60 | ] 61 | }, 62 | { 63 | "cell_type": "code", 64 | "metadata": { 65 | "id": "5aifR2qzxeRQ" 66 | }, 67 | "source": [ 68 | "url = 'https://apex.oracle.com/pls/apex/superdataworld/book_view/'\n", 69 | "r = requests.get(url)\n", 70 | "json = r.json()\n", 71 | "df = pd.DataFrame(json['items'])" 72 | ], 73 | "execution_count": 10, 74 | "outputs": [] 75 | }, 76 | { 77 | "cell_type": "code", 78 | "metadata": { 79 | "colab": { 80 | "base_uri": "https://localhost:8080/", 81 | "height": 362 82 | }, 83 | "id": "gSuViNJUz52i", 84 | "outputId": "6de524cb-a4f1-4c1e-9488-bc6ba8c8a2ba" 85 | }, 86 | "source": [ 87 | "df.info()\n", 88 | "df.head()" 89 | ], 90 | "execution_count": 11, 91 | "outputs": [ 92 | { 93 | "output_type": "stream", 94 | "text": [ 95 | "\n", 96 | "RangeIndex: 25 entries, 0 to 24\n", 97 | "Data columns (total 2 columns):\n", 98 | " # Column Non-Null Count Dtype \n", 99 | "--- ------ -------------- ----- \n", 100 | " 0 entity 25 non-null object\n", 101 | " 1 year 25 non-null int64 \n", 102 | "dtypes: int64(1), object(1)\n", 103 | "memory usage: 528.0+ bytes\n" 104 | ], 105 | "name": "stdout" 106 | }, 107 | { 108 | "output_type": "execute_result", 109 | "data": { 110 | "text/html": [ 111 | "
\n", 112 | "\n", 125 | "\n", 126 | " \n", 127 | " \n", 128 | " \n", 129 | " \n", 130 | " \n", 131 | " \n", 132 | " \n", 133 | " \n", 134 | " \n", 135 | " \n", 136 | " \n", 137 | " \n", 138 | " \n", 139 | " \n", 140 | " \n", 141 | " \n", 142 | " \n", 143 | " \n", 144 | " \n", 145 | " \n", 146 | " \n", 147 | " \n", 148 | " \n", 149 | " \n", 150 | " \n", 151 | " \n", 152 | " \n", 153 | " \n", 154 | " \n", 155 | " \n", 156 | " \n", 157 | " \n", 158 | " \n", 159 | " \n", 160 | "
entityyear
0Australia1942
1Australia1943
2Australia1944
3Australia1945
4Australia1946
\n", 161 | "
" 162 | ], 163 | "text/plain": [ 164 | " entity year\n", 165 | "0 Australia 1942\n", 166 | "1 Australia 1943\n", 167 | "2 Australia 1944\n", 168 | "3 Australia 1945\n", 169 | "4 Australia 1946" 170 | ] 171 | }, 172 | "metadata": {}, 173 | "execution_count": 11 174 | } 175 | ] 176 | }, 177 | { 178 | "cell_type": "markdown", 179 | "metadata": { 180 | "id": "vtH41Xa38VUD" 181 | }, 182 | "source": [ 183 | "## Refine Data and Graph" 184 | ] 185 | }, 186 | { 187 | "cell_type": "code", 188 | "metadata": { 189 | "colab": { 190 | "base_uri": "https://localhost:8080/", 191 | "height": 206 192 | }, 193 | "id": "9N0NJb__yE6z", 194 | "outputId": "28fda8f9-b8ef-4912-834b-a35e35a172e2" 195 | }, 196 | "source": [ 197 | "df = df[['entity','year','books_per_million']]\n", 198 | "df = df[df['entity'] == 'Austria']\n", 199 | "df.head()\n" 200 | ], 201 | "execution_count": 8, 202 | "outputs": [ 203 | { 204 | "output_type": "execute_result", 205 | "data": { 206 | "text/html": [ 207 | "
\n", 208 | "\n", 221 | "\n", 222 | " \n", 223 | " \n", 224 | " \n", 225 | " \n", 226 | " \n", 227 | " \n", 228 | " \n", 229 | " \n", 230 | " \n", 231 | " \n", 232 | " \n", 233 | " \n", 234 | " \n", 235 | " \n", 236 | " \n", 237 | " \n", 238 | " \n", 239 | " \n", 240 | " \n", 241 | " \n", 242 | " \n", 243 | " \n", 244 | " \n", 245 | " \n", 246 | " \n", 247 | " \n", 248 | " \n", 249 | " \n", 250 | " \n", 251 | " \n", 252 | " \n", 253 | " \n", 254 | " \n", 255 | " \n", 256 | " \n", 257 | " \n", 258 | " \n", 259 | " \n", 260 | " \n", 261 | " \n", 262 | "
entityyearbooks_per_million
47Austria1937219.002794
48Austria1945411.685106
49Austria1946411.226809
50Austria1947410.831617
51Austria1948410.508146
\n", 263 | "
" 264 | ], 265 | "text/plain": [ 266 | " entity year books_per_million\n", 267 | "47 Austria 1937 219.002794\n", 268 | "48 Austria 1945 411.685106\n", 269 | "49 Austria 1946 411.226809\n", 270 | "50 Austria 1947 410.831617\n", 271 | "51 Austria 1948 410.508146" 272 | ] 273 | }, 274 | "metadata": {}, 275 | "execution_count": 8 276 | } 277 | ] 278 | }, 279 | { 280 | "cell_type": "code", 281 | "metadata": { 282 | "colab": { 283 | "base_uri": "https://localhost:8080/", 284 | "height": 297 285 | }, 286 | "id": "IyAe2kDw6P-_", 287 | "outputId": "a801b218-2cfc-4e3d-cbeb-267498daf7a5" 288 | }, 289 | "source": [ 290 | "df.plot(x = 'year', y= 'books_per_million')" 291 | ], 292 | "execution_count": 9, 293 | "outputs": [ 294 | { 295 | "output_type": "execute_result", 296 | "data": { 297 | "text/plain": [ 298 | "" 299 | ] 300 | }, 301 | "metadata": {}, 302 | "execution_count": 9 303 | }, 304 | { 305 | "output_type": "display_data", 306 | "data": { 307 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAEGCAYAAACJnEVTAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAgAElEQVR4nO3deXxU1fn48c+ThYQdEiJbgIRddiRABBWVKogLaBVFsbi01hZ/VauAVFutltbauhS1KK24flWs4o4ioIgoW1gCYQ9JgIQtkLAEyCQz8/z+mBsMmIQkZJJJ5nm/XvPKvecucw5Dnnly7rn3iKpijDEmOITUdAWMMcZUHwv6xhgTRCzoG2NMELGgb4wxQcSCvjHGBJGwmq5AWVq0aKFxcXE1XQ1jjKlVVq1adUBVY0raFtBBPy4ujqSkpJquhjHG1CoisqO0bda9Y4w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67N/xSl/BYh2yn8PPASgqhuA94CNwJfARFX1nMX716gtW7bw29/+lk2bNtGkSROeeeYZbrvtNmbPns369etxu93MmDGD/Pz8EsuL5OXlcfXVVzNu3Dh+9atf8eWXX9KmTRuSk5NJSUlh5MiRZdajadOmrF+/nnvuuYf77rsPgHvvvZf777+flStX8sEHH/DLX/7y5P4bN25kwYIFJQb8IikpKcyZM4eVK1fy8MMP06BBA9asWcP555/PG2+8UeF/qzlz5rB27VqSk5NZsGABkyZNYs+ePQCsWbOG5557jo0bN5KWlsb3339f4fMbU9e43N4a7d45SVUXAYuc5TRKGH2jqvnADaUcPw2YVtFKlqY8Gbm/tGvXjqFDhwIwfvx4nnjiCeLj4+natSsAEyZM4MUXX+SSSy4psbwoQI8ePZrJkydzyy23ANC7d28eeOABpkyZwlVXXcWFF15YZj3GjRt38uf9998PwIIFC9i4cePJfY4cOUJeXh4A11xzDfXr1y/znJdccgmNGzemcePGNG3alKuvvvpk3datW1f+fyTHkiVLGDduHKGhobRs2ZJhw4axcuVKmjRpwqBBg4iNjQWgX79+ZGRkcMEFF1T4PYypSwI10w9qp3dBNGvWrFLnGTp0KF9++SWqCkDXrl1ZvXo1vXv35pFHHjlj33nxehQte71eli1bxtq1a1m7di1ZWVk0atQIgIYNG56xTsW7nkJCQk6uh4SE4Ha7SzusUoq/V2hoaJWf35jayJ+ZvgX9Stq5cydLly4F4O233yYhIYGMjAxSU1MBePPNNxk2bBjdunUrsbzI448/TvPmzZk4cSIAu3fvpkGDBowfP55JkyaxevXqMusxe/bskz/PP/98AC6//HKef/75k/usXbu2ilpdORdeeCGzZ8/G4/GQnZ3N4sWLGTTIbtEwpjT+zPRr3bN3AkW3bt148cUXueOOO+jRowfTp08nMTGRG2644eQF27vvvpuIiAheffXVn5QX969//Ys77riDyZMnM3z4cCZNmkRISAjh4eGn9P+XJDc3lz59+hAREXGyn3769OlMnDiRPn364Ha7ueiii3jppZf89m9xJtdeey1Lly6lb9++iAhPPfUUrVq1YvPmzTV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wse8eYYkSkB5AKLLSAb+oiy/SNMSaIWKZvjDFBxIK+McYEEQv6xhgTRCzoG2NMELGgb4wxQeT/A4WVuHKPCGRYAAAAAElFTkSuQmCC\n", 308 | "text/plain": [ 309 | "
" 310 | ] 311 | }, 312 | "metadata": { 313 | "needs_background": "light" 314 | } 315 | } 316 | ] 317 | } 318 | ] 319 | } -------------------------------------------------------------------------------- /Web_Scraping_from_TrustPilot.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "provenance": [], 7 | "authorship_tag": "ABX9TyOWtJ2tpj3chJADoVCotlOE", 8 | "include_colab_link": true 9 | }, 10 | "kernelspec": { 11 | "name": "python3", 12 | "display_name": "Python 3" 13 | }, 14 | "language_info": { 15 | "name": "python" 16 | } 17 | }, 18 | "cells": [ 19 | { 20 | "cell_type": "markdown", 21 | "metadata": { 22 | "id": "view-in-github", 23 | "colab_type": "text" 24 | }, 25 | "source": [ 26 | "\"Open" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "metadata": { 33 | "id": "JP6PLQnwDvlC" 34 | }, 35 | "outputs": [], 36 | "source": [ 37 | "from time import sleep\n", 38 | "import requests\n", 39 | "from google.colab import files\n", 40 | "import pandas as pd\n", 41 | "from bs4 import BeautifulSoup\n", 42 | "\n", 43 | "def soup2list(src, list_, attr=None):\n", 44 | " if attr:\n", 45 | " for val in src:\n", 46 | " list_.append(val[attr])\n", 47 | " else:\n", 48 | " for val in src:\n", 49 | " list_.append(val.get_text())\n", 50 | "\n", 51 | "users = []\n", 52 | "userReviewNum = []\n", 53 | "ratings = []\n", 54 | "locations = []\n", 55 | "dates = []\n", 56 | "reviews = []\n", 57 | "\n", 58 | "from_page = 1\n", 59 | "to_page = 6\n", 60 | "company = 'mefx.company'\n", 61 | "\n", 62 | "for i in range(from_page, to_page+1):\n", 63 | "\n", 64 | " result = requests.get(fr\"https://www.trustpilot.com/review/{company}?page={i}\")\n", 65 | " soup = BeautifulSoup(result.content)\n", 66 | "\n", 67 | " # Trust Pilot was setup in a way that's not friendly to scraping, so this hacky method will do.\n", 68 | " soup2list(soup.find_all('span', {'class','typography_heading-xxs__QKBS8 typography_appearance-default__AAY17'}), users)\n", 69 | " soup2list(soup.find_all('div', {'class','typography_body-m__xgxZ_ typography_appearance-subtle__8_H2l styles_detailsIcon__Fo_ua'}), locations)\n", 70 | " soup2list(soup.find_all('span', {'class','typography_body-m__xgxZ_ typography_appearance-subtle__8_H2l'}), userReviewNum)\n", 71 | " soup2list(soup.find_all('div', {'class','styles_reviewHeader__iU9Px'}), dates)\n", 72 | " soup2list(soup.find_all('div', {'class','styles_reviewHeader__iU9Px'}), ratings, attr='data-service-review-rating')\n", 73 | " soup2list(soup.find_all('div', {'class','styles_reviewContent__0Q2Tg'}), reviews)\n", 74 | "\n", 75 | " # To avoid throttling\n", 76 | " sleep(1)\n", 77 | "\n", 78 | "review_data = pd.DataFrame(\n", 79 | "{\n", 80 | " 'Username':users,\n", 81 | " 'Total reviews':userReviewNum,\n", 82 | " 'location':locations,\n", 83 | " 'date':dates,\n", 84 | " 'content':reviews,\n", 85 | " 'Rating': ratings\n", 86 | "})\n" 87 | ] 88 | }, 89 | { 90 | "cell_type": "code", 91 | "source": [ 92 | "review_data" 93 | ], 94 | "metadata": { 95 | "colab": { 96 | "base_uri": "https://localhost:8080/", 97 | "height": 423 98 | }, 99 | "id": "_soYMTNmEDNF", 100 | "outputId": "f7d6df63-61fc-45e9-e9af-8ed83e67235d" 101 | }, 102 | "execution_count": 3, 103 | "outputs": [ 104 | { 105 | "output_type": "execute_result", 106 | "data": { 107 | "text/plain": [ 108 | " Username Total reviews location date \\\n", 109 | "0 Jorge Guilherme Eggers 3 reviews BR Dec 13, 2022 \n", 110 | "1 Darryl Hayton 4 reviews GB Dec 13, 2022 \n", 111 | "2 Jude Crown 1 review CA Oct 25, 2022 \n", 112 | "3 Stéphane MOTARD 4 reviews ES Aug 6, 2022 \n", 113 | "4 Mahadev Kumar 2 reviews NP Oct 25, 2022 \n", 114 | ".. ... ... ... ... \n", 115 | "114 Asling Elvis 1 review US Jan 29, 2022 \n", 116 | "115 Elfrem Neftalem 1 review GB Jun 4, 2021 \n", 117 | "116 Nabinur Islam 1 review BD Jun 2, 2021 \n", 118 | "117 Byron Clark 1 review US Jun 1, 2021 \n", 119 | "118 Rohan Smit 1 review GB May 21, 2021 \n", 120 | "\n", 121 | " content Rating \n", 122 | "0 I have been a member of the MEFX…I have been a... 5 \n", 123 | "1 MEFX Company LTD is the best thing to…MEFX Com... 5 \n", 124 | "2 I have never believed in anything…I have never... 5 \n", 125 | "3 Still with the same opinionStill with the same... 1 \n", 126 | "4 I have never been this lucky in…I have never b... 5 \n", 127 | ".. ... ... \n", 128 | "114 Amazing investment company with good…Amazing i... 5 \n", 129 | "115 Amazing passive income projectDate of experien... 5 \n", 130 | "116 Best Investment platformDate of experience: Ju... 5 \n", 131 | "117 Awesome platform!Date of experience: June 01, ... 5 \n", 132 | "118 Fast withdrawalsDate of experience: May 21, 2021 5 \n", 133 | "\n", 134 | "[119 rows x 6 columns]" 135 | ], 136 | "text/html": [ 137 | "\n", 138 | "
\n", 139 | "
\n", 140 | "\n", 153 | "\n", 154 | " \n", 155 | " \n", 156 | " \n", 157 | " \n", 158 | " \n", 159 | " \n", 160 | " \n", 161 | " \n", 162 | " \n", 163 | " \n", 164 | " \n", 165 | " \n", 166 | " \n", 167 | " \n", 168 | " \n", 169 | " \n", 170 | " \n", 171 | " \n", 172 | " \n", 173 | " \n", 174 | " \n", 175 | " \n", 176 | " \n", 177 | " \n", 178 | " \n", 179 | " \n", 180 | " \n", 181 | " \n", 182 | " \n", 183 | " \n", 184 | " \n", 185 | " \n", 186 | " \n", 187 | " \n", 188 | " \n", 189 | " \n", 190 | " \n", 191 | " \n", 192 | " \n", 193 | " \n", 194 | " \n", 195 | " \n", 196 | " \n", 197 | " \n", 198 | " \n", 199 | " \n", 200 | " \n", 201 | " \n", 202 | " \n", 203 | " \n", 204 | " \n", 205 | " \n", 206 | " \n", 207 | " \n", 208 | " \n", 209 | " \n", 210 | " \n", 211 | " \n", 212 | " \n", 213 | " \n", 214 | " \n", 215 | " \n", 216 | " \n", 217 | " \n", 218 | " \n", 219 | " \n", 220 | " \n", 221 | " \n", 222 | " \n", 223 | " \n", 224 | " \n", 225 | " \n", 226 | " \n", 227 | " \n", 228 | " \n", 229 | " \n", 230 | " \n", 231 | " \n", 232 | " \n", 233 | " \n", 234 | " \n", 235 | " \n", 236 | " \n", 237 | " \n", 238 | " \n", 239 | " \n", 240 | " \n", 241 | " \n", 242 | " \n", 243 | " \n", 244 | " \n", 245 | " \n", 246 | " \n", 247 | " \n", 248 | " \n", 249 | " \n", 250 | " \n", 251 | " \n", 252 | " \n", 253 | " \n", 254 | " \n", 255 | " \n", 256 | " \n", 257 | " \n", 258 | " \n", 259 | " \n", 260 | " \n", 261 | " \n", 262 | " \n", 263 | " \n", 264 | " \n", 265 | " \n", 266 | "
UsernameTotal reviewslocationdatecontentRating
0Jorge Guilherme Eggers3 reviewsBRDec 13, 2022I have been a member of the MEFX…I have been a...5
1Darryl Hayton4 reviewsGBDec 13, 2022MEFX Company LTD is the best thing to…MEFX Com...5
2Jude Crown1 reviewCAOct 25, 2022I have never believed in anything…I have never...5
3Stéphane MOTARD4 reviewsESAug 6, 2022Still with the same opinionStill with the same...1
4Mahadev Kumar2 reviewsNPOct 25, 2022I have never been this lucky in…I have never b...5
.....................
114Asling Elvis1 reviewUSJan 29, 2022Amazing investment company with good…Amazing i...5
115Elfrem Neftalem1 reviewGBJun 4, 2021Amazing passive income projectDate of experien...5
116Nabinur Islam1 reviewBDJun 2, 2021Best Investment platformDate of experience: Ju...5
117Byron Clark1 reviewUSJun 1, 2021Awesome platform!Date of experience: June 01, ...5
118Rohan Smit1 reviewGBMay 21, 2021Fast withdrawalsDate of experience: May 21, 20215
\n", 267 | "

119 rows × 6 columns

\n", 268 | "
\n", 269 | "
\n", 270 | "\n", 271 | "
\n", 272 | " \n", 280 | "\n", 281 | " \n", 321 | "\n", 322 | " \n", 346 | "
\n", 347 | "\n", 348 | "\n", 349 | "
\n", 350 | " \n", 361 | "\n", 362 | "\n", 451 | "\n", 452 | " \n", 474 | "
\n", 475 | "
\n", 476 | "
\n" 477 | ] 478 | }, 479 | "metadata": {}, 480 | "execution_count": 3 481 | } 482 | ] 483 | }, 484 | { 485 | "cell_type": "code", 486 | "source": [ 487 | "# Convert the DataFrame to a CSV file and download it\n", 488 | "review_data.to_csv('reviews.csv', index=False)\n", 489 | "files.download('reviews.csv')" 490 | ], 491 | "metadata": { 492 | "colab": { 493 | "base_uri": "https://localhost:8080/", 494 | "height": 17 495 | }, 496 | "id": "XfeWnNaSVd02", 497 | "outputId": "680e8a17-e0fd-4873-deb5-355d38772162" 498 | }, 499 | "execution_count": 4, 500 | "outputs": [ 501 | { 502 | "output_type": "display_data", 503 | "data": { 504 | "text/plain": [ 505 | "" 506 | ], 507 | "application/javascript": [ 508 | "\n", 509 | " async function download(id, filename, size) {\n", 510 | " if (!google.colab.kernel.accessAllowed) {\n", 511 | " return;\n", 512 | " }\n", 513 | " const div = document.createElement('div');\n", 514 | " const label = document.createElement('label');\n", 515 | " label.textContent = `Downloading \"${filename}\": `;\n", 516 | " div.appendChild(label);\n", 517 | " const progress = document.createElement('progress');\n", 518 | " progress.max = size;\n", 519 | " div.appendChild(progress);\n", 520 | " document.body.appendChild(div);\n", 521 | "\n", 522 | " const buffers = [];\n", 523 | " let downloaded = 0;\n", 524 | "\n", 525 | " const channel = await google.colab.kernel.comms.open(id);\n", 526 | " // Send a message to notify the kernel that we're ready.\n", 527 | " channel.send({})\n", 528 | "\n", 529 | " for await (const message of channel.messages) {\n", 530 | " // Send a message to notify the kernel that we're ready.\n", 531 | " channel.send({})\n", 532 | " if (message.buffers) {\n", 533 | " for (const buffer of message.buffers) {\n", 534 | " buffers.push(buffer);\n", 535 | " downloaded += buffer.byteLength;\n", 536 | " progress.value = downloaded;\n", 537 | " }\n", 538 | " }\n", 539 | " }\n", 540 | " const blob = new Blob(buffers, {type: 'application/binary'});\n", 541 | " const a = document.createElement('a');\n", 542 | " a.href = window.URL.createObjectURL(blob);\n", 543 | " a.download = filename;\n", 544 | " div.appendChild(a);\n", 545 | " a.click();\n", 546 | " div.remove();\n", 547 | " }\n", 548 | " " 549 | ] 550 | }, 551 | "metadata": {} 552 | }, 553 | { 554 | "output_type": "display_data", 555 | "data": { 556 | "text/plain": [ 557 | "" 558 | ], 559 | "application/javascript": [ 560 | "download(\"download_9c6b9184-994b-440a-9e86-267dc193321c\", \"reviews.csv\", 32399)" 561 | ] 562 | }, 563 | "metadata": {} 564 | } 565 | ] 566 | } 567 | ] 568 | } --------------------------------------------------------------------------------