Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pygmt/src/x2sys_cross.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def tempfile_from_dftrack(track, suffix):
sep="\t",
index=False,
na_rep="NaN", # write a NaN value explicitly instead of a blank string
date_format="%Y-%m-%dT%H:%M:%S.%fZ",
date_format="%Y-%m-%dT%H:%M:%S.%fZ", # ISO8601 format
)
yield tmpfilename
finally:
Expand Down Expand Up @@ -235,6 +235,7 @@ def x2sys_cross(tracks=None, outfile=None, **kwargs):
header=2, # Column names are on 2nd row
comment=">", # Skip the 3rd row with a ">"
parse_dates=[2, 3], # Datetimes on 3rd and 4th column
date_format="ISO8601",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This date_format parameter only works with pandas>=2.0. Do we want to set a minimum version of pandas, or make things backwards compatible with pandas=1.x?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make things backwards compatible with pandas=1.x?

This would be better.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, compatibility with pandas=1.x and 2.x should be done in fa2a6d3 and 146a7f4. I've also changed ci_tests_legacy to run with pandas<2 as a check.

)
# Remove the "# " from "# x" in the first column
table = table.rename(columns={table.columns[0]: table.columns[0][2:]})
Expand Down
2 changes: 1 addition & 1 deletion pygmt/tests/test_x2sys_cross.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def test_x2sys_cross_input_two_dataframes(mock_x2sys_home):
for i in range(2):
np.random.seed(seed=i)
track = pd.DataFrame(data=np.random.rand(10, 3), columns=("x", "y", "z"))
track["time"] = pd.date_range(start=f"2020-{i}1-01", periods=10, freq="ms")
track["time"] = pd.date_range(start=f"2020-{i}1-01", periods=10, freq="min")
tracks.append(track)

output = x2sys_cross(tracks=tracks, tag=tag, coe="e")
Expand Down