{
"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": [
""
]
},
{
"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", " | 0 | \n", "1 | \n", "2 | \n", "3 | \n", "4 | \n", "
---|---|---|---|---|---|
0 | \n", "id | \n", "2539 | \n", "2595 | \n", "3647 | \n", "3831 | \n", "
1 | \n", "name | \n", "Clean & quiet apt home by the park | \n", "Skylit Midtown Castle | \n", "THE VILLAGE OF HARLEM....NEW YORK ! | \n", "Cozy Entire Floor of Brownstone | \n", "
2 | \n", "host_id | \n", "2787 | \n", "2845 | \n", "4632 | \n", "4869 | \n", "
3 | \n", "host_name | \n", "John | \n", "Jennifer | \n", "Elisabeth | \n", "LisaRoxanne | \n", "
4 | \n", "neighbourhood_group | \n", "Brooklyn | \n", "Manhattan | \n", "Manhattan | \n", "Brooklyn | \n", "
5 | \n", "neighbourhood | \n", "Kensington | \n", "Midtown | \n", "Harlem | \n", "Clinton Hill | \n", "
6 | \n", "latitude | \n", "40.64749 | \n", "40.75362 | \n", "40.80902 | \n", "40.68514 | \n", "
7 | \n", "longitude | \n", "-73.97237 | \n", "-73.98377 | \n", "-73.9419 | \n", "-73.95976 | \n", "
8 | \n", "room_type | \n", "Private room | \n", "Entire home/apt | \n", "Private room | \n", "Entire home/apt | \n", "
9 | \n", "price | \n", "149 | \n", "225 | \n", "150 | \n", "89 | \n", "
10 | \n", "minimum_nights | \n", "1 | \n", "1 | \n", "3 | \n", "1 | \n", "
11 | \n", "number_of_reviews | \n", "9 | \n", "45 | \n", "0 | \n", "270 | \n", "
12 | \n", "last_review | \n", "2018-10-19 | \n", "2019-05-21 | \n", "\n", " | 2019-07-05 | \n", "
13 | \n", "reviews_per_month | \n", "0.21 | \n", "0.38 | \n", "\n", " | 4.64 | \n", "
14 | \n", "calculated_host_listings_count | \n", "6 | \n", "2 | \n", "1 | \n", "1 | \n", "
15 | \n", "availability_365 | \n", "365 | \n", "355 | \n", "365 | \n", "194 | \n", "