<jupyter_start><jupyter_text>CO2 DATA RETRIEVAL FROM MULTIPLE SOURCES TABLE OF CONTENTS1. NOAA - Moana Loa2. SCRIPPS: ICECORE Dataset (1600-Present)3. SCRIPPS: Substation Sampling Data from Worldwide Locations_Required Citations_: * **II**. <NAME>, C. et al., 2006: Law Dome CO2, CH4 and N2O ice core records extended to 2000 years BP. Geophysical Research Letters, 33.* **III**. <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, and <NAME>, Exchanges of atmospheric CO2 and 13CO2 with the terrestrial biosphere and oceans from 1978 to 2000. I. Global aspects, SIO Reference Series, No. 01-06, Scripps Institution of Oceanography, San Diego, 88 pages, 2001"<jupyter_code>import pandas as pd
import numpy as np

#Retrieving from NOAA: Moana Loa database
df_moanaloa = pd.read_csv('ftp://aftp.cmdl.noaa.gov/products/trends/co2/co2_annmean_mlo.txt', 
                 comment = '#',delimiter='   ', header=None)
df_moanaloa = df_moanaloa.rename(index=str, columns={0: "Date", 1: "Mean_CO2", 2:'StdDev'})
print(df_moanaloa.head())<jupyter_output>Date  Mean_CO2  StdDev
0  1959    315.97    0.12
1  1960    316.91    0.12
2  1961    317.64    0.12
3  1962    318.45    0.12
4  1963    318.99    0.12<jupyter_text>CO2 DATA FROM SCRIPPS: ICECORE HISTORICAL DATASET (1600-PRESENT)<jupyter_code>#Retrieving from Scripps ICE-CORE 13CE-present dataset
df_icecore = pd.read_csv('http://scrippsco2.ucsd.edu/assets/data/atmospheric/merged_ice_core_mlo_spo/spline_merged_ice_core_yearly.csv',
                         comment = '"',delimiter=',',header=None)
df_icecore = df_icecore.rename(index = str, columns={0:'Date',1:"Mean_CO2"})
print("################ DATA FROM SCRIPPS: IceCore DATA 1600-Present #############")
print(df_icecore.head())<jupyter_output>################ DATA FROM SCRIPPS: IceCore DATA 1600-Present #############
   Date  Mean_CO2
0  1679   275.903
1  1680   275.937
2  1681   275.972
3  1682   276.007
4  1683   276.042<jupyter_text>CO2 DATA FROM SCRIPPS STATION SAMPLING WORLDWIDE<jupyter_code>print("####################################################################")
print("## FOLLOWING DATA SETS FROM SCRIPPS:STATION DATA FROM WORLDWIDE LOCATIONS")


#Retrieving from Scripps ALERT NWT, CANADA Station Data
df_alertNWT = pd.read_csv('http://scrippsco2.ucsd.edu/assets/data/atmospheric/stations/flask_co2/monthly/monthly_flask_co2_alt.csv',
                          comment = '"', delimiter=",",header=None)
print("################ DATA FROM SCRIPPS: ALERT, NWT, CANADA CO2 DATA #############")
print(df_alertNWT.head())


#Retrieving from Scripps LA JOLLA, CA, UNITED STATES  Station Data
df_lajolla = pd.read_csv('http://scrippsco2.ucsd.edu/assets/data/atmospheric/stations/flask_co2/monthly/monthly_flask_co2_ljo.csv',
                          comment = '"', delimiter=",",header=None)
print("################ DATA FROM SCRIPPS: LA JOLLA, CA, UNITED STATES CO2 DATA #############")
print(df_lajolla.head())


#Retrieving from Scripps CHRISTMAS ISLAND, AUSTRALIA  Station Data
df_christmas_isl = pd.read_csv('http://scrippsco2.ucsd.edu/assets/data/atmospheric/stations/flask_isotopic/monthly/monthly_flask_c13_chr.csv', 
                                comment = '"',delimiter=",",header=None)
print("################ DATA FROM SCRIPPS: CHRISTMAS ISLAND, AUSTRALIA CO2 DATA #############")
print(df_christmas_isl.head())

#Retrieving from Scripps AMERICAN SAMOA Station Data
df_am_samoa = pd.read_csv('http://scrippsco2.ucsd.edu/assets/data/atmospheric/stations/flask_co2/monthly/monthly_flask_co2_sam.csv', 
                                comment = '"',delimiter=",",header=None)
