From 4074168429d4298b5a8ff0bc9ce02e6a27afb352 Mon Sep 17 00:00:00 2001 From: lxcxjxhx Date: Wed, 29 Jul 2026 21:58:36 +0800 Subject: [PATCH] fix: replace deprecated pandas as_matrix() with to_numpy() DataFrame.as_matrix() was deprecated in pandas 0.25.0 and removed in later versions. Replace all occurrences with to_numpy() in the TimeSeriesTensor._df2tensors() method across 5 files. --- 7-TimeSeries/1-Introduction/solution/common/utils.py | 4 ++-- 7-TimeSeries/1-Introduction/working/common/utils.py | 4 ++-- 7-TimeSeries/2-ARIMA/solution/common/utils.py | 4 ++-- 7-TimeSeries/2-ARIMA/working/common/utils.py | 4 ++-- 7-TimeSeries/common/utils.py | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/7-TimeSeries/1-Introduction/solution/common/utils.py b/7-TimeSeries/1-Introduction/solution/common/utils.py index 62684f96a..151f687a9 100644 --- a/7-TimeSeries/1-Introduction/solution/common/utils.py +++ b/7-TimeSeries/1-Introduction/solution/common/utils.py @@ -120,13 +120,13 @@ class TimeSeriesTensor(UserDict): inputs = {} y = dataframe['target'] - y = y.as_matrix() + y = y.to_numpy() inputs['target'] = y for name, structure in self.tensor_structure.items(): rng = structure[0] cols = structure[1] - tensor = dataframe[name][cols].as_matrix() + tensor = dataframe[name][cols].to_numpy() if rng is None: tensor = tensor.reshape(tensor.shape[0], len(cols)) else: diff --git a/7-TimeSeries/1-Introduction/working/common/utils.py b/7-TimeSeries/1-Introduction/working/common/utils.py index 62684f96a..151f687a9 100644 --- a/7-TimeSeries/1-Introduction/working/common/utils.py +++ b/7-TimeSeries/1-Introduction/working/common/utils.py @@ -120,13 +120,13 @@ class TimeSeriesTensor(UserDict): inputs = {} y = dataframe['target'] - y = y.as_matrix() + y = y.to_numpy() inputs['target'] = y for name, structure in self.tensor_structure.items(): rng = structure[0] cols = structure[1] - tensor = dataframe[name][cols].as_matrix() + tensor = dataframe[name][cols].to_numpy() if rng is None: tensor = tensor.reshape(tensor.shape[0], len(cols)) else: diff --git a/7-TimeSeries/2-ARIMA/solution/common/utils.py b/7-TimeSeries/2-ARIMA/solution/common/utils.py index 62684f96a..151f687a9 100644 --- a/7-TimeSeries/2-ARIMA/solution/common/utils.py +++ b/7-TimeSeries/2-ARIMA/solution/common/utils.py @@ -120,13 +120,13 @@ class TimeSeriesTensor(UserDict): inputs = {} y = dataframe['target'] - y = y.as_matrix() + y = y.to_numpy() inputs['target'] = y for name, structure in self.tensor_structure.items(): rng = structure[0] cols = structure[1] - tensor = dataframe[name][cols].as_matrix() + tensor = dataframe[name][cols].to_numpy() if rng is None: tensor = tensor.reshape(tensor.shape[0], len(cols)) else: diff --git a/7-TimeSeries/2-ARIMA/working/common/utils.py b/7-TimeSeries/2-ARIMA/working/common/utils.py index 62684f96a..151f687a9 100644 --- a/7-TimeSeries/2-ARIMA/working/common/utils.py +++ b/7-TimeSeries/2-ARIMA/working/common/utils.py @@ -120,13 +120,13 @@ class TimeSeriesTensor(UserDict): inputs = {} y = dataframe['target'] - y = y.as_matrix() + y = y.to_numpy() inputs['target'] = y for name, structure in self.tensor_structure.items(): rng = structure[0] cols = structure[1] - tensor = dataframe[name][cols].as_matrix() + tensor = dataframe[name][cols].to_numpy() if rng is None: tensor = tensor.reshape(tensor.shape[0], len(cols)) else: diff --git a/7-TimeSeries/common/utils.py b/7-TimeSeries/common/utils.py index 4ab7623fe..801839c23 100644 --- a/7-TimeSeries/common/utils.py +++ b/7-TimeSeries/common/utils.py @@ -122,13 +122,13 @@ class TimeSeriesTensor(UserDict): inputs = {} y = dataframe['target'] - y = y.as_matrix() + y = y.to_numpy() inputs['target'] = y for name, structure in self.tensor_structure.items(): rng = structure[0] cols = structure[1] - tensor = dataframe[name][cols].as_matrix() + tensor = dataframe[name][cols].to_numpy() if rng is None: tensor = tensor.reshape(tensor.shape[0], len(cols)) else: