-
Notifications
You must be signed in to change notification settings - Fork 73
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
Function to transform an xarray grid into a pandas dataframe #5
Comments
I've started working on this and have something that works on a few cases. I'll expand it and run it through some tests and put in a pull request next week. I am assuming its just a pandas dataframe with columns named after coordinates and the variable, and an incremental index? What are your thoughts on adding support for multiple variables? |
Hi @jessepisel, just got back from vacation. Thanks for taking a stab at this! I really appreciate it.
Yep, that was the basic premise. It's meant as a utility to help with classes/functions that don't support xarray input, like
That should probably be the default if given a But we could start off with just a single |
Any ideas on creating some tests for the PR that I just submitted? |
OT. just dropping a comment here: Hi, this is a function that should be implemented in xarray. Meaning that given nD object, there should be a Basically xarray.to_dataframe() outputs data in a long format, and what we usually want is to have data in a wide format. This is similar problem we had in https://github.com/arviz-devs/arviz/pull/335/files I'm just saying, maybe there should be an effort to upgrade xarray functionality. |
@ahartikainen I was thinking the same thing. You are absolutely right. We could get this into Verde for now and then ping the xarray folks to see if they have interest in this. We can then port it over to them and deprecate/remove our function. It could even be an option for |
The builtin
to_dataframe
method in xarray uses the coordinates as the dataframe 2D indices, so in practice it's not really spelling out all of the point coordinates. What I want is to make the grid into an xyz format with the coordinates as columns of the dataframe.This will allow us to use the data in functions that don't like grids, like the forward modeling and inversion functions in Fatiando.
The function should be
grid_to_table(grid)
and it spits out a table with the columns having the correct names taken from the grid.The text was updated successfully, but these errors were encountered: