From 3f72c40897a80132099729d5d00a6718e76e0e9e Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Wed, 13 Nov 2024 13:37:50 +0100 Subject: [PATCH] Support pandas v2 (#1671) --- CHANGES.md | 5 +++++ augur/parse.py | 6 +++--- setup.py | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 297f92ba2..7cfe82974 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,11 +4,14 @@ ### Features +- support pandas v2. [#1671] (@corneliusroemer and @victorlin) - curate: change output metadata to [RFC 4180 CSV-like TSVs][] to match the TSV format output by other Augur subcommands and the Nextstrain ecosystem as discussed in [#1566][]. [#1565][] (@joverlee521) + [#1565]: https://github.com/nextstrain/augur/pull/1565 [#1566]: https://github.com/nextstrain/augur/issues/1566 [RFC 4180 CSV-like TSVs]: https://datatracker.ietf.org/doc/html/rfc4180 +[#1671]: https://github.com/nextstrain/augur/pull/1671 ## 26.1.0 (12 November 2024) @@ -22,7 +25,9 @@ * index: Previously specifying a directory that does not exist in the path to `--output` would result in an incorrect error stating that the input file does not exist. It now shows the correct path responsible for the error. [#1644][] (@victorlin) * curate format-dates: Update help docs and improve failure messages to show use of `--expected-date-formats`. [#1653][] (@joverlee521) +* parse: fix test failure with pandas 2.2. [#1471] (@emollier) +[#1471]: https://github.com/nextstrain/augur/pull/1471 [#1644]: https://github.com/nextstrain/augur/issues/1644 [#1547]: https://github.com/nextstrain/augur/pull/1547 [#1653]: https://github.com/nextstrain/augur/pull/1653 diff --git a/augur/parse.py b/augur/parse.py index 1aaeec5b5..7e1a094ee 100644 --- a/augur/parse.py +++ b/augur/parse.py @@ -25,7 +25,7 @@ '\\': '_'} ) -def fix_dates(d, dayfirst=True): +def fix_dates(d: str, dayfirst: bool = True) -> str: ''' attempt to parse a date string using pandas date parser. If ambiguous, the argument 'dayfirst' determines whether month or day is assumed to be @@ -35,7 +35,7 @@ def fix_dates(d, dayfirst=True): try: try: # pandas <= 2.1 - from pandas.core.tools.datetimes import parsing + from pandas.core.tools.datetimes import parsing # type: ignore except ImportError: # pandas >= 2.2 from pandas._libs.tslibs import parsing @@ -44,7 +44,7 @@ def fix_dates(d, dayfirst=True): results = parsing.parse_datetime_string_with_reso(d, dayfirst=dayfirst) except AttributeError: # pandas 1.x - results = parsing.parse_time_string(d, dayfirst=dayfirst) + results = parsing.parse_time_string(d, dayfirst=dayfirst) # type: ignore if len(results) == 2: dto, res = results else: diff --git a/setup.py b/setup.py index a924fe534..863e67fa0 100644 --- a/setup.py +++ b/setup.py @@ -61,7 +61,7 @@ "networkx >= 2.5, <4", "numpy ==1.*", "packaging >=19.2", - "pandas >=1.0.0, ==1.*", + "pandas >=1.0.0, <3", "phylo-treetime >=0.11.2, <0.12", "pyfastx >=1.0.0, <3.0", "python_calamine >=0.2.0", @@ -76,7 +76,7 @@ "freezegun >=0.3.15", "mypy", "nextstrain-sphinx-theme >=2022.5", - "pandas-stubs >=1.0.0, ==1.*", + "pandas-stubs >=1.0.0, <3", "pylint >=1.7.6", "pytest >=5.4.1", "pytest-cov >=2.8.1",