Quellcode durchsuchen

Replace deprecated pandas .ix

bletham vor 8 Jahren
Ursprung
Commit
047a0c3c23
1 geänderte Dateien mit 9 neuen und 7 gelöschten Zeilen
  1. 9 7
      python/fbprophet/forecaster.py

+ 9 - 7
python/fbprophet/forecaster.py

@@ -296,7 +296,9 @@ class Prophet(object):
                     .round()
                     .astype(np.int)
                 )
-                self.changepoints = self.history.ix[cp_indexes]['ds'].tail(-1)
+                self.changepoints = (
+                    self.history.iloc[cp_indexes]['ds'].tail(-1)
+                )
             else:
                 # set empty changepoints
                 self.changepoints = []
@@ -615,9 +617,9 @@ class Prophet(object):
         function.
         """
         i0, i1 = df['ds'].idxmin(), df['ds'].idxmax()
-        T = df['t'].ix[i1] - df['t'].ix[i0]
-        k = (df['y_scaled'].ix[i1] - df['y_scaled'].ix[i0]) / T
-        m = df['y_scaled'].ix[i0] - k * df['t'].ix[i0]
+        T = df['t'].iloc[i1] - df['t'].iloc[i0]
+        k = (df['y_scaled'].iloc[i1] - df['y_scaled'].iloc[i0]) / T
+        m = df['y_scaled'].iloc[i0] - k * df['t'].iloc[i0]
         return (k, m)
 
     @staticmethod
@@ -639,11 +641,11 @@ class Prophet(object):
         function.
         """
         i0, i1 = df['ds'].idxmin(), df['ds'].idxmax()
-        T = df['t'].ix[i1] - df['t'].ix[i0]
+        T = df['t'].iloc[i1] - df['t'].iloc[i0]
 
         # Force valid values, in case y > cap.
-        r0 = max(1.01, df['cap_scaled'].ix[i0] / df['y_scaled'].ix[i0])
-        r1 = max(1.01, df['cap_scaled'].ix[i1] / df['y_scaled'].ix[i1])
+        r0 = max(1.01, df['cap_scaled'].iloc[i0] / df['y_scaled'].iloc[i0])
+        r1 = max(1.01, df['cap_scaled'].iloc[i1] / df['y_scaled'].iloc[i1])
 
         if abs(r0 - r1) <= 0.01:
             r0 = 1.05 * r0