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