Skip to content

Deprecated pandas as_matrix() usage in TimeSeries utils #1012

Description

Problem

The \TimeSeriesTensor._df2tensors()\ method in \7-TimeSeries/common/utils.py\ (and its copies in lesson subdirectories) uses the deprecated \DataFrame.as_matrix()\ method, which was removed in pandas 0.25.0+.

Current Behavior

Running the time series lessons with modern pandas versions raises:
\
AttributeError: 'DataFrame' object has no attribute 'as_matrix'
\\

Expected Behavior

The code should use the modern \ o_numpy()\ API, which has been the recommended approach since pandas 0.25.0.

Proposed Fix

Replace all occurrences of .as_matrix()\ with .to_numpy()\ in:

  • \7-TimeSeries/common/utils.py\
  • \7-TimeSeries/1-Introduction/working/common/utils.py\
  • \7-TimeSeries/1-Introduction/solution/common/utils.py\
  • \7-TimeSeries/2-ARIMA/working/common/utils.py\
  • \7-TimeSeries/2-ARIMA/solution/common/utils.py\

Environment

  • pandas >= 0.25.0
  • Python 3.7+

Additional Context

This is a straightforward API modernization fix that ensures compatibility with current pandas versions while maintaining backward compatibility with the tutorial's educational goals.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions