def select_by_hour(df, hour="All"):
    """
    This function takes in a string designating a time window and returns instances from a dataframe which fall
    within this time window.

    Required argument:
    - df: pandas dataframe, contains movie showtimes

    Optional argument:
    - hour: string, designates a time window; valid options are: "All", "9-12am", "12-3pm", "3-6pm", "6-9pm", "9-12pm".
    Defaults to "All".

    Returns:
    - df: pandas dataframe, the same as was fed into the function, but filtered to contain only those occurrences
    where the showtime is within the designated time window.
    """
    if hour == "All":
        df = df
    elif hour == "9-12am":
        df = df[df["dt_showtime"].between('09:00:00', '12:00:00')]
    elif hour == "12-3pm":
        df = df[df["dt_showtime"].between('12:00:00', '15:00:00')]
    elif hour == "3-6pm":
        df = df[df["dt_showtime"].between('15:00:00', '18:00:00')]
    elif hour == "6-9pm":
        df = df[df["dt_showtime"].between('18:00:00', '21:00:00')]
    else:
        df = df[df["dt_showtime"].between('21:00:00', '23:59:00')]

    return df