-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathutil.py
26 lines (19 loc) · 811 Bytes
/
util.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Useful stuff
import datetime
import pendulum
import pandas as pd
def generate_dates_in_range(start_dt, end_dt, interval_minutes):
"""Return list of dates between start and end."""
start_dt = start_dt.replace(second = 0, microsecond = 0)
date_time_list = []
current = start_dt
while current < end_dt :
dt_str = pendulum.instance(current).format('D/MM/YYYY H:mm')
date_time_list.append(current)
current = current + datetime.timedelta(minutes = interval_minutes)
return date_time_list
def date_parser(date_string):
# print("parsing", date_string)
# return pendulum.from_format(date_string, ('%d/%m/%Y %H:%M'))
return pd.datetime.strptime(date_string, '%d/%m/%Y %H:%M')
# return pendulum.from_format(date_string, ('DD/MM/YYYY HH:mm'))