dev
Steve Nyemba 3 years ago
parent 2fdc7c8f5c
commit 1bdf6cc8b3

@ -244,7 +244,14 @@ class Generator (Learner):
return _date.strftime(FORMAT) return _date.strftime(FORMAT)
pass pass
def format(self,_df): 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]')
return _df
pass pass
def post(self,_candidates): def post(self,_candidates):
@ -272,10 +279,10 @@ class Generator (Learner):
years = _df[iname] years = _df[iname]
_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)
writer.write(_df,schema=_schema) writer.write(_df,schema=_schema)
self.log(**{'module':self.name,'action':'write','input':{'rows':N,'candidates':len(_candidates)}}) self.log(**{'module':self.name,'action':'write','input':{'rows':N,'candidates':len(_candidates)}})

Loading…
Cancel
Save