Skip to content

fix: handle pandas extension dtypes in ownership calculations - #1377

Merged
dgunning merged 3 commits into
dgunning:mainfrom
monody0007:fix/ownership-pandas-string-dtype
Sep 28, 2026
Merged

dgunning merged 3 commits into
dgunning:mainfrom
monody0007:fix/ownership-pandas-string-dtype

Conversation

@monody0007

Copy link
Copy Markdown
Contributor

Pandas 3 text columns and pandas nullable numeric dtypes can make NumPy's dtype check raise TypeError in ownership calculations. Use pandas' dtype predicate at both affected sites while retaining the numeric-text fallback and nonnumeric results.

Fixes #1368. Thanks to @manantlerio for the reproduction, affected-site analysis, and proposed fix. The empty-trades change in #1367 remains separate.

The regression exercises Form4.parse_xml() with the checked-in Snowflake fixture modified only in memory. It covers footnoted text, unreadable shares, nullable numeric columns, and the normal share total; the modified XML is synthetic and no cassette is recorded.

Validation:

  • New regression: 11 passed on pandas 3.0.6 and pandas 2.3.3. On the original code: 7 failed/4 passed on pandas 3; 5 failed/6 passed on pandas 2, all at the dtype check.
  • pytest -p tests._offline_harness -p no:pytest-retry -q tests/issues/regression/test_issue_1368_ownership_numeric_dtypes.py
  • Offline ownership fast tests: 9 passed, 50 deselected. Changed-file Ruff and regression provenance/skip/changelog checks passed.
  • Existing whole-repo Ruff and production-file Pyright findings match the base. Live SEC and the full network suite were not run.

AI assistance: coding, test execution, and an independent model review were performed with AI tools. This is disclosed as AI-assisted work; no human code review is claimed.

monody0007 and others added 3 commits September 27, 2026 22:34
Resolve the conflict with dgunning#1367 in Ownership.shares_traded: keep its
None/empty guard and `trades` local, and keep this branch's
pd.api.types.is_numeric_dtype check in place of np.issubdtype.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@monody0007

Copy link
Copy Markdown
Contributor Author

Merged current main (73491ae) into this branch to resolve the conflict with #1367. The resolution retains its None/empty guard in shares_traded and the pandas-aware dtype check from this PR.

The #1368 and #1359 regression files pass on both pandas 3.0.6 and 2.3.3: 15 tests per environment, with no skips. The wider network-dependent tests remain unverified locally; their offline failures match the unchanged upstream base.

@dgunning
dgunning merged commit 6c0be08 into dgunning:main Sep 28, 2026
11 checks passed
@dgunning dgunning mentioned this pull request Oct 2, 2026
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.

is_numeric raises TypeError instead of returning False for pandas 3 string columns

2 participants