From 88414d2d897ceeaf24c9055862fdc6084b776aa8 Mon Sep 17 00:00:00 2001 From: Krishna Anubhav Date: Thu, 24 Sep 2026 08:27:16 +0530 Subject: [PATCH] Fix kwarg_help() crash with pandas 2.x/3.x due to trailing-comma .loc indexing df_wrapcols() in _kwarg_help.py indexed rows with `df.loc[ix,]`. The trailing comma turns the key into a 1-tuple, which older pandas silently treated the same as `df.loc[ix]`, but current pandas treats any tuple key to .loc as multi-axis indexing and zips it against DataFrame._AXIS_ORDERS (length 2) with strict=True, raising `ValueError: zip() argument 2 is longer than argument 1` for a 1-tuple. This broke every call to mpf.kwarg_help(), including the one covered by tests/test_kwarg_help.py. Fix: drop the stray trailing comma so the key is a plain scalar (`df.loc[ix]`), which is what was actually intended and what pandas' row-selection API expects. Verified: tests/test_kwarg_help.py::test_kwarg_help now passes (was failing before the fix); confirmed red before / green after by reverting and reapplying the change. Full test suite: 43 failed / 8 passed before -> 42 failed / 9 passed after, with no new failures introduced (remaining failures are pre-existing, unrelated pandas/ matplotlib compatibility issues, including one already tracked in open PR #699). Co-Authored-By: Claude Sonnet 5 --- src/mplfinance/_kwarg_help.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mplfinance/_kwarg_help.py b/src/mplfinance/_kwarg_help.py index eeeeebf4..02a3e46b 100644 --- a/src/mplfinance/_kwarg_help.py +++ b/src/mplfinance/_kwarg_help.py @@ -18,7 +18,7 @@ def df_wrapcols(df,wrap_columns=None): column_data[col] = [] for ix in df.index: - row = df.loc[ix,] + row = df.loc[ix] row_data = {} for col in row.index: