Skip to content

Conversation

seisman
Copy link
Member

@seisman seisman commented May 27, 2025

Pandas 3.x changes the string dtype representation from string[python] to <StringDtype(storage='python', na_value=<NA>)> in pandas-dev/pandas#61148, which causes one failure in the GMT Dev Tests CI (https://github.com/GenericMappingTools/pygmt/actions/runs/15244024455/job/42867873374):

___________ [doctest] pygmt.datatypes.dataset._GMT_DATASET.to_pandas ___________
233 >>> text
234 array(['TEXT1 TEXT23', 'TEXT4 TEXT567', 'TEXT8 TEXT90',
235    'TEXT123 TEXT456789'], dtype='<U18')
236 >>> df
237    col1  col2  col3              colstr
238 0   1.0   2.0   3.0        TEXT1 TEXT23
239 1   4.0   5.0   6.0       TEXT4 TEXT567
240 2   7.0   8.0   9.0        TEXT8 TEXT90
241 3  10.0  11.0  12.0  TEXT123 TEXT456789
242 >>> df.dtypes.to_list()
Expected:
    [dtype('float64'), dtype('float64'), dtype('float64'), string[python]]
Got:
    [dtype('float64'), dtype('float64'), dtype('float64'), <StringDtype(storage='python', na_value=<NA>)>]

This PR refactors the doctest so that it passes for both pandas 2.x and dev.

Triggerd "GMT Dev Tests" runs at https://github.com/GenericMappingTools/pygmt/actions/runs/15267534336.

@seisman seisman added this to the 0.16.0 milestone May 27, 2025
@seisman seisman added maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog needs review This PR has higher priority and needs review. labels May 27, 2025
@seisman seisman added final review call This PR requires final review and approval from a second reviewer and removed needs review This PR has higher priority and needs review. labels May 28, 2025
@seisman seisman removed the final review call This PR requires final review and approval from a second reviewer label Jun 2, 2025
@seisman seisman merged commit 851ae08 into main Jun 2, 2025
23 of 24 checks passed
@seisman seisman deleted the fix/pandas-str-dtype branch June 2, 2025 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant