Fixed date issue.

parent 567e0113
......@@ -53,13 +53,18 @@ if "DATDS" in datafile.columns:
if str(x) == 'nan': #math.isnan(x):
derived_outcome_month.append(None)
else:
month_num = x.split("/")
if len(month_num) == 3:
month_num = month_num[1]
month_nums = x.split("/")
year_pos = 2
if len(month_nums) == 1:
month_nums = x.split("-")
year_pos = 0
if len(month_nums) == 3:
month_num = month_nums[1]
datetime_object = datetime.datetime.strptime(month_num, "%m")
full_month_name = datetime_object.strftime("%B")
derived_outcome_month.append(full_month_name)
derived_outcome_month.append(month_nums[year_pos] + "-" + full_month_name)
else:
derived_outcome_month.append(None)
......@@ -71,16 +76,24 @@ if "DATAD" in datafile.columns:
derived_outcome_month = []
for x in datafile["DATAD"]:
if str(x) == 'nan': # math.isnan(x):
if str(x) == 'nan': #math.isnan(x):
derived_outcome_month.append(None)
else:
month_num = x.split("/")
if len(month_num) == 3:
month_num = month_num[1]
month_nums = x.split("/")
year_pos = 2
if len(month_nums) == 1:
month_nums = x.split("-")
year_pos = 0
if len(month_nums) == 3:
month_num = month_nums[1]
datetime_object = datetime.datetime.strptime(month_num, "%m")
full_month_name = datetime_object.strftime("%B")
derived_outcome_month.append(full_month_name)
if int(month_nums[year_pos]) >= 2019 or (int(month_num) == 12 and int(month_nums[year_pos]) == 2019):
derived_outcome_month.append(month_nums[year_pos] + "-" + full_month_name)
else:
derived_outcome_month.append(None)
else:
derived_outcome_month.append(None)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment