From 1ff4145eeaaff2c7e901bb73cc3c1c650298f2a3 Mon Sep 17 00:00:00 2001 From: Steve Nyemba Date: Thu, 14 Apr 2022 12:36:20 -0500 Subject: [PATCH] bugfix: formatter --- data/maker/__init__.py | 13 +++++++++++-- setup.py | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/data/maker/__init__.py b/data/maker/__init__.py index 3f437d2..2b53def 100644 --- a/data/maker/__init__.py +++ b/data/maker/__init__.py @@ -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'] : + + 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 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) diff --git a/setup.py b/setup.py index c96877b..1991bde 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ import sys def read(fname): return open(os.path.join(os.path.dirname(__file__), fname)).read() -args = {"name":"data-maker","version":"1.5.1", +args = {"name":"data-maker","version":"1.5.2", "author":"Vanderbilt University Medical Center","author_email":"steve.l.nyemba@vumc.org","license":"MIT", "packages":find_packages(),"keywords":["healthcare","data","transport","protocol"]} args["install_requires"] = ['data-transport@git+https://dev.the-phi.com/git/steve/data-transport.git','tensorflow']