Glider
Loading...
Searching...
No Matches
NightlifeTemplate.py
Go to the documentation of this file.
1import re
2
4 def date(self, filename):
5 """Sets date column given the filename (it contains the date)
6 For example Nightlife_2022_Q4.csv
7 Args:
8 filename (str): current filename
9 Returns: date_str (str)
10 """
11 # "Nightlife_2022_Q4.csv"
12 quarter = {"Q1": "01", "Q2": "04", "Q3": "07", "Q4": "10"}
13 year = re.findall(r'_20\d{2}', filename)[0]
14 year = year.replace("_", "")
15 q = re.findall(r'_Q\d{1}', filename)[0]
16 q = q.replace("_", "")
17 month = quarter[q]
18 date_str = year+"-"+month+"-01"
19 # df["date_from_file"] = date_str
20 return date_str