From 1bdf6cc8b3adbb200e3f2e318553ddbef5b55e2f Mon Sep 17 00:00:00 2001 From: Steve Nyemba Date: Wed, 13 Apr 2022 10:55:55 -0500 Subject: [PATCH] bug fix --- data/maker/__init__.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/data/maker/__init__.py b/data/maker/__init__.py index 3acddc1..ff93104 100644 --- a/data/maker/__init__.py +++ b/data/maker/__init__.py @@ -244,7 +244,14 @@ class Generator (Learner): return _date.strftime(FORMAT) 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 def post(self,_candidates): @@ -272,10 +279,10 @@ class Generator (Learner): years = _df[iname] _dates = [self.make_date(year=year,field=name) for year in years] if _dates : - _df[name] = _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) writer.write(_df,schema=_schema) self.log(**{'module':self.name,'action':'write','input':{'rows':N,'candidates':len(_candidates)}})