-
Notifications
You must be signed in to change notification settings - Fork 224
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
Allow pandas.DataFrame table and 1D/2D numpy array inputs into pygmt.info #574
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:
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
info
supports both file name inputs and pandas.DataFrame tables now.Fixes #564
Reminders
make format
andmake check
to make sure the code follows the style guide.doc/api/index.rst
.