Skip to content

Commit 42d9840

Browse files
committed
Make lowercase columns default, add option to make them same as model
1 parent 292dc84 commit 42d9840

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

odm2api/ODM2/services/readService.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ def getDataSetsResults(self, ids=None, codes=None, uuids=None, dstype=None):
923923
print('Error running Query {}'.format(e))
924924
return None
925925

926-
def getDataSetsValues(self, ids=None, codes=None, uuids=None, dstype=None):
926+
def getDataSetsValues(self, ids=None, codes=None, uuids=None, dstype=None, lowercols=True):
927927
"""
928928
Retrieve a list of datavalues associated with the given dataset info
929929
@@ -934,6 +934,8 @@ def getDataSetsValues(self, ids=None, codes=None, uuids=None, dstype=None):
934934
uuids (list, optional): List of Dataset UUIDs string.
935935
dstype (str, optional): Type of Dataset from
936936
`controlled vocabulary name <http://vocabulary.odm2.org/datasettype/>`_.
937+
lowercols (bool, optional): Make column names to be lowercase.
938+
Default to True.
937939
938940
939941
Returns:
@@ -945,7 +947,7 @@ def getDataSetsValues(self, ids=None, codes=None, uuids=None, dstype=None):
945947
>>> READ.getDataSetsValues(codes=['HOME', 'FIELD'])
946948
>>> READ.getDataSetsValues(uuids=['a6f114f1-5416-4606-ae10-23be32dbc202',
947949
... '5396fdf3-ceb3-46b6-aaf9-454a37278bb4'])
948-
>>> READ.getDataSetsValues(dstype='singleTimeSeries')
950+
>>> READ.getDataSetsValues(dstype='singleTimeSeries', lowercols=False)
949951
950952
"""
951953

@@ -956,7 +958,7 @@ def getDataSetsValues(self, ids=None, codes=None, uuids=None, dstype=None):
956958
resids.append(ds.ResultID)
957959

958960
try:
959-
return self.getResultValues(resultids = resids)
961+
return self.getResultValues(resultids=resids, lowercols=lowercols)
960962
except Exception as e:
961963
print('Error running Query {}'.format(e))
962964
return None
@@ -1336,7 +1338,7 @@ def getResultDerivationEquations(self):
13361338
"""
13371339
return self._session.query(ResultDerivationEquations).all()
13381340

1339-
def getResultValues(self, resultids, starttime=None, endtime=None):
1341+
def getResultValues(self, resultids, starttime=None, endtime=None, lowercols=True):
13401342
"""
13411343
Retrieve result values associated with the given result.
13421344
@@ -1345,6 +1347,8 @@ def getResultValues(self, resultids, starttime=None, endtime=None):
13451347
resultids (list): List of SamplingFeatureIDs.
13461348
starttime (object, optional): Start time to filter by as datetime object.
13471349
endtime (object, optional): End time to filter by as datetime object.
1350+
lowercols (bool, optional): Make column names to be lowercase.
1351+
Default to True.
13481352
13491353
Returns:
13501354
DataFrame: Pandas dataframe of result values.
@@ -1355,7 +1359,7 @@ def getResultValues(self, resultids, starttime=None, endtime=None):
13551359
>>> READ.getResultValues(resultids=[100, 20, 34], starttime=datetime.today())
13561360
>>> READ.getResultValues(resultids=[1, 2, 3, 4],
13571361
>>> starttime=datetime(2000, 01, 01),
1358-
>>> endtime=datetime(2003, 02, 01))
1362+
>>> endtime=datetime(2003, 02, 01), lowercols=False)
13591363
13601364
"""
13611365
restype = self._session.query(Results).filter_by(ResultID=resultids[0]).first().ResultTypeCV
@@ -1393,7 +1397,8 @@ def getResultValues(self, resultids, starttime=None, endtime=None):
13931397
con=self._session_factory.engine,
13941398
params=query.params
13951399
)
1396-
df.columns = [self._get_columns(ResultValues)[c] for c in df.columns]
1400+
if not lowercols:
1401+
df.columns = [self._get_columns(ResultValues)[c] for c in df.columns]
13971402
return df
13981403
except Exception as e:
13991404
print('Error running Query: {}'.format(e))

0 commit comments

Comments
 (0)