Skip to content

Fix pandas 2.x compatibility by replacing deprecated DataFrame/Series.append#342

Open
wavebyrd wants to merge 1 commit intogoldmansachs:masterfrom
wavebyrd:fix-pandas-2-append-compatibility
Open

Fix pandas 2.x compatibility by replacing deprecated DataFrame/Series.append#342
wavebyrd wants to merge 1 commit intogoldmansachs:masterfrom
wavebyrd:fix-pandas-2-append-compatibility

Conversation

@wavebyrd
Copy link
Copy Markdown

Summary

  • Replace deprecated DataFrame.append() and Series.append() calls with pd.concat() for pandas 2.x compatibility
  • Fixes runtime AttributeError when using gs-quant with pandas >= 2.0
  • Maintains backward compatibility with pandas 1.x

Changes

File Function Change
utility_processors.py AppendProcessor.process() a.append(b)pd.concat([a, b])
tree_entity.py AssetTreeNode.__build_constituents_df() df.append(...)pd.concat([...], ignore_index=True)
hedge.py Hedge.create_transaction_cost_data_structures() Loop append → collect then concat
results.py _compose() lhs.append(rhs)pd.concat([lhs, rhs])

Test plan

  • Run existing test suite to verify no regressions
  • Test with pandas 1.5.x to ensure backward compatibility
  • Test with pandas 2.x to confirm fix resolves the AttributeError

Fixes #337

🤖 Generated with Claude Code

….append

The append() method was removed in pandas 2.0. This change replaces all
occurrences with pd.concat() to ensure compatibility with pandas 2.x
while maintaining backward compatibility with pandas 1.x.

Affected files:
- utility_processors.py: AppendProcessor.process()
- tree_entity.py: AssetTreeNode.__build_constituents_df()
- hedge.py: Hedge.create_transaction_cost_data_structures()
- results.py: _compose()

Fixes goldmansachs#337

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@wavebyrd
Copy link
Copy Markdown
Author

Ping on this pandas 2.x compatibility fix. Replaces deprecated .append() with pd.concat(). Ready for review!

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.

[BIG REPORT] - Pandas 2.x compatibility: replace removed DataFrame/Series append usage causing runtime failures

1 participant