Skip to content
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

Add location_df_to_json function #95

Open
msweier opened this issue Oct 8, 2024 · 2 comments
Open

Add location_df_to_json function #95

msweier opened this issue Oct 8, 2024 · 2 comments

Comments

@msweier
Copy link
Collaborator

msweier commented Oct 8, 2024

This would help bulk management of locations by allowing one to do edits of subsetted location data in a panadas dataframe and then store into the database. It appears you have to manually convert the dataframe into json for a store.

@Enovotny
Copy link
Collaborator

@msweier for things like this where it is a direct 1 to 1 for the df to json we can use standard pandas functions. for example
from json import loads, dumps
loads(df.to_json(orient="records"))[0]

now maybe it makes sense to put that in as a function, but since it is really only one line I'm not sure if it is needed.

The functions are for things like timeseries where the df is only a subset of the json that is obtained from CDA. the df only includes the values. So in this case we could not use the standard pandas function to go back to json.

@msweier
Copy link
Collaborator Author

msweier commented Oct 10, 2024

@Enovotny loads(df.to_json(orient="records" should probably do the trick. I didn't know that was the way to do it.

I suppose it would be more like location_cat_to_df. I'm thinking for editing metadata for multiple locations in a dataframe (e.g. elevation, state, timezone, etc...) using get_locations_catalog, turning that into a dataframe, subseting data, and storing back. Mainly to clean up data and manage project locations and sublocations. CMA is going away and CWMS-VUE has issues and lags behind with features. Maybe there's a better way to do what I'm trying to do.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants