Skip to content

fix: replace deprecated pandas as_matrix() with to_numpy() - #1013

Closed
lxcxjxhx wants to merge 1 commit into
microsoft:mainfrom
lxcxjxhx:fix/deprecated-pandas-as-matrix
Closed

fix: replace deprecated pandas as_matrix() with to_numpy()#1013
lxcxjxhx wants to merge 1 commit into
microsoft:mainfrom
lxcxjxhx:fix/deprecated-pandas-as-matrix

Conversation

@lxcxjxhx

Copy link
Copy Markdown

Description

This PR fixes deprecated pandas API usage in the TimeSeries lessons by replacing as_matrix() with to_numpy().

Changes

  • Replace DataFrame.as_matrix() with DataFrame.to_numpy() in TimeSeriesTensor._df2tensors()
  • Affected files:
    • 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

Motivation

DataFrame.as_matrix() was deprecated in pandas 0.25.0 and removed in later versions. Students running these lessons with modern pandas encounter AttributeError: 'DataFrame' object has no attribute 'as_matrix'.

Testing

  • Verified syntax correctness
  • to_numpy() is the recommended replacement per pandas documentation
  • Maintains backward compatibility with pandas 0.25.0+

Related Issues

Fixes #1012


Note: Local environment limitations, relying on CI/CD automated testing for full validation.

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.
@lxcxjxhx lxcxjxhx closed this by deleting the head repository Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecated pandas as_matrix() usage in TimeSeries utils

1 participant