Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 13
Make lowercase columns default, add option to make them same as model#140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
42d98404b48b3edbca706badb4985164ebe58a3616File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 <http://vocabulary.odm2.org/datasettype/>`_. | ||
| 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. | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add this at the end of the | ||
| **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)) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add this at the end of the
lowercolsdescription: "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.