Skip to content

BUG: Append a Series without a name to state space results - #11115

Merged
bashtage merged 2 commits into
statsmodels:mainfrom
bashtage:wip-mlemodel-append-unnamed
Nov 24, 2026
Merged

bashtage merged 2 commits into
statsmodels:mainfrom
bashtage:wip-mlemodel-append-unnamed

Conversation

@bashtage

Copy link
Copy Markdown
Member

No conflict in tools.py or mlemodel.py with the open statespace PRs. Other open statespace PRs also append tests at the end of the same test files: keep both appended blocks.

MLEResults.append of a model whose endog is a named Series raised
"ValueError: Columns must match to concatenate along rows." for new
observations given as a Series without a name:

res = SARIMAX(pd.Series(y, index=ix, name="y"), order=(1, 0, 0)).smooth(p)
res.append(pd.Series([0.1], index=new_ix))

while an ndarray, a list or the Series named "y" were accepted. The
appended data are concatenated by statsmodels.tsa.statespace.tools.concat,
which gives an unnamed Series passed with a DataFrame the DataFrame's
first column name, but compared the names of two Series as they were.

Changes

  • tools.concat gives a Series without a name the name of the first
    series when it concatenates two series along the rows, as it does for an
    unnamed Series passed with a DataFrame. The given Series is not changed.
  • versionchanged note for endog of MLEResults.append.

Not changed

  • A Series with another name still raises, as does a DataFrame with other
    columns.
  • Concatenation along the columns: an unnamed Series keeps its default
    column name.

Tests

  • append of an unnamed Series gives the same model endog (the
    concatenated data, named "y"), loglikelihood, smoothed state and
    forecasts as append of the Series named "y", and the given Series
    keeps its name (None).

  • tools.concat of a named and an unnamed Series gives a Series with the
    first name and the concatenated values; a Series with another name still
    raises; along the columns the unnamed Series keeps the column name 0.

  • Both fail on main. Also checked with pandas 2.3.3.

  • tests added / passed.

  • code/documentation is well formatted.

  • properly formatted commit message. See
    NumPy's guide.

AI Disclosure

Contributions must comply with the statsmodels AI Policy.

Tick exactly one of the following. If AI tools were used, replace the <...>
placeholders in the second option with the tool name(s) and how the tool's output was
used.

  • No AI tools were used to develop this pull request.
  • AI tools were used.
    Tool(s): Claude Code (Claude Opus 5.5).
    Used for: finding the bug in a coverage audit of the state space models, writing the fix and its tests, and checking them (tests failing on the base, mutation check).
    I have personally read, understood, and can explain every line of this diff, and
    have verified the statistical/numerical correctness of the change.

🤖 Generated with Claude Code

`MLEResults.append` of a model whose `endog` is a named Series raised
"ValueError: Columns must match to concatenate along rows." for new
observations given as a Series without a name:

    res = SARIMAX(pd.Series(y, index=ix, name="y"), order=(1, 0, 0)).smooth(p)
    res.append(pd.Series([0.1], index=new_ix))

while an ndarray, a list or the Series named "y" were accepted. The
appended data are concatenated by `statsmodels.tsa.statespace.tools.concat`,
which gives an unnamed Series passed with a DataFrame the DataFrame's
first column name, but compared the names of two Series as they were.

Changes
- `tools.concat` gives a Series without a name the name of the first
  series when it concatenates two series along the rows, as it does for an
  unnamed Series passed with a DataFrame. The given Series is not changed.
- `versionchanged` note for `endog` of `MLEResults.append`.

Not changed
- A Series with another name still raises, as does a DataFrame with other
  columns.
- Concatenation along the columns: an unnamed Series keeps its default
  column name.

Tests
- `append` of an unnamed Series gives the same model endog (the
  concatenated data, named "y"), loglikelihood, smoothed state and
  forecasts as `append` of the Series named "y", and the given Series
  keeps its name (None).
- `tools.concat` of a named and an unnamed Series gives a Series with the
  first name and the concatenated values; a Series with another name still
  raises; along the columns the unnamed Series keeps the column name 0.
- Both fail on main. Also checked with pandas 2.3.3.
@bashtage
bashtage force-pushed the wip-mlemodel-append-unnamed branch from b0c8c08 to a06eca1 Compare November 24, 2026 16:16
@bashtage
bashtage marked this pull request as ready for review November 24, 2026 23:00
@bashtage
bashtage merged commit 957e431 into statsmodels:main Nov 24, 2026
10 of 11 checks passed
@bashtage
bashtage deleted the wip-mlemodel-append-unnamed branch November 24, 2026 23:00
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