-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
42d9840
Make lowercase columns default, add option to make them same as model
lsetiawan 4b48b3e
Merge branch 'development' into fix_grv
lsetiawan dbca706
Merge branch 'development' into fix_grv
lsetiawan badb498
Add warning message for lowercols parameter
lsetiawan 5164ebe
Merge branch 'fix_grv' of https://github.com/lsetiawan/ODM2PythonAPI …
lsetiawan 58a3616
Add warning doc in getDataSetsValues
lsetiawan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)) | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.