Skip to content

Commit

Permalink
More fixes for Sheets tutorials (#497)
Browse files Browse the repository at this point in the history
* troubleshooting API

* Revert to gerund

Though the style guide says to just use imperatives, "get started" just sounds weird. Also this is more consistent with "troubleshooting"

* fixed egregiously out-of-date info and added mention of Sheets to the concepts doc

* overhaul Sheets index page

* fix few mis-wordings

* restore mention of Workspace Marketplace

* tweak procedure

* Revert "tweak procedure"

This reverts commit d35bc34.

* tweak procedure again

* rewording suggested by Julia

* removed reference to video which I removed, and correct column number

* rewrote sort step of sleep tutorial

* updated data to 2020

* tweak images

* small tweaks

* redoing Covid tutorial

* more corrections to tutorials

* more tweaks
  • Loading branch information
kmoscoe authored Sep 4, 2024
1 parent 6fd4e0a commit e9dcc41
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 41 deletions.
2 changes: 1 addition & 1 deletion api/sheets/get_name.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
layout: default
title: Names Associated with a DCID
nav_order: 1
nav_order: 6
parent: Google Sheets
grand_parent: API
---
Expand Down
2 changes: 1 addition & 1 deletion api/sheets/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
layout: default
title: Google Sheets
nav_order: 5
nav_order: 0
parent: API
has_children: true
---
Expand Down
6 changes: 3 additions & 3 deletions api/sheets/tutorials/index.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
layout: default
title: Tutorials
nav_order: 100
nav_order: 1
parent: Google Sheets
grand_parent: API
has_children: true
has_children: false
---

# Tutorials

Get familiar with the [Data Commons Google Sheets API](..) with these step-by-step guides:
Get familiar with the [Data Commons Google Sheets add-on with these step-by-step guides:

- [Analyze the COVID-19 pandemic](sheets_covid.html)
- [Obtain latitude information for country capitals in South America](sheets_latitude.html)
Expand Down
36 changes: 17 additions & 19 deletions api/sheets/tutorials/sheets_covid.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
---
layout: default
title: Sheets COVID-19 Analysis
nav_order: 3
title: Sheets COVID-19 analysis
parent: Tutorials
parent_url: /api/sheets/tutorials
grand_parent: Google Sheets
grand_parent_url: /api/sheets
show_in_nav: false
---

# Using Data Commons' Google Sheets API to analyze the COVID-19 pandemic
# Analyze the COVID-19 pandemic

## Introduction
Throughout the ongoing COVID-19 pandemic, the Data Commons team has been working to upload COVID-19 data as it becomes available, helping public and private sector analysts create evidence-based policy to combat the public health crisis. This tutorial presents an example of how to obtain this data from the Data Commons API and use Google Sheets for visualization of it.
Throughout COVID-19 pandemic, the Data Commons team worked to upload COVID-19 data as it became available, helping public and private sector analysts create evidence-based policy to combat the public health crisis. This tutorial presents an example of how to obtain use Google Sheets to obtain the data from Data Commons and create visualizations for it.

## Step 1: Setup
Pull up Google Sheets and create a new, blank spreadsheet. You can title it `Data Commons COVID-19 analysis` or any other name of your choosing.

![](/assets/images/sheets/tutorials/sheets_covid_tutorial_1.png)

To enable the Data Commons API in your spreadsheet, ensure that the Data Commons extension is installed and available under the Extensions tab in the main menu. Hover over the Data Commons menu item, then click on the Fill Place DCIDs option.
To enable the Data Commons API in your spreadsheet, ensure that the Data Commons extension is installed and available under the **Extensions** menu. Hover over the **Data Commons** menu item, then click on the **Fill place DCIDs** option.

![](/assets/images/sheets/tutorials/sheets_covid_tutorial_2.png)

Expand All @@ -30,30 +30,28 @@ Next, double-click on A1 in the chart and type `country/USA`.

![](/assets/images/sheets/tutorials/sheets_covid_tutorial_4.png)

## Step 2: Retrieving place names and DCIDs from Data Commons
To obtain the DCIDs for all the states, you can use the plugin function `DCPLACESIN`. Type `=DCPLACESIN(A1, "State")` into cell B1. Sheets will provide pointers to help guide your function inputs. Your spreadsheet output should look like this:
## Step 2: Retrieve place names and DCIDs
To obtain the DCIDs for all the states, you can use the plugin function `DCPLACESIN`. In cell B1, type `=DCPLACESIN(A1, "State")`. Sheets provides pointers to help guide your function inputs. Your spreadsheet output should look like this:

![](/assets/images/sheets/tutorials/sheets_covid_tutorial_5.png)

Finally, you’ll want to retrieve the state names and position them conveniently near these DCIDs. You can use the plugin function `DCGETNAME` to access this information. Type `=DCGETNAME(B1)` in cell C1, then click and drag to repeat this formula throughout the C column. Your final output should look like this:
Finally, you’ll want to retrieve the state names and position them conveniently near these DCIDs. You can use the add-on function `DCGETNAME` to access this information. In cell C1, type `=DCGETNAME(B1:B)`. Your final output should look like this:

![](/assets/images/sheets/tutorials/sheets_covid_tutorial_6.png)

## Step 3: Populating the spreadsheet with COVID information
In this tutorial, you will be analyzing each state’s cumulative count of deaths due to COVID as of December 15, 2020. To do this, you will need to get the value of the [statistical variable](/glossary.html) `CumulativeCount_MedicalConditionIncident_COVID_19_PatientDeceased` for each state on the date specified. You can use the `DCGET` method to do this.
## Step 3: Populate the spreadsheet with COVID information
Let's analyze each state’s cumulative count of deaths due to COVID as of December 31, 2022. To do this, we get the value of the [statistical variable](/glossary.html) `CumulativeCount_MedicalConditionIncident_COVID_19_PatientDeceased` for each state on the date specified. You can use the `DCGET` method to do this.

Type `=DCGET(B1, "CumulativeCount_MedicalConditionIncident_COVID_19_PatientDeceased", "2020-12-15")` into cell D1, then click and drag to repeat this formula throughout the D column. Your final output should look like this:
In cell D1, type `=DCGET(B1:B, "CumulativeCount_MedicalConditionIncident_COVID_19_PatientDeceased", "2022-12-31")`. Your final output should look like this:

![](/assets/images/sheets/tutorials/sheets_covid_tutorial_7.png)
![](/assets/images/sheets/tutorials/sheets_covid_tutorial_7.png){: width="600"}

## Step 4: Visualizing the data
As a final step, you can use Google’s Geo Chart option to map this data! Select cell arrays C1:C52 and D1:D52, then click on the Chart option under Insert in the main menu. Your spreadsheet will look a bit like this:
## Step 4: Visualize the data
As a final step, you can use Google Sheets' Chart option to map this data! Select cells C1 to D52, then select **Insert** > **Chart**. Your spreadsheet will look like this:

![](/assets/images/sheets/tutorials/sheets_covid_tutorial_8.png)
![](/assets/images/sheets/tutorials/sheets_covid_tutorial_8.png){: width="800"}

Feel free to drag the histogram out of the way of the numbers! As a final step, under `Chart type` in the right sidebar, click on the map. Under the chart customization options, you can click on the `Geo` dropdown, then select the United States region to display your results. Your final sheet should look something like this:
Feel free to drag the histogram out of the way of the numbers! As a final step, in the right sidebar **Chart editor**, from the **Setup** > **Chart type** drop-down menu, select **Map**. Then, from the **Customize** > **Geo** > **Region** drop-down menu, select the **United States**. Your final sheet should look something like this:

![](/assets/images/sheets/tutorials/sheets_covid_tutorial_9.png)

If you’d like to experiment more with the data and methods from this tutorial, check out <https://docs.google.com/spreadsheets/d/1yK4YCpwF2AeiaVIfINXVHXw5O3BEjPyWnCSsqonfVBM/edit?usp=sharing>. You can copy the spreadsheet at <https://docs.google.com/spreadsheets/d/1yK4YCpwF2AeiaVIfINXVHXw5O3BEjPyWnCSsqonfVBM/copy>. Note that you will need to enable the Sheets API as in Step 1 to retrieve the data for analysis.
![](/assets/images/sheets/tutorials/sheets_covid_tutorial_9.png){: width="800"}

26 changes: 13 additions & 13 deletions api/sheets/tutorials/sheets_latitude.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
---
layout: default
title: Sheets South American Latitudes
nav_order: 4
title: Sheets South American latitudes
parent: Tutorials
parent_url: /api/sheets/tutorials
grand_parent: Google Sheets
grand_parent_url: /api/sheets
show_in_nav: false
---

# Obtaining latitude information for country capitals in South America
# Obtain latitude information for country capitals in South America

## Introduction
The Data Commons API enables end users to obtain basic information about the entities in the graph by retrieving their properties. This tutorial walks you through the `DCPROPERTY` method in the Sheets API that enables this.
The Data Commons Sheets add-on allows you to obtain basic information about the entities in the knowledge graph by retrieving their properties. This tutorial walks you through the `DCPROPERTY` function that enables this.

## Step 1: Setup
Pull up Google Sheets and create a new, blank spreadsheet. You can title it `Data Commons South American capitals’ latitude` or any other name of your choosing.

![](/assets/images/sheets/tutorials/sheets_latitude_tutorial_1.png)

To enable the Data Commons API in your spreadsheet, ensure that the Data Commons extension is installed and available under the Extensions tab in the main menu. Hover over the Data Commons menu item, then click on the Fill Place DCIDs option.
To enable the Data Commons API in your spreadsheet, ensure that the Data Commons extension is installed and available under the **Extensions** menu. Hover over the **Data Commons** menu item, then click on the **Fill place DCIDs** option.

![](/assets/images/sheets/tutorials/sheets_latitude_tutorial_2.png)

## Step 2: Retrieving place names and DCIDs from Data Commons
Double-click on A1 in the chart and enter [`southamerica`](https://datacommons.org/browser/southamerica) (the DCID for the continent of South America).
## Step 2: Retrieve place names and DCIDs
Double-click on the A1 cell and enter [`southamerica`](https://datacommons.org/browser/southamerica) (the DCID for the continent of South America).

![](/assets/images/sheets/tutorials/sheets_latitude_tutorial_3.png)

To obtain the DCIDs for all the countries, you can use the plugin function [`DCPLACESIN`](/api/sheets/places_in.html). Type `=DCPLACESIN(A1, "Country")` into cell B1. Sheets will provide pointers to help guide your function inputs. Your spreadsheet output should look like this:
To obtain the DCIDs for all the countries, you can use the add-on function [`DCPLACESIN`](/api/sheets/places_in.html). In cell B1, type `=DCPLACESIN(A1, "Country")`. Sheets provides pointers to help guide your function inputs. Your spreadsheet output should look like this:

![](/assets/images/sheets/tutorials/sheets_latitude_tutorial_4.png)

Next, you’ll want to retrieve the country names and position them conveniently near these DCIDs. You can use the plugin function [`DCGETNAME`](/api/sheets/get_name.html) to access this information. Type `=dcgetname(B1:B)` in cell C1. Your final output will look like this:
Next, you’ll want to retrieve the country names and position them conveniently near these DCIDs. You can use the addon-on function [`DCGETNAME`](/api/sheets/get_name.html) to access this information. In cell C1, type `=dcgetname(B1:B)`. Your final output will look like this:

![](/assets/images/sheets/tutorials/sheets_latitude_tutorial_5.png)

## Step 3: Populating the spreadsheet with capital and latitude information
## Step 3: Populate the spreadsheet with capital and latitude information
In this step, you will obtain all South American countries’ capitals and latitudes. To do this, you will need to get the value of the property names [`latitude`](https://datacommons.org/browser/latitude) and [`administrativeCapital`](https://datacommons.org/browser/administrativeCapital) for each country on the date specified. (As an aside, if you'd like to see what properties are available for any given entity, Data Commons provides a [Knowledge Graph](https://datacommons.org/browser) tool enabling you to look up any entity in the graph and view its associated properties.) You can use the [`DCPROPERTY`](/api/sheets/get_property.html) method to do this.

Type `=DCPROPERTY(B1:B, "administrativeCapital")` into cell D1. Your output should look like this:
In cell D1, `=DCPROPERTY(B1:B, "administrativeCapital")`. Your output should look like this:

![](/assets/images/sheets/tutorials/sheets_latitude_tutorial_6.png)

Now, to get the latitude of each capital, type `=DCPROPERTY(D1:D, "latitude")` into cell E1.
Now, to get the latitude of each capital, in cell E1, type `=DCPROPERTY(D1:D, "latitude")`.

![](/assets/images/sheets/tutorials/sheets_latitude_tutorial_7.png)

If you’d like to experiment more with the data and methods from this tutorial, check out <https://docs.google.com/spreadsheets/d/1AYOD9yX59aKNNHoLLsmy00uihU72EKDFDZVo5KdX7H0/edit#gid=0>. You can clone the sheet by clicking on the File dropdown, then choosing the 'Make a copy' option. Note that you will need to enable the Sheets API as in Step 1 to retrieve the data for analysis.
Finally, use the `DCGETNAME` function again, against column D, to get the names of the capitals. Try it yourself!
6 changes: 3 additions & 3 deletions api/sheets/tutorials/sheets_sleep.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
layout: default
title: Sheets CDC 500 cities sleep health
nav_order: 2
parent: Tutorials
parent_url: /api/sheets/tutorials
grand_parent: Google Sheets
grand_parent_url: /api/sheets
show_in_nav: false
---

# Analyze the CDC 500 cities for sleep health
Expand All @@ -32,12 +32,12 @@ In cell B1, enter `=DCCOHORTMEMBERS(A1)`. The output should look like this:

![](/assets/images/sheets/tutorials/sheets_sleep_tutorial_4.png)

To get the names of these cities, enter `=DCGETNAME(B1:B500)` into cell C1. The output should look like this:
To get the names of these cities, enter `=DCGETNAME(B1:B)` into cell C1. The output should look like this:

![](/assets/images/sheets/tutorials/sheets_sleep_tutorial_5.png)

## Step 3: Obtain the sleep health level for each city
We will use the percentage of chronically restless residents in each city using the `DCGET` method with the statistical variable `Percent_Person_SleepLessThan7Hours`. (More information on statistical variables is available in the [glossary](https://docs.datacommons.org/glossary.html).) Enter `=DCGET(B1:B500, "Percent_Person_SleepLessThan7Hours", "2016")` into cell D1 in your spreadsheet. The output should look like this:
We will use the percentage of chronically restless residents in each city using the `DCGET` method with the statistical variable `Percent_Person_SleepLessThan7Hours`. (More information on statistical variables is available in the [glossary](https://docs.datacommons.org/glossary.html).) Enter `=DCGET(B1:B, "Percent_Person_SleepLessThan7Hours", "2020")` into cell D1 in your spreadsheet. The output should look like this:

![](/assets/images/sheets/tutorials/sheets_sleep_tutorial_6.png){: width="600"}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/sheets/tutorials/sheets_covid_tutorial_8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/sheets/tutorials/sheets_covid_tutorial_9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion data_model.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ For example, in this node for the city of Addis Ababa, Ethiopia, the `typeOf` an

![KG browser]({{site.url}}/assets/images/dc/concept10.png){: width="600"}


Note that the DCID for a property is the same as its name.

## Observation
Expand Down

0 comments on commit e9dcc41

Please sign in to comment.