|
|
|
@ -265,9 +265,17 @@ class Generator (Learner):
|
|
|
|
|
def format(self,_df,_schema):
|
|
|
|
|
for _item in _schema :
|
|
|
|
|
name = _item['name']
|
|
|
|
|
if _item['type'].upper() in ['DATETIME','TIMESTAMP'] :
|
|
|
|
|
|
|
|
|
|
_df[name] = pd.to_datetime(_df[name], format='%Y-%m-%d %H:%M:%S').astype('datetime64[ns]')
|
|
|
|
|
if _item['type'].upper() in ['DATE','DATETIME','TIMESTAMP'] :
|
|
|
|
|
FORMAT = '%Y-%d-%m'
|
|
|
|
|
if 'format' in self.info and name in self.info['format'] :
|
|
|
|
|
FORMAT = self.info['format'][name]
|
|
|
|
|
else:
|
|
|
|
|
if _item['type'] == ['DATETIME','TIMESTAMP'] :
|
|
|
|
|
FORMAT = '%Y-%d-%m %H:%M:%S'
|
|
|
|
|
self.log(**{'action':'format','input':{'name':name,'format':FORMAT}})
|
|
|
|
|
|
|
|
|
|
_df[name] = pd.to_datetime(_df[name], format=FORMAT).astype(str) #.astype('datetime64[ns]')
|
|
|
|
|
return _df
|
|
|
|
|
|
|
|
|
|
pass
|
|
|
|
@ -298,6 +306,7 @@ class Generator (Learner):
|
|
|
|
|
_dates = [self.make_date(year=year,field=name) for year in years]
|
|
|
|
|
if _dates :
|
|
|
|
|
_df[name] = _dates
|
|
|
|
|
|
|
|
|
|
_schema = self.get_schema()
|
|
|
|
|
_schema = [{'name':_item.name,'type':_item.field_type} for _item in _schema]
|
|
|
|
|
_df = self.format(_df,_schema)
|
|
|
|
|