<jupyter_start><jupyter_text>Task IIIs average/median monthly delay different during the year? If yes, which are months with the biggest delays and what could be the reason? --- **INPUT** data with nulls removed  may be before or after outlier removal since we are using this for exploratory and understanding purposes ---<jupyter_code>#import packages
import pandas as pd
import datetime
import seaborn as sns<jupyter_output><empty_output><jupyter_text>*using the LOF computed remaining information*<jupyter_code>df = pd.read_csv('lof.csv')
tasktwo = df[["fl_date","arr_delay"]]
def get_month(date):
    """Returns the month the flight occurs
    INPUT date in form YYYY-MM-DD
    RETURNS month"""
    DATE = datetime.datetime.strptime(date, "%Y-%m-%d")
    return DATE.month
def get_day_of_week(date):
    """Returns the day of the week
    INPUT date in the form YYYY-MM-DD
    RETURNS number of day of the week:
            where 0 = Monday and 6 = Sunday"""
    DATE = pd.to_datetime(date)
    return DATE.dayofweek
tasktwo["fl_month"] = tasktwo.fl_date.apply(get_month)
#group by month and determine the mean
tasktwo_monthmean = tasktwo.groupby("fl_month", as_index=False)["arr_delay"].mean()
sns.barplot(x="fl_month",
            y="arr_delay",
            data=tasktwo_monthmean,
            color='purple').set_title("Mean Arrival Delays by Month")
#Repeat for median
tasktwo_monthmedian = tasktwo.groupby("fl_month", as_index=False)["arr_delay"].median()
sns.barplot(x="fl_month",
            y="arr_delay",
            data=tasktwo_monthmedian,
            color='purple').set_title("Median Arrival Delays by Month")<jupyter_output><empty_output><jupyter_text>if we consider only the "delays" not any on time or early flights...<jupyter_code>tasktwo_delaycheck = tasktwo[tasktwo.arr_delay > 0]
#group by month and determine the mean
tasktwo_delay_monthmean = tasktwo_delaycheck.groupby("fl_month", as_index=False)["arr_delay"].mean()
#group by month and determine the median
tasktwo_delay_monthmedian = tasktwo_delaycheck.groupby("fl_month", as_index=False)["arr_delay"].median()
sns.barplot(x="fl_month",
            y="arr_delay",
            data=tasktwo_delay_monthmean,
            color='blue').set_title("Mean of Arrival Delays(late) by Month")
sns.barplot(x="fl_month",
            y="arr_delay",
            data=tasktwo_delay_monthmedian,
            color='blue').set_title("Median Arrival Delays(late) by Month")<jupyter_output><empty_output><jupyter_text>*Using the IQR computed outlier data*<jupyter_code>df = pd.read_csv('iqr.csv')
tasktwo = df[["fl_date","arr_delay"]]
tasktwo["fl_month"] = tasktwo.fl_date.apply(get_month)
tasktwo_monthmean = tasktwo.groupby("fl_month", as_index=False)["arr_delay"].mean()
sns.barplot(x="fl_month", y="arr_delay", data=tasktwo_monthmean, color='purple').set_title("Mean Arrival Delays by Month")
tasktwo_monthmedian = tasktwo.groupby("fl_month", as_index=False)["arr_delay"].median()
sns.barplot(x="fl_month", y="arr_delay", data=tasktwo_monthmedian, color='purple').set_title("Median Arrival Delays by Month")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12346872985170858, 'fraction_numerical': 0.0009671179883945841, 'mean_word_length': 5.156746031746032, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 18, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '570698', 'license': 'MIT', 'n_tokens_mistral': 1051, 'n_tokens_neox': 1015, 'n_words': 234, 'path': 'Notebooks/2_Task_2.ipynb', 'repo_name': 'Isabelle-Dr/MidTerm-Project', 'size': '3102'}