{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "name": "gspread_demo.ipynb", "provenance": [], "collapsed_sections": [], "authorship_tag": "ABX9TyOAgIGXHEa/heCsRp3jWT4k", "include_colab_link": true }, "kernelspec": { "name": "python3", "display_name": "Python 3" } }, "cells": [ { "cell_type": "markdown", "metadata": { "id": "view-in-github", "colab_type": "text" }, "source": [ "\"Open" ] }, { "cell_type": "code", "metadata": { "id": "Lb7ZoNMM2_nH", "colab_type": "code", "colab": {} }, "source": [ "from google.colab import auth\n", "\n", "auth.authenticate_user()\n", "\n", "import gspread\n", "\n", "from oauth2client.client import GoogleCredentials\n", "gc = gspread.authorize(GoogleCredentials.get_application_default())\n" ], "execution_count": 0, "outputs": [] }, { "cell_type": "markdown", "metadata": { "id": "_e1tPrKS3r_T", "colab_type": "text" }, "source": [ "# Import data from demo spreadsheet (\"AirBnB open data\") #" ] }, { "cell_type": "code", "metadata": { "id": "_Y5DXy3j3xc5", "colab_type": "code", "colab": {} }, "source": [ "url2='https://docs.google.com/spreadsheets/d/1YTD0pxdGTGAzM8IiWDfLL4AZPjrFRN-vpGUiLQWOtoI/edit#gid=1512387781'\n", "\n", "gc2= gspread.authorize(GoogleCredentials.get_application_default())\n", "wb2= gc2.open_by_url(url2)\n", "\n", "sheet = wb2.worksheet('AB_NYC_2019')\n", "\n" ], "execution_count": 0, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "gQDz6Cl55vxG", "colab_type": "code", "colab": {} }, "source": [ "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "\n", "data = sheet.get_all_values()\n", "\n", "df = pd.DataFrame( data )\n", "\n" ], "execution_count": 0, "outputs": [] }, { "cell_type": "code", "metadata": { "id": "w-PuSUBD69qj", "colab_type": "code", "colab": { "base_uri": "https://localhost:8080/", "height": 551 }, "outputId": "43ea7fe9-17f2-42b0-a65c-61a4cd56f545" }, "source": [ "df.head().transpose()" ], "execution_count": 16, "outputs": [ { "output_type": "execute_result", "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
01234
0id2539259536473831
1nameClean & quiet apt home by the parkSkylit Midtown CastleTHE VILLAGE OF HARLEM....NEW YORK !Cozy Entire Floor of Brownstone
2host_id2787284546324869
3host_nameJohnJenniferElisabethLisaRoxanne
4neighbourhood_groupBrooklynManhattanManhattanBrooklyn
5neighbourhoodKensingtonMidtownHarlemClinton Hill
6latitude40.6474940.7536240.8090240.68514
7longitude-73.97237-73.98377-73.9419-73.95976
8room_typePrivate roomEntire home/aptPrivate roomEntire home/apt
9price14922515089
10minimum_nights1131
11number_of_reviews9450270
12last_review2018-10-192019-05-212019-07-05
13reviews_per_month0.210.384.64
14calculated_host_listings_count6211
15availability_365365355365194
\n", "
" ], "text/plain": [ " 0 ... 4\n", "0 id ... 3831\n", "1 name ... Cozy Entire Floor of Brownstone\n", "2 host_id ... 4869\n", "3 host_name ... LisaRoxanne\n", "4 neighbourhood_group ... Brooklyn\n", "5 neighbourhood ... Clinton Hill\n", "6 latitude ... 40.68514\n", "7 longitude ... -73.95976\n", "8 room_type ... Entire home/apt\n", "9 price ... 89\n", "10 minimum_nights ... 1\n", "11 number_of_reviews ... 270\n", "12 last_review ... 2019-07-05\n", "13 reviews_per_month ... 4.64\n", "14 calculated_host_listings_count ... 1\n", "15 availability_365 ... 194\n", "\n", "[16 rows x 5 columns]" ] }, "metadata": { "tags": [] }, "execution_count": 16 } ] } ] }