Created
May 11, 2020 07:55
-
-
Save yzdann/09aa5a4825eaf9fcad74c29a3fd7365a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import timedelta | |
import pandas | |
def read_csv(file_name): | |
file_name_with_extension = f"{file_name}.csv" | |
df = pandas.read_csv(file_name_with_extension, parse_dates=["Date"]) | |
df = df[["Zone", "Date", "Status Code", "Response Time"]] | |
return df | |
def select_time(df, hour: int, minute: int, mins_duration: int): | |
date_of_csv = df["Date"][0] | |
start_time = date_of_csv.replace(hour=hour, minute=minute) | |
end_time = start_time + timedelta(minutes=mins_duration) | |
selected_time = df[(df["Date"] > start_time) & (df["Date"] <= end_time)] | |
return selected_time |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment