<jupyter_start><jupyter_text>Extracting Data I used SQL to extract the data from the database and calculate the moving averages at the same time.1. I filtered `city_list` to show me cities in my country using:```SQLselect city from city_listwhere country='Turkey'```2. I extracted global temperature data from `globa_data` using:```SQLselect year, avg_temp as global_avg, ROUND(AVG(avg_temp) OVER (ORDER BY year ASC ROWS 9 PRECEDING), 2) AS global_ma10, ROUND(AVG(avg_temp) OVER (ORDER BY year ASC ROWS 24 PRECEDING), 2) AS global_ma25from global_data```3. I did the same with `city_data` but only for the closest city which happens to be Istanbul:```SQLselect year, avg_temp as city_avg, ROUND(AVG(avg_temp) OVER (ORDER BY year ASC ROWS 9 PRECEDING), 2) AS city_ma10, ROUND(AVG(avg_temp) OVER (ORDER BY year ASC ROWS 24 PRECEDING), 2) AS city_ma25from city_datawhere city='Istanbul'```  Loading dataThe 2 tables are loaded and joined together using `Python` and `pandas`.<jupyter_code>global_data_path = "datasets/weather_global_data.csv"
city_data_path = "datasets/weather_city_data.csv"
import pandas as pd

global_data = pd.read_csv(global_data_path)
city_data = pd.read_csv(city_data_path)
full_data = pd.merge(left=global_data,right=city_data, how='outer', left_on='year', right_on='year')
full_data.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
Int64Index: 273 entries, 0 to 272
Data columns (total 7 columns):
 #   Column       Non-Null Count  Dtype  
---  ------       --------------  -----  
 0   year         273 non-null    int64  
 1   global_avg   266 non-null    float64
 2   global_ma10  266 non-null    float64
 3   global_ma25  266 non-null    float64
 4   city_avg     267 non-null    float64
 5   city_ma10    271 non-null    float64
 6   city_ma25    271 non-null    float64
dtypes: float64(6), int64(1)
memory usage: 17.1 KB<jupyter_text>VisualizationThe dataframe containeing the full data is plotted using pandas' `plot` function, it uses `matplotlib` as its backend, which in turn is styled using `seaborn`.We can ignore the earliest records for Istanbul, because we don't have global averages for the same years to compare them to.The graph needs to fit all the dataand still be easy to read.<jupyter_code>import seaborn as sns

sns.set()
ax1 = full_data[['year', 'global_avg', 'city_avg']].plot(x = 'year', title = 'Average temperatures globally and in Istanbul', figsize=(17,10), ylim=(0,16), xlim=(1750,2015), xticks=range(1750,2015,25))
ax1.set_xlabel('Year')
ax1.set_ylabel('Average Temperature in ºC')
ax2 = full_data.drop(['global_avg', 'city_avg'], axis = 1).plot(x = 'year', title = 'Average temperatures globally and in Istanbul', figsize=(17,10), xlim=(1750,2015), ylim=(0,16), xticks=range(1750,2015,25))
ax2.set_xlabel('Year')
ax2.set_ylabel('Average Temperature in ºC')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11005958640028041, 'fraction_numerical': 0.05187521906764809, 'mean_word_length': 4.896694214876033, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '539905', 'license': 'MIT', 'n_tokens_mistral': 1077, 'n_tokens_neox': 942, 'n_words': 312, 'path': 'P1/P1_Explore_Weather_Trends.ipynb', 'repo_name': 'husmen/DAND_Udacity', 'size': '2853'}