<jupyter_start><jupyter_text>Generate Cities List<jupyter_code># List for holding lat_lngs and cities
lat_lngs = []
cities = []

# Create a set of random lat and lng combinations
lats = np.random.uniform(low=-90.000, high=90.000, size=1500)
lngs = np.random.uniform(low=-180.000, high=180.000, size=1500)
lat_lngs = zip(lats, lngs)

# Identify nearest city for each lat, lng combination
for lat_lng in lat_lngs:
    city = citipy.nearest_city(lat_lng[0], lat_lng[1]).city_name
    
    # If the city is unique, then add it to a our cities list
    if city not in cities:
        cities.append(city)

# Print the city count to confirm sufficient count
len(cities)<jupyter_output><empty_output><jupyter_text>Perform API Calls<jupyter_code># OpenWeatherMap API Key

# Starting URL for Weather Map API Call
def call_city(city, request, api_key):
    try:
        url = "http://api.openweathermap.org/data/2.5/weather?units=Imperial&appid=" + api_key + "&q=" + city
        data = requests.get(url).json()
        latitude = data['coord']['lat']
    
        if (request == 'temperature'):
            answer = data['main']['temp_max']
        elif(request == 'humidity'):
            answer = data['main']['humidity']
        elif request == 'clouds':
            answer = data['clouds']['all']
        elif request == 'wind':
            answer = data['wind']['speed']
        else:
            print('That request is not valid!\nUse "temperature" , "humidity", "clouds", or "wind"')
    
        return latitude, answer

    except:
        return 'NA', "errorhere" + city

def create_df(cities, request, api_key):
    df = pd.DataFrame(columns = ['Latitude', request], index = range(len(cities)))
    df['Latitude'] = [call_city(city, request, api_key)[0] for city in cities]
    df[request] = [call_city(city, request, api_key)[1] for city in cities]
    return df<jupyter_output><empty_output><jupyter_text>Temperature (F) vs. Latitude<jupyter_code>temp_df = create_df(cities,'temperature',api_key)
temp_df.head()
temp_df.to_csv('temperatures.csv')

temp_error_indexes = temp_df['Latitude'][temp_df['Latitude'] == 'NA'].index
cleaned_temp = temp_df.drop(temp_df.index[temp_error_indexes])

plt.scatter(cleaned_temp['Latitude'], cleaned_temp['temperature'])
plt.xlabel('Latitude')
plt.ylabel('Temperature (F)')
plt.title('Temperature at Different Latitudes')
sns.set_style("dark")<jupyter_output><empty_output><jupyter_text>There's clearly a very strong inverse correlation between distance from the equator and temperature. As in, the closer you get to the equator, the hotter it gets. It seems that this trend is a bit stronger in the southern hemisphere.  Humidity (%) vs. Latitude<jupyter_code>hum_df = create_df(cities,'humidity',api_key)
hum_df.head()
hum_df.to_csv('humidity.csv')

hum_error_indexes = hum_df['Latitude'][hum_df['Latitude'] == 'NA'].index
cleaned_hum = hum_df.drop(hum_df.index[hum_error_indexes])

plt.scatter(cleaned_hum['Latitude'], cleaned_hum['humidity'])
plt.xlabel('Latitude')
plt.ylabel('Humidity (%)')
plt.title('Humidity at Different Latitudes')
sns.set_style("dark")<jupyter_output><empty_output><jupyter_text>It appears that there is a slight correlation with higher humidity the closer you get to the equator, albeit far less strong that temperature correlation with latitude. Mostly it appears that this correlation starts around +/- 20 latitude. The closer you get from that point, the more humid it will be. However, further out than that, the humidity appears to have no correlation with latitude.  Cloudiness (%) vs. Latitude<jupyter_code>clouds_df = create_df(cities,'clouds',api_key)
clouds_df.head()
clouds_df.to_csv('clouds.csv')

clouds_error_indexes = clouds_df['Latitude'][clouds_df['Latitude'] == 'NA'].index
cleaned_clouds = clouds_df.drop(clouds_df.index[clouds_error_indexes])

plt.scatter(cleaned_clouds['Latitude'], cleaned_clouds['clouds'])
plt.xlabel('Latitude')
plt.ylabel('Clouds (%)')
plt.title('Cloud Pecentage at Different Latitudes')
sns.set_style("dark")<jupyter_output><empty_output><jupyter_text>There is clearly no correlation between cloud percentage and different latitudes. However, the data looks discrete, as evidenced by the neat rows. The cloud density is probably estimated by percentages of 5 or 2.5.  Wind Speed (mph) vs. Latitude<jupyter_code>wind_df = create_df(cities,'wind',api_key)
wind_df.head()
wind_df.to_csv('wind.csv')

wind_error_indexes = wind_df['Latitude'][wind_df['Latitude'] == 'NA'].index
cleaned_wind = wind_df.drop(wind_df.index[wind_error_indexes])

plt.scatter(cleaned_wind['Latitude'], cleaned_wind['wind'])
plt.xlabel('Latitude')
plt.ylabel('Wind Speed (mph)')
plt.title('Wind Speed at Different Latitudes')
sns.set_style("dark")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13009667927700713, 'fraction_numerical': 0.008617065994115174, 'mean_word_length': 5.387919463087249, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '144368', 'license': 'MIT', 'n_tokens_mistral': 1645, 'n_tokens_neox': 1571, 'n_words': 388, 'path': 'WeatherPy.ipynb', 'repo_name': 'tobymbern/weather', 'size': '4758'}