Skip to content

Conversation

@geekalaa
Copy link
Contributor

Description

Replace deprecated fillna(method="ffill"/"bfill") calls with modern pandas ffill() and bfill() methods to fix FutureWarnings in pandas 2.x.

This addresses the pandas deprecation warnings portion of issue #1981. Other issues (date parsing, type conversion, timezone handling) will be addressed in separate commits.

Motivation and Context

How Has This Been Tested?

  • Pass the test by running: pytest qlib/tests/test_all_pipeline.py under upper directory of qlib.
  • Verified no deprecation warnings with updated methods
  • Black formatting applied for code compliance

Screenshots of Test Results (if appropriate):

  1. Pipeline test: ✅ All 3 tests passed
  2. Deprecation test: ✅ No FutureWarnings with new methods

Types of changes

  • Fix bugs

Files Changed:

  • qlib/backtest/profit_attribution.py - 2 fixes
  • qlib/contrib/ops/high_freq.py - 2 fixes
  • qlib/contrib/report/analysis_position/parse_position.py - 1 fix
  • qlib/utils/resam.py - 1 fix
  • scripts/data_collector/baostock_5min/collector.py - 1 fix
  • scripts/data_collector/yahoo/collector.py - 2 fixes
  • Plus black formatting compliance fixes

  Replace deprecated fillna(method="ffill"/"bfill") calls with modern
  pandas ffill() and bfill() methods to fix FutureWarnings in pandas 2.x.

  Also includes black formatting fixes for compliance.

  This addresses the pandas deprecation warnings portion of issue microsoft#1981.
  Other issues (date parsing, type conversion, timezone handling) will be
  addressed in separate commits.

  Fixes:
  - Yahoo collector: 2 instances in calc_change() and adjusted_price()
  - BaoStock collector: 1 instance in calc_change()
  - Core utils: resam.py fillna operations
  - Backtest: profit_attribution.py stock data processing
  - High-freq ops: FFillNan and BFillNan operators
  - Position analysis: parse_position.py weight processing

  Partially addresses GitHub issue microsoft#1981
@github-actions github-actions bot added the waiting for triage Cannot auto-triage, wait for triage. label Aug 16, 2025
@geekalaa
Copy link
Contributor Author

@microsoft-github-policy-service agree

@geekalaa geekalaa changed the title fix: replace deprecated pandas fillna(method=) with ffill()/bfill() fix: replace deprecated pandas fillna(method=) with ffill()/bfill() Aug 16, 2025
@SunsetWolf
Copy link
Collaborator

Hi, @geekalaa
Please pull the latest code from the main branch, it will fix the CI.

@geekalaa
Copy link
Contributor Author

Hello @SunsetWolf,

Done ✅.

@SunsetWolf
Copy link
Collaborator

Hi, @geekalaa
It looks great now, thanks for contributing to qlib.

@SunsetWolf SunsetWolf merged commit 7095e75 into microsoft:main Aug 19, 2025
95 of 102 checks passed
@SunsetWolf SunsetWolf removed the waiting for triage Cannot auto-triage, wait for triage. label Aug 19, 2025
next-page117 pushed a commit to next-page117/qlib that referenced this pull request Sep 6, 2025
…icrosoft#1987)

* fix: replace deprecated pandas fillna(method=) with ffill()/bfill()

  Replace deprecated fillna(method="ffill"/"bfill") calls with modern
  pandas ffill() and bfill() methods to fix FutureWarnings in pandas 2.x.

  Also includes black formatting fixes for compliance.

  This addresses the pandas deprecation warnings portion of issue microsoft#1981.
  Other issues (date parsing, type conversion, timezone handling) will be
  addressed in separate commits.

  Fixes:
  - Yahoo collector: 2 instances in calc_change() and adjusted_price()
  - BaoStock collector: 1 instance in calc_change()
  - Core utils: resam.py fillna operations
  - Backtest: profit_attribution.py stock data processing
  - High-freq ops: FFillNan and BFillNan operators
  - Position analysis: parse_position.py weight processing

  Partially addresses GitHub issue microsoft#1981

* lint with black

* lint with black

* limit minimum version of pandas

* limit minimum version of pandas

---------

Co-authored-by: Linlang <Lv.Linlang@hotmail.com>
gaogen123 pushed a commit to gaogen123/qlib that referenced this pull request Sep 13, 2025
…icrosoft#1987)

* fix: replace deprecated pandas fillna(method=) with ffill()/bfill()

  Replace deprecated fillna(method="ffill"/"bfill") calls with modern
  pandas ffill() and bfill() methods to fix FutureWarnings in pandas 2.x.

  Also includes black formatting fixes for compliance.

  This addresses the pandas deprecation warnings portion of issue microsoft#1981.
  Other issues (date parsing, type conversion, timezone handling) will be
  addressed in separate commits.

  Fixes:
  - Yahoo collector: 2 instances in calc_change() and adjusted_price()
  - BaoStock collector: 1 instance in calc_change()
  - Core utils: resam.py fillna operations
  - Backtest: profit_attribution.py stock data processing
  - High-freq ops: FFillNan and BFillNan operators
  - Position analysis: parse_position.py weight processing

  Partially addresses GitHub issue microsoft#1981

* lint with black

* lint with black

* limit minimum version of pandas

* limit minimum version of pandas

---------

Co-authored-by: Linlang <Lv.Linlang@hotmail.com>
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.

2 participants