File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed
Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change 1+ from pandas .errors import ParserError
2+
3+
14def calendar_days (start : str , end : str ):
25 """
36 This method will create a union of calendar dates for further comparison.
@@ -7,11 +10,11 @@ def calendar_days(start: str, end: str):
710 :return: Union of calendar days. 01/01/2015 to 01/01/2016
811 """
912 from pandas import to_datetime , date_range
10-
11- start_date = to_datetime (start ) # Defines the start date of data collection
12- end_date = to_datetime (end ) # Defines the end date of data collection
13-
14- calendar_list = date_range ( start_date , end_date )
15-
16- return calendar_list
17-
13+ try :
14+ start_date = to_datetime (start ) # Defines the start date of data collection
15+ end_date = to_datetime (end ) # Defines the end date of data collection
16+ calendar_list = date_range ( start_date , end_date )
17+ return calendar_list
18+ except ( ValueError , ParserError ):
19+ print ( ' \033 [31m' + 'WARNING! Please, insert a valid date' + ' \033 [0m' )
20+ return None
You can’t perform that action at this time.
0 commit comments