From 7b11575ee6256539db8e94c377212806adc6ecc4 Mon Sep 17 00:00:00 2001 From: John Huddleston Date: Tue, 11 Aug 2020 12:37:25 -0700 Subject: [PATCH] Update call and expected returns from pandas's parse_time_string The API for `parse_time_string` changed recently to only return two values instead of three [1] and the function is no longer importable from the pandas core tools datetimes module as of version 1.1.0. Instead, we have to import the `parsing` module that exposes the `parse_time_string` function. This commit supports both the previous and new API's return values. This bug should affect anyone trying to run augur with pandas 1.1.0 but not users running earlier versions of pandas. [1] https://github.com/pandas-dev/pandas/pull/31065 --- augur/parse.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/augur/parse.py b/augur/parse.py index dd35175aa..02e1b82f5 100644 --- a/augur/parse.py +++ b/augur/parse.py @@ -25,7 +25,13 @@ def fix_dates(d, dayfirst=True): On failure to parse the date, the function will return the input. ''' try: - dto, _, res = pd.core.tools.datetimes.parse_time_string(d, dayfirst=dayfirst) + from pandas.core.tools.datetimes import parsing + results = parsing.parse_time_string(d, dayfirst=dayfirst) + if len(results) == 2: + dto, res = results + else: + dto, _, res = results + if res == 'year': return "%d-XX-XX"%dto.year elif res == 'month':