diff --git a/odm2api/ODM2/services/readService.py b/odm2api/ODM2/services/readService.py index a696c15..cbe8cc4 100644 --- a/odm2api/ODM2/services/readService.py +++ b/odm2api/ODM2/services/readService.py @@ -922,7 +922,7 @@ def getDataSetsResults(self, ids=None, codes=None, uuids=None, dstype=None): print('Error running Query {}'.format(e)) return None - def getDataSetsValues(self, ids=None, codes=None, uuids=None, dstype=None): + def getDataSetsValues(self, ids=None, codes=None, uuids=None, dstype=None, lowercols=True): """ Retrieve a list of datavalues associated with the given dataset info @@ -933,6 +933,12 @@ def getDataSetsValues(self, ids=None, codes=None, uuids=None, dstype=None): uuids (list, optional): List of Dataset UUIDs string. dstype (str, optional): Type of Dataset from `controlled vocabulary name `_. + lowercols (bool, optional): Make column names to be lowercase. + Default to True. + **Please start upgrading your code to rely on CamelCase column names, + In a near-future release, + the default will be changed to False, + and later the parameter may be removed**. Returns: @@ -944,7 +950,7 @@ def getDataSetsValues(self, ids=None, codes=None, uuids=None, dstype=None): >>> READ.getDataSetsValues(codes=['HOME', 'FIELD']) >>> READ.getDataSetsValues(uuids=['a6f114f1-5416-4606-ae10-23be32dbc202', ... '5396fdf3-ceb3-46b6-aaf9-454a37278bb4']) - >>> READ.getDataSetsValues(dstype='singleTimeSeries') + >>> READ.getDataSetsValues(dstype='singleTimeSeries', lowercols=False) """ @@ -955,7 +961,7 @@ def getDataSetsValues(self, ids=None, codes=None, uuids=None, dstype=None): resids.append(ds.ResultID) try: - return self.getResultValues(resultids=resids) + return self.getResultValues(resultids=resids, lowercols=lowercols) except Exception as e: print('Error running Query {}'.format(e)) return None @@ -1338,7 +1344,7 @@ def getResultDerivationEquations(self): """ return self._session.query(ResultDerivationEquations).all() - def getResultValues(self, resultids, starttime=None, endtime=None): + def getResultValues(self, resultids, starttime=None, endtime=None, lowercols=True): """ Retrieve result values associated with the given result. @@ -1347,6 +1353,12 @@ def getResultValues(self, resultids, starttime=None, endtime=None): resultids (list): List of SamplingFeatureIDs. starttime (object, optional): Start time to filter by as datetime object. endtime (object, optional): End time to filter by as datetime object. + lowercols (bool, optional): Make column names to be lowercase. + Default to True. + **Please start upgrading your code to rely on CamelCase column names, + In a near-future release, + the default will be changed to False, + and later the parameter may be removed**. Returns: DataFrame: Pandas dataframe of result values. @@ -1357,7 +1369,7 @@ def getResultValues(self, resultids, starttime=None, endtime=None): >>> READ.getResultValues(resultids=[100, 20, 34], starttime=datetime.today()) >>> READ.getResultValues(resultids=[1, 2, 3, 4], >>> starttime=datetime(2000, 01, 01), - >>> endtime=datetime(2003, 02, 01)) + >>> endtime=datetime(2003, 02, 01), lowercols=False) """ restype = self._session.query(Results).filter_by(ResultID=resultids[0]).first().ResultTypeCV @@ -1395,7 +1407,14 @@ def getResultValues(self, resultids, starttime=None, endtime=None): con=self._session_factory.engine, params=query.params ) - df.columns = [self._get_columns(ResultValues)[c] for c in df.columns] + if not lowercols: + df.columns = [self._get_columns(ResultValues)[c] for c in df.columns] + else: + warnings.warn( + 'In a near-future release, ' + 'the parameter \'lowercols\' default will be changed to False, ' + 'and later the parameter may be removed.', + DeprecationWarning, stacklevel=2) return df except Exception as e: print('Error running Query: {}'.format(e))