print("################ DATA FROM SCRIPPS: AMERICAN SAMOA CO2 DATA #############")
print(df_am_samoa.head())

#Retrieving from Scripps SOUTH POLE Station Data
df_southpole = pd.read_csv('http://scrippsco2.ucsd.edu/assets/data/atmospheric/stations/merged_in_situ_and_flask/monthly/monthly_merge_co2_spo.csv',
                            comment = '"',delimiter=",",header=None)
print("################ DATA FROM SCRIPPS: SOUTH POLE, ANTARCTICA CO2 DATA #############")
print(df_southpole.head())<jupyter_output>####################################################################
## FOLLOWING DATA SETS FROM SCRIPPS:STATION DATA FROM WORLDWIDE LOCATIONS
################ DATA FROM SCRIPPS: ALERT, NWT, CANADA CO2 DATA #############
      0    1         2           3          4           5            6  \
0    Yr   Mn      Date        Date        CO2  seasonally          fit   
1                                                adjusted                
2                Excel                  [ppm]      [ppm]         [ppm]   
3  1985   01     31062   1985.0411     -99.99      -99.99       -99.99   
4  1985   02     31093   1985.1260     -99.99      -99.99       -99.99   

              7             8                9  
0    seasonally           CO2       seasonally  
1  adjusted fit        filled  adjusted filled  
2         [ppm]         [ppm]            [ppm]  
3        -99.99        -99.99           -99.99  
4        -99.99        -99.99           -99.99  
################ DATA FROM SCRIPPS: LA J[...]<jupyter_text>Create a function to do all of the above....<jupyter_code>def grab_scripps_co2_data():
    links = ['http://scrippsco2.ucsd.edu/assets/data/atmospheric/stations/flask_co2/monthly/monthly_flask_co2_alt.csv',
            'http://scrippsco2.ucsd.edu/assets/data/atmospheric/stations/flask_co2/monthly/monthly_flask_co2_ljo.csv', 
            'http://scrippsco2.ucsd.edu/assets/data/atmospheric/stations/flask_isotopic/monthly/monthly_flask_c13_chr.csv',
            'http://scrippsco2.ucsd.edu/assets/data/atmospheric/stations/flask_co2/monthly/monthly_flask_co2_sam.csv',
            'http://scrippsco2.ucsd.edu/assets/data/atmospheric/stations/merged_in_situ_and_flask/monthly/monthly_merge_co2_spo.csv']
    locations = ['Alert_CAN','LaJolla_USA','ChristmasIsland_AUS','AmericanSamoa_ASM','SouthPole_ANT']
    master_df = pd.DataFrame()
    count = 0
    for link in links: 
        station_df = pd.read_csv(link,comment = '"',delimiter=",",header=None)
        print(station_df.columns.values)
        #Add column denoting _this_ substation location 
        station_df['Location'] = locations[count]
        count += 1
        
        #only get the columns we care about...
        station_df = station_df.iloc[:,[0,3,4,10]]
        print(station_df.columns.values)
        master_df = master_df.append(station_df)
    print(master_df.head())
grab_scripps_co2_data()<jupyter_output>[0 1 2 3 4 5 6 7 8 9]
[0 3 4 'Location']
[0 1 2 3 4 5 6 7 8 9]
[0 3 4 'Location']
[0 1 2 3 4 5 6 7 8 9]
[0 3 4 'Location']
[0 1 2 3 4 5 6 7 8 9]
[0 3 4 'Location']
[0 1 2 3 4 5 6 7 8 9]
[0 3 4 'Location']
      0           3          4   Location
0    Yr        Date        CO2  Alert_CAN
1                               Alert_CAN
2                        [ppm]  Alert_CAN
3  1985   1985.0411     -99.99  Alert_CAN
4  1985   1985.1260     -99.99  Alert_CAN
{'fraction_non_alphanumeric': 0.1581061692969871, 'fraction_numerical': 0.0642754662840746, 'mean_word_length': 2.9162921348314605, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '568557', 'license': 'MIT', 'n_tokens_mistral': 2766, 'n_tokens_neox': 2395, 'n_words': 547, 'path': 'scrap/co2_data_retrieval.ipynb', 'repo_name': 'toddschultz/DegreesOfClimateChange', 'size': '7018'}