<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 <a href="https
Step1:  List Superfund sites
The individual sites are instances of SuperfundSite, and are listed in the corresponding Graph Browser page.
To programmatically list all Superfund sites, use the get_places_in API as follows
Step2:  In place of USA, you can specify any US state or county. You can use place search to find the corresponding DCID, as illustrated here.
Get statistics
Superfund sites have associated statistical variables like CrsiScore_Superfundsite, NaturalHazardRiskScore_Superfundsite, etc. To see the list of all variables, you can visit a Superfund site's Graph Browser page (example).
To get stats for all variables for all sites, use the build_multivariate_dataframe API, as follows
Step3:  Additional statistics for Tar Creek site
Tar Creek is one of the largest Superfund sites, and only for that site we have additional stats on contaminants in the ground water from sampling wells. These stats are attached to instances of SuperfundMeasurementSite contained in Tar Creek.
The measurement sites are listed on the Tar Creek Graph Browser page, and a measurement site's Graph Browser page (example) lists all available statistical variables.
To get these stats, list the measurement sites within Tar Creek, and then provide all associated variables, as follows
Step4:  Get non-statistical attributes
The Superfund sites have non-statistical properties like latitude/longitude, ownership status, EPA region code, and so on. These are listed in each site's Graph Browser page (example).
To get these values, use the get_property_labels and get_property_values APIs, and append to the existing dataframe (site_df), as follows
<ASSISTANT_TASK:>
Python Code:
!pip install datacommons_pandas datacommons --upgrade --quiet
# Import Data Commons libraries
import datacommons as dc
import datacommons_pandas as dcpd
Explanation: <a href="https://colab.research.google.com/github/datacommonsorg/api-python/blob/master/notebooks/Accessing_Superfund_data_from_Data_Commons.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>
Copyright 2022 Google LLC.
SPDX-License-Identifier: Apache-2.0
Notebook Version - 1.0.0
Accessing Superfund data from Data Commons
Superfund sites are US locations contaminated with hazardous substances that the EPA seeks to investigate and clean up. Data Commons (DC) includes data about Superfund sites, and this notebook illustrates how that can be accessed using the DC python APIs with Pandas extension.
An extended version of this notebook that does some analysis with the extracted Superfund data can be found here.
Set-up
Import the DC python APIs, as follows:
End of explanation
# Gets all Superfund sites within USA
place_dcid = 'country/USA'   # DCID of USA
site_list = dc.get_places_in([place_dcid], 'SuperfundSite')[place_dcid]
site_list[:5]
Explanation: List Superfund sites
The individual sites are instances of SuperfundSite, and are listed in the corresponding Graph Browser page.
To programmatically list all Superfund sites, use the get_places_in API as follows:
End of explanation
# Gets stats for the listed variables from all sites in a Pandas table
site_df = dcpd.build_multivariate_dataframe(site_list,
                                            ['CrsiScore_SuperfundSite',
                                             'NaturalHazardExposureScore_SuperfundSite',
                                             'NaturalHazardRiskScore_SuperfundSite',
                                             'NaturalHazardRiskScore_SuperfundSite_CoastalFloodEvent',
                                             'NaturalHazardRiskScore_SuperfundSite_DroughtEvent',
                                             'NaturalHazardRiskScore_SuperfundSite_EarthquakeEvent',
                                             'NaturalHazardRiskScore_SuperfundSite_ExcessiveHeatEvent',
                                             'NaturalHazardRiskScore_SuperfundSite_ExtremeColdWindChillEvent',
                                             'NaturalHazardRiskScore_SuperfundSite_FloodEvent',
                                             'NaturalHazardRiskScore_SuperfundSite_HailEvent',
                                             'NaturalHazardRiskScore_SuperfundSite_HighWindEvent',
                                             'NaturalHazardRiskScore_SuperfundSite_HurricaneEvent',
                                             'NaturalHazardRiskScore_SuperfundSite_LandslideEvent',
                                             'NaturalHazardRiskScore_SuperfundSite_TornadoEvent',
                                             'NaturalHazardRiskScore_SuperfundSite_WildfireEvent'])
site_df.head()
Explanation: In place of USA, you can specify any US state or county. You can use place search to find the corresponding DCID, as illustrated here.
Get statistics
Superfund sites have associated statistical variables like CrsiScore_Superfundsite, NaturalHazardRiskScore_Superfundsite, etc. To see the list of all variables, you can visit a Superfund site's Graph Browser page (example).
To get stats for all variables for all sites, use the build_multivariate_dataframe API, as follows:
End of explanation
# Gets all measurement sites contained in Tar Creek 
tar_creek_site = 'epaSuperfundSiteId/OKD980629844'  # DCID of Tar Creek
measurement_sites = dc.get_places_in([tar_creek_site], 'SuperfundMeasurementSite')[tar_creek_site]
# Gets stats for contaminant variables for said measurement sites
tar_creek_df = dcpd.build_multivariate_dataframe(
                    measurement_sites,
                    [
                      'Concentration_Cadmium_BodyOfWater_GroundWater',
                      'Concentration_DissolvedContaminant_Cadmium_BodyOfWater_GroundWater',
                      'Concentration_DissolvedContaminant_Iron_BodyOfWater_GroundWater',
                      'Concentration_DissolvedContaminant_Lead_BodyOfWater_GroundWater',
                      'Concentration_DissolvedContaminant_Zinc_BodyOfWater_GroundWater',
                      'Concentration_Iron_BodyOfWater_GroundWater',
                      'Concentration_Lead_BodyOfWater_GroundWater',
                      'Concentration_Sulfate_BodyOfWater_GroundWater',
                      'DissolvedOxygen_BodyOfWater_GroundWater',
                      'Concentration_Zinc_BodyOfWater_GroundWater',
                      'PotentialOfHydrogen_BodyOfWater_GroundWater',
                      'ElectricalConductivity_BodyOfWater_GroundWater',
                      'Temperature_BodyOfWater_GroundWater',
                      'WaterHardness_BodyOfWater_GroundWater'
                    ])
tar_creek_df.head()
Explanation: Additional statistics for Tar Creek site
Tar Creek is one of the largest Superfund sites, and only for that site we have additional stats on contaminants in the ground water from sampling wells. These stats are attached to instances of SuperfundMeasurementSite contained in Tar Creek.
The measurement sites are listed on the Tar Creek Graph Browser page, and a measurement site's Graph Browser page (example) lists all available statistical variables.
To get these stats, list the measurement sites within Tar Creek, and then provide all associated variables, as follows:
End of explanation
# Lists properties for a sample site
site_props = dc.get_property_labels([tar_creek_site], out=True)[tar_creek_site]
for prop in site_props:
  # Gets values for a given property. pvs is dict from site-id -> list of values
  pvs = dc.get_property_values(site_list, prop)
  # Turns the list of values into a comma-separated a single-value
  pvs = {p: ', '.join(v) for p, v in pvs.items()}
  # Extends the dataframe
  site_df[prop] = site_df.index.map(pvs)
site_df.head()
Explanation: Get non-statistical attributes
The Superfund sites have non-statistical properties like latitude/longitude, ownership status, EPA region code, and so on. These are listed in each site's Graph Browser page (example).
To get these values, use the get_property_labels and get_property_values APIs, and append to the existing dataframe (site_df), as follows:
End of explanation
<END_TASK>