Skip to content

Commit

Permalink
[DEPR] remove pd.index.is_all_dates
Browse files Browse the repository at this point in the history
  • Loading branch information
kavvkon committed Feb 3, 2024
1 parent ab91ca6 commit 8772445
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion enlopy/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def gen_demand_response(Load, percent_peak_hrs_month=0.03, percent_shifted=0.05,
Return:
pd.Series: New load profile with reduced peaks. The peak can be shifted to low load hours or shaved
"""
if not Load.index.is_all_dates:
if not isinstance(Load.index, pd.DatetimeIndex):
print ('Need date Time indexed series. Trying to force one.')
Load = clean_convert(Load, force_timed_index=True)
demand = Load
Expand Down
4 changes: 2 additions & 2 deletions enlopy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def clean_convert(x, force_timed_index=True, always_df=False, **kwargs):
elif isinstance(x, pd.Series):
if always_df:
x = pd.DataFrame(x)
if x.index.is_all_dates:
if isinstance(x.index, pd.DatetimeIndex):
return x
else: # if not datetime index
if force_timed_index:
Expand All @@ -137,7 +137,7 @@ def clean_convert(x, force_timed_index=True, always_df=False, **kwargs):
if x.shape[1] == 1 and not always_df:
return clean_convert(x.squeeze(), force_timed_index, always_df, **kwargs)
else:
if force_timed_index and not x.index.is_all_dates:
if force_timed_index and not isinstance(x.index, pd.DatetimeIndex):
return make_timeseries(x, **kwargs)
else: # does not require datetimeindex
return x
Expand Down
8 changes: 4 additions & 4 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,22 @@ class Test_clean_convert():
def test_ndarray_to_series_indexed(self):
a = np.random.rand(8760)
b = clean_convert(a, force_timed_index=True, always_df=False)
assert isinstance(b, pd.Series) and b.index.is_all_dates
assert isinstance(b, pd.Series) and isinstance(b.index, pd.DatetimeIndex)

def test_ndarray_to_df_indexed(self):
a = np.random.rand(8760)
b = clean_convert(a, force_timed_index=True, always_df=True)
assert isinstance(b, pd.DataFrame) and b.index.is_all_dates
assert isinstance(b, pd.DataFrame) and isinstance(b.index, pd.DatetimeIndex)

def test_1d_series_to_frame(self):
a = pd.Series(np.random.rand(8760))
b = clean_convert(a, force_timed_index=True, always_df=True)
assert isinstance(b, pd.DataFrame) and b.index.is_all_dates
assert isinstance(b, pd.DataFrame) and isinstance(b.index, pd.DatetimeIndex)

def test_2d_ndarray_to_df_indexed(self):
a = np.random.rand(8760, 2)
b = clean_convert(a, force_timed_index=True, always_df=True)
assert isinstance(b, pd.DataFrame) and b.index.is_all_dates
assert isinstance(b, pd.DataFrame) and isinstance(b.index, pd.DatetimeIndex)

def test_list_to_series(self):
a = list(np.random.rand(8760))
Expand Down

0 comments on commit 8772445

Please sign in to comment.