Running info on pandas.DataFrame with time column doesn't work
See original GitHub issueDescription of the problem
Just noticed that datetime columns being passed into pygmt.info
doesn’t work. This follows on from the pandas.DataFrame
inputs into pygmt.info
functionality added in #574, see also #464 and #562 where the datetime machinery should be more or less implemented.
Full code that generated the error
import pygmt
import pandas as pd
table = pd.DataFrame(data=[1,3,2,5,4], columns=["z"])
table["time"] = pd.date_range(start="2020-01-01", periods=5)
pygmt.info(table=table)
Note that the equivalent gmt
command does work on datetime inputs.
!gmt info temp.txt
temp.txt: N = 5 <1/5> <2020-01-01T00:00:00/2020-01-05T00:00:00>
Full error message
---------------------------------------------------------------------------
GMTCLibError Traceback (most recent call last)
<ipython-input-6-a9e68c3dc07e> in <module>
----> 1 pygmt.info(table=table)
~/pygmt/pygmt/helpers/decorators.py in new_module(*args, **kwargs)
235 if alias in kwargs:
236 kwargs[arg] = kwargs.pop(alias)
--> 237 return module_func(*args, **kwargs)
238
239 new_module.aliases = aliases
~/pygmt/pygmt/modules.py in info(table, **kwargs)
116
117 with GMTTempFile() as tmpfile:
--> 118 with file_context as fname:
119 arg_str = " ".join(
120 [fname, build_arg_string(kwargs), "->" + tmpfile.name]
~/miniconda3/envs/pygmt/lib/python3.7/contextlib.py in __enter__(self)
110 del self.args, self.kwds, self.func
111 try:
--> 112 return next(self.gen)
113 except StopIteration:
114 raise RuntimeError("generator didn't yield") from None
~/pygmt/pygmt/clib/session.py in virtualfile_from_matrix(self, matrix)
1268 )
1269
-> 1270 self.put_matrix(dataset, matrix)
1271
1272 with self.open_virtual_file(
~/pygmt/pygmt/clib/session.py in put_matrix(self, dataset, matrix, pad)
906 )
907 if status != 0:
--> 908 raise GMTCLibError("Failed to put matrix of type {}.".format(matrix.dtype))
909
910 def write_data(self, family, geometry, mode, wesn, output, data):
GMTCLibError: Failed to put matrix of type object.
System information
Please paste the output of python -c "import pygmt; pygmt.show_versions()"
:
PyGMT information:
version: v0.1.2+55.g6deb388
System information:
python: 3.7.8 | packaged by conda-forge | (default, Jul 31 2020, 02:25:08) [GCC 7.5.0]
executable: ~/miniconda3/envs/pygmt/bin/python
machine: Linux-4.19.0-8-amd64-x86_64-with-debian-10.5
Dependency information:
numpy: 1.19.1
pandas: 1.1.1
xarray: 0.16.0
netCDF4: 1.5.3
packaging: 20.4
ghostscript: 9.27
gmt: None
GMT library information:
binary dir: ~/miniconda3/envs/pygmt/bin
cores: 2
grid layout: rows
library path: ~/miniconda3/envs/pygmt/lib/libgmt.so
padding: 2
plugin dir: ~/miniconda3/envs/pygmt/lib/gmt/plugins
share dir: ~/miniconda3/envs/pygmt/share/gmt
version: 6.1.1
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
pandas rolling mean didn't work for my time data series
Your construction of the DataFrame has no index (defaults to ints) and has a column of Timestamp and a column of floats.
Read more >Working with datetime in Pandas DataFrame | by B. Chen
This solution normally requires start_date , end_date and date column to be datetime format. And in fact, this solution is slow when you...
Read more >How to handle time series data with ease? - Pandas
I want to work with the dates in the column datetime as datetime objects ... What is the start and end date of...
Read more >The Pandas DataFrame: Make Working With Data Delightful
In this tutorial, you'll get started with Pandas DataFrames, which are powerful and widely used two-dimensional data structures. You'll learn how to perform ......
Read more >Pandas for time series data — tricks and tips - Adrian G
Calculate a running delta between date column and a given date (eg here we use first date in the date column as the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
FYI, https://github.com/GenericMappingTools/gmt/issues/4241 has been magically resolved, so this issue can be resolved when PyGMT bumps the minimum version to GMT 6.2.0!
Fixed by https://github.com/GenericMappingTools/gmt/pull/4849