edgartools icon indicating copy to clipboard operation
edgartools copied to clipboard

XBRL.to_pandas() omits available fact metadata because the catalog lookup uses colon-form IDs

Open synfonia-llc opened this issue 1 month ago • 2 comments

Issue Type

  • [ ] Data Quality Issue (incorrect financial values, missing data)
  • [x] XBRL Parsing Issue (statement rendering, concept mapping)
  • [ ] Filing Access Issue (download failures, attachment problems)
  • [ ] Performance Issue (slow operations, memory problems)
  • [ ] Compatibility Issue (platform/dependency conflicts)
  • [ ] Documentation Issue (unclear instructions, missing examples)

Environment

EdgarTools Version: main at commit 2323d732 (reports 5.62.0); the v5.62.0 tag (commit 5068cc54) gives the same output Python Version: 3.14.4 Operating System: Windows 11

Bug Description

What you expected to happen: XBRL.to_pandas()["facts"] includes element_name, element_type, element_period_type, element_balance and element_label for each fact whose concept is in the parsed element catalog.

What actually happened: The facts frame has 1,844 rows and none of the five columns. The enrichment branch in XBRL.to_pandas() tests the raw element_id (for example aubn:EmployeeRetentionTaxCredit) against a catalog keyed with underscores (aubn_EmployeeRetentionTaxCredit). None of the 427 distinct element IDs in this filing matches directly; all 427 match once the colon is replaced with an underscore. A query on the facts view (x.facts.query().by_concept("aubn:EmployeeRetentionTaxCredit", exact=True)) returns the label and balance for the same concept, because the facts view replaces the colon with an underscore before its own catalog lookup.

Error message (if any):

None. The columns are absent and no error is raised.

Reproduction

Company/Ticker: Auburn National Bancorporation (AUBN), CIK 750574 Time Period: Fiscal year 2023, with 2022 comparative facts Relevant Forms: 10-K, accession 0001193125-24-067944 (filed 2024-03-14)

Minimal code to reproduce:

from edgar import get_by_accession_number, set_identity

set_identity("Your Name [email protected]")
x = get_by_accession_number("0001193125-24-067944").xbrl()
facts = x.to_pandas()["facts"]
metadata = ["element_name", "element_type", "element_period_type",
            "element_balance", "element_label"]
print(len(facts))
print([c for c in metadata if c not in facts.columns])

element = x.element_catalog["aubn_EmployeeRetentionTaxCredit"]
print(element.name, element.data_type, element.period_type, element.balance)
print(element.labels["http://www.xbrl.org/2003/role/label"])

q = x.facts.query().by_concept("aubn:EmployeeRetentionTaxCredit", exact=True)
print(q.to_dataframe()[["fact_id", "numeric_value", "label", "balance"]])

Output on main (2323d732) and on v5.62.0 (5068cc54) was the same:

1844
['element_name', 'element_type', 'element_period_type', 'element_balance', 'element_label']
aubn_EmployeeRetentionTaxCredit xbrli:monetaryItemType duration debit
Employee Retention Tax Credit
  fact_id  numeric_value                          label balance
0  ID_910            0.0  Employee Retention Tax Credit   debit
1  ID_911     -1569000.0  Employee Retention Tax Credit   debit

The filing's consolidated statement of earnings (in thousands) shows Employee retention credit as a dash for 2023 and (1,569) for 2022, and FDIC and other regulatory assessments as 631 for 2023. These match facts ID_910 (0), ID_911 (-1,569,000) and ID_605 (631,000).

Additional Context

Scope. The same omission appears in two other 10-K filings, both measured on main (2323d732): Apple, accession 0000320193-24-000123 (1,127 rows, 382 distinct element IDs, none matching the catalog directly), and Microsoft, accession 0000950170-24-087843 (1,856 rows, 507 distinct element IDs, none matching directly and 502 after the colon is replaced). The five columns are absent in all three. This report covers XBRL.to_pandas()["facts"] only. It does not claim that other APIs drop the metadata, that every catalog field is known for every fact, or that any amount, row or unit is wrong.

Expected result of the fix. In a local copy of main with one line changed (element_id = fact.element_id.replace(':', '_') in the enrichment branch), the five columns appear. element_name, element_period_type and element_label are filled on all 1,844 rows. element_type is filled on 381 rows and element_balance on 338, because the catalog leaves type and balance empty for standard concepts after #1431. element_name then carries the underscore form beside the colon form in element_id.

Code locations on main. The enrichment branch is in edgar/xbrl/xbrl.py lines 2982-2998. The facts view normalizes the same identifier in edgar/xbrl/facts.py lines 1540-1546.

Filing links. Filing index and primary document.

Related: #1276 and #1418 (the same colon and underscore split in other APIs), #1425 and #1431 (placeholder and standard-concept metadata in element_catalog), #941 (the FactQuery path never builds the element_* keys), #1430 (the to_pandas() docs).


This issue will be handled using EdgarTools' systematic issue resolution workflow. A reproduction test will be created to verify the fix.

synfonia-llc avatar Oct 22 '26 14:10 synfonia-llc

@dgunning, here is our current thinking on the root cause, proposed behavior, and coordination with other issues.

Root Cause:

XBRL.to_pandas()["facts"] looks up colon-form concept IDs in an underscore-keyed catalog, so it omits five intended metadata fields even when those fields are available. The observed AUBN defect concerns the export join, not missing facts or changed amounts.

Proposed Behavior:

Try the exact catalog key first, then normalize only the qualified concept's namespace separator for lookup. Export the existing element_* metadata without changing fact identifiers, contexts, values or signs, including AUBN's filed 2023 zero and 2022 negative amount. Preserve unknown metadata and namespace identity rather than guessing by local name or using balance metadata to negate a value. This repair exposes existing catalog information without acquiring additional taxonomy metadata.

Coordination:

Recommend a standalone #1711 PR. Coordinate metadata meaning with #1426, #1728 and #1730, whose broader source/loading work is not required for this join. Other concept-ID consumers in #1276/#1418 remain separate.

Below, please find the full design document. Please let me know your thoughts.

Brian

Attachment: design-public.md, Restore available catalog metadata in the facts export — #1711.

AI assistance: Codex; GPT-6.1 Sol (High) performed current-main scouting, source verification and final writing; GPT-6 Astra (Max) developed the architecture and completed an independent financial-statement review.

synfonia-llc avatar Oct 27 '26 11:10 synfonia-llc

@synfonia-llc thanks for the analysis. I'm working on a standalone fix along the lines you propose: to_pandas() tries the exact catalog key first, then the underscore form of the qualified concept, and adds the existing element_* columns without touching fact IDs, contexts, values or signs. It comes with a regression test and a changelog fragment. I'll open it as a PR shortly; happy to close mine if you'd already started on one.

rqms40 avatar Nov 11 '26 02:11 rqms40