Repository: FZJ-IEK3-VSA/tsam

Issue:
Error when creating typical periods which are longer than 24h (e.g. 48h or 72h)
I am using version 2.0.1 of Pandas. Unfortunately, as of version 1.4.0, DataFrame.append() has been deprecated. So now I get an error message when I try to create typical periods longer than 24h, for example, typical periods that are 48h long. 

Discussion:

Patch:
diff --git a/tsam/periodAggregation.py b/tsam/periodAggregation.py
index 768d16f..52b1128 100644
--- a/tsam/periodAggregation.py
+++ b/tsam/periodAggregation.py
@@ -49,7 +49,7 @@ def aggregatePeriods(
             clusterOrder.append(
                 [n_clusters - 1] * int(n_sets - cluster_size * n_clusters)
             )
-        clusterOrder = np.hstack(np.array(clusterOrder))
+        clusterOrder = np.hstack(np.array(clusterOrder, dtype=object))
         clusterCenters, clusterCenterIndices = representations(
             candidates,
             clusterOrder,
diff --git a/tsam/timeseriesaggregation.py b/tsam/timeseriesaggregation.py
index b1d0804..5dd3768 100644
--- a/tsam/timeseriesaggregation.py
+++ b/tsam/timeseriesaggregation.py
@@ -61,7 +61,7 @@ def unstackToPeriods(timeSeries, timeStepsPerPeriod):
         rep_data = unstackedTimeSeries.head(attached_timesteps)
 
         # append them at the end of the time series
-        unstackedTimeSeries = unstackedTimeSeries.append(rep_data, ignore_index=False)
+        unstackedTimeSeries = pd.concat([unstackedTimeSeries, rep_data])
 
     # create period and step index
     for ii in range(0, len(unstackedTimeSeries)):


Test patch:
diff --git a/test/test_cluster_order.py b/test/test_cluster_order.py
index 3fbbe4c..0948755 100644
--- a/test/test_cluster_order.py
+++ b/test/test_cluster_order.py
@@ -81,19 +81,19 @@ def test_cluster_order():
 
     # sort the typical days in order to avoid error assertion due to different order
     sortedDaysOrig1 = (
-        orig_raw_predefClusterOrder.sum(axis=0, level=0).sort_values("GHI").index
+        orig_raw_predefClusterOrder.groupby(level=0).sum().sort_values("GHI").index
     )
     sortedDaysTest1 = (
-        typPeriods_predefClusterOrder.sum(axis=0, level=0).sort_values("GHI").index
+        typPeriods_predefClusterOrder.groupby(level=0).sum().sort_values("GHI").index
     )
 
     sortedDaysOrig2 = (
-        orig_raw_predefClusterOrderAndClusterCenters.sum(axis=0, level=0)
+        orig_raw_predefClusterOrderAndClusterCenters.groupby(level=0).sum()
         .sort_values("GHI")
         .index
     )
     sortedDaysTest2 = (
-        typPeriods_predefClusterOrderAndClusterCenters.sum(axis=0, level=0)
+        typPeriods_predefClusterOrderAndClusterCenters.groupby(level=0).sum()
         .sort_values("GHI")
         .index
     )
diff --git a/test/test_hierarchical.py b/test/test_hierarchical.py
index 7025ce3..40d2f88 100644
--- a/test/test_hierarchical.py
+++ b/test/test_hierarchical.py
@@ -42,8 +42,8 @@ def test_hierarchical():
     print("Clustering took " + str(time.time() - starttime))
 
     # sort the typical days in order to avoid error assertion due to different order
-    sortedDaysOrig = orig_raw.sum(axis=0, level=0).sort_values("GHI").index
-    sortedDaysTest = typPeriods.sum(axis=0, level=0).sort_values("GHI").index
+    sortedDaysOrig = orig_raw.groupby(level=0).sum().sort_values("GHI").index
+    sortedDaysTest = typPeriods.groupby(level=0).sum().sort_values("GHI").index
 
     # rearange their order
     orig = orig_raw[typPeriods.columns].unstack().loc[sortedDaysOrig, :].stack()
diff --git a/test/test_k_medoids.py b/test/test_k_medoids.py
index 5c53de7..b373dbf 100644
--- a/test/test_k_medoids.py
+++ b/test/test_k_medoids.py
@@ -39,8 +39,8 @@ def test_k_medoids():
     print("Clustering took " + str(time.time() - starttime))
 
     # sort the typical days in order to avoid error assertion due to different order
-    sortedDaysOrig = orig_raw.sum(axis=0, level=0).sort_values("GHI").index
-    sortedDaysTest = typPeriods.sum(axis=0, level=0).sort_values("GHI").index
+    sortedDaysOrig = orig_raw.groupby(level=0).sum().sort_values("GHI").index
+    sortedDaysTest = typPeriods.groupby(level=0).sum().sort_values("GHI").index
 
     # rearange their order
     orig = orig_raw[typPeriods.columns].unstack().loc[sortedDaysOrig, :].stack()
diff --git a/test/test_segmentation.py b/test/test_segmentation.py
index 894ce4d..7dfd99b 100644
--- a/test/test_segmentation.py
+++ b/test/test_segmentation.py
@@ -41,8 +41,8 @@ def test_segmentation():
     print("Clustering took " + str(time.time() - starttime))
 
     # sort the typical days in order to avoid error assertion due to different order
-    sortedDaysOrig = orig_raw.sum(axis=0, level=0).sort_values("GHI").index
-    sortedDaysTest = typPeriods.sum(axis=0, level=0).sort_values("GHI").index
+    sortedDaysOrig = orig_raw.groupby(level=0).sum().sort_values("GHI").index
+    sortedDaysTest = typPeriods.groupby(level=0).sum().sort_values("GHI").index
 
     # rearange their order
     orig = orig_raw[typPeriods.columns].unstack().loc[sortedDaysOrig, :].stack()