Skip to content

Commit cd12048

Browse files
committed
MAINT: ensure backward compat with pandas
1 parent ae06ffa commit cd12048

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

pysatNASA/instruments/methods/cdaweb.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import datetime as dt
1919
import numpy as np
2020
import os
21+
from packaging.version import Version as pack_ver
2122
import pandas as pds
2223
import requests
2324
import tempfile
@@ -845,9 +846,15 @@ def list_remote_files(tag='', inst_id='', start=None, stop=None,
845846
if 'year' in search_dir['keys']:
846847
url_list = []
847848
if 'month' in search_dir['keys']:
849+
# TODO(#242): remove if/else once support for older pandas is
850+
# dropped.
851+
if pack_ver(pds.__version__) >= pack_ver('2.2.0'):
852+
freq_key = 'ME'
853+
else:
854+
freq_key = 'M'
848855
search_times = pds.date_range(start,
849856
stop + pds.DateOffset(months=1),
850-
freq='ME')
857+
freq=freq_key)
851858
for time in search_times:
852859
subdir = format_dir.format(year=time.year, month=time.month)
853860
url_list.append('/'.join((remote_url, subdir)))
@@ -857,9 +864,16 @@ def list_remote_files(tag='', inst_id='', start=None, stop=None,
857864
+ pds.DateOffset(days=1),
858865
freq='D')
859866
else:
867+
868+
# TODO(#242): remove if/else once support for older pandas
869+
# is dropped.
870+
if pack_ver(pds.__version__) >= pack_ver('2.2.0'):
871+
freq_key = 'YE'
872+
else:
873+
freq_key = 'Y'
860874
search_times = pds.date_range(start, stop
861875
+ pds.DateOffset(years=1),
862-
freq='YE')
876+
freq=freq_key)
863877
for time in search_times:
864878
doy = int(time.strftime('%j'))
865879
subdir = format_dir.format(year=time.year, day=doy)

0 commit comments

Comments
 (0)