Skip to content

Commit

Permalink
Merge pull request #89 from ioos/numpy-bump-deprecations
Browse files Browse the repository at this point in the history
Fix weekofyear accessor deprecation
  • Loading branch information
kwilcox authored Oct 17, 2022
2 parents 5439fda + 60a2167 commit 569d29f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ioos_qc/qartod.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ class QartodFlags(object):
FLAGS = QartodFlags # Default name for all check modules
NOTEVAL_VALUE = QartodFlags.UNKNOWN

WEEK_PERIODS = [
'week',
'weekofyear',
]

span = namedtuple('Span', 'minv maxv')


Expand Down Expand Up @@ -342,7 +347,11 @@ def check(self, tinp, inp, zinp):
# If a period is defined, extract the attribute from the
# pd.DatetimeIndex object before comparison. The min and max
# values are in this period unit already.
tinp_copy = getattr(tinp, m.period).to_series()
if m.period in WEEK_PERIODS:
# The weekofyear accessor was depreacated
tinp_copy = pd.Index(tinp.isocalendar().week, dtype='int64')
else:
tinp_copy = getattr(tinp, m.period).to_series()
else:
# If a period isn't defined, make a new Timestamp object
# to align with the above name 'tinp_copy'
Expand Down

0 comments on commit 569d29f

Please sign in to comment.