-
Notifications
You must be signed in to change notification settings - Fork 234
Allow pandas.DataFrame table and 1D/2D numpy array inputs into pygmt.info #574
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
Conversation
Also renamed 'fname' argument to 'table' since `info` supports both file name inputs and pandas.DataFrame tables now.
| if kind == "file": | ||
| file_context = dummy_context(table) | ||
| elif kind == "matrix": | ||
| _table = np.asanyarray(table) |
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.
Just FYI, this line converts pandas.DataFrame into a numpy.ndarray, while allowing numpy.ndarray objects to just pass through. A bit easier than using _table = table.values if hasattr(table, values) else table, and I think this allows for Python lists to work too (though I haven't tested it).
See also:
seisman
left a comment
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.
Looks good
Description of proposed changes
Let pygmt.info support pandas.DataFrame and 1D/2D numpy array inputs. Enables code like so:
I've renamed the 'fname' argument to 'table' (which is a 💥 breaking change) since
infosupports both file name inputs and pandas.DataFrame tables now.Fixes #564
Reminders
make formatandmake checkto make sure the code follows the style guide.doc/api/index.rst.