Skip to content

fix: Replace positional Series indexing with .iloc in PSARIndicator - #370

Open
dwaddle wants to merge 1 commit into
bukosabino:masterfrom
dwaddle:fix-pandas-positional-indexing-deprecation
Open

dwaddle wants to merge 1 commit into
bukosabino:masterfrom
dwaddle:fix-pandas-positional-indexing-deprecation

Conversation

@dwaddle

@dwaddle dwaddle commented Sep 10, 2026

Copy link
Copy Markdown

Fixes a FutureWarning (and eventual crash in future pandas versions) in PSARIndicator._run() in ta/trend.py.

Line 1030 used `self._psar[i] = high2` (deprecated positional integer indexing on a pandas Series). All 12 surrounding assignments in the same method already correctly use `.iloc[i]`. This single inconsistent line caused the warning reported in multiple issues.

## Fixes
Closes #354
Closes #357
Closes #348

## Change
```python
# Before (deprecated)
self._psar[i] = high2

# After
self._psar.iloc[i] = high2

Testing

Manually verified PSARIndicator runs without FutureWarning on a 60-bar OHLC dataset containing a trend reversal (which triggers the affected code path).

…o resolve pandas FutureWarning

Fixes bukosabino#354, bukosabino#357, bukosabino#348

In PSARIndicator._run(), line 1030 used self._psar[i] = high2 (positional
integer indexing on a pandas Series), which triggers a FutureWarning in
pandas >= 2.0 and Python 3.12+. All surrounding code in the same method
already correctly uses .iloc[i]. This single inconsistent line caused the
warning reported in issues bukosabino#354, bukosabino#357 and bukosabino#348.
@dwaddle

dwaddle commented Sep 10, 2026

Copy link
Copy Markdown
Author

"Note: the ci/circleci: test_py36 failure is pre-existing and also fails on the current master
│ branch (verified via the GitHub status API). Our change is limited to a single line —
replacing
│ self._psar[i] with self._psar.iloc[i] — which is identical in behavior but correct for pandas
│ >= 2.0."

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.

1 participant