<jupyter_start><jupyter_text><jupyter_code>import numpy as np
import requests
import pandas as pd
import matplotlib.pyplot as plt
import datetime
# Define function to download data from NCEI
# Function adapted from <NAME>: https://github.com/stefmolin/Hands-On-Data-Analysis-with-Pandas/

def make_request(endpoint, payload=None):
    """
    Make a request to a specific endpoint on the weather API
    passing headers and optional payload.
    
    Parameters:
        - endpoint: The endpoint of the API you want to 
                    make a GET request to.
        - payload: A dictionary of data to pass along 
                   with the request.
    
    Returns:
        Response object.
    """
    return requests.get(
        f'https://www.ncdc.noaa.gov/cdo-web/api/v2/{endpoint}',
        headers={
            'token': '<KEY>'
        },
        params=payload
    )
current = datetime.date(2017,12, 1)
end = datetime.date(2017, 12, 3)

results = []

while current < end:

    response = make_request(
        'data', 
        {
            'datasetid' : 'GHCND', # Global Historical Climatology Network - Daily (GHCND) dataset
            'stationid' : 'GHCND:ASN00008051', # Somewhere in Australia 
            'datatypeid': 'TMAX', # Request only TMAX
            'startdate' : current,
            'enddate' : current,
            'units' : 'metric'
        }
    )

    if response.ok:
        # we extend the list instead of appending to avoid getting a nested list
        results.extend(response.json()['results'][0])

    # update the current date to avoid an infinite loop
    current += datetime.timedelta(days=1)
results<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09838998211091235, 'fraction_numerical': 0.01490757304710793, 'mean_word_length': 2.316205533596838, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '634955', 'license': 'MIT', 'n_tokens_mistral': 506, 'n_tokens_neox': 487, 'n_words': 150, 'path': 'groupb_project2.ipynb', 'repo_name': 'bieri2/ATMS-597-SP-2020', 'size': '1713'}