I want to only see the times in the dictionary as it it currently being printed like
How do i only see, for example the 17:00 - 18:00 part of the dictionary.
event_dates = {} #dictionary to store event dates and time
df = pd.read_html('https://www.dcu.ie/students/events')[0]['Event date']
event_dates.update(df)
I have tried using the pop method but doesn't seem to work. this is how i am printing it
for key in event_dates.values():
print(key)
CodePudding user response:
IIUC, you want to remove the dates and keep only the time.
You could use a regex:
df = df.str.replace('([a-zA-Z] \d , |\s (?=\s))', '')
output:
0 09:00 - 17:00
1 12:45 - 14:00
2 17:00 - 18:00
3 13:00 - 14:00
4 13:15 - 13:35
...
CodePudding user response:
You can do the following to print any desired key from the dictionary, just replace it with whatever time you need to print:
for key, value in event_dates.values():
if key == event_dates["March 9, 17:00 - March 9, 18:00"]:
print(value)