[DATA] Missing Axis and Member metadata in xbrl.facts.query().to_dataframe()
Data Quality Issue Details
Issue Type:
- [x] Incorrect financial values (due to mixed contexts)
- [x] Data inconsistency (multiple values for same metric without distinction)
- [x] Missing metadata (Axis and Member information missing from facts)
Environment
EdgarTools Version: 5.7.1 Python Version: 3.13.5 Operating System: Windows 11
Financial Data Details
Company/Ticker: NVIDIA CORP (NVDA) Form Type: 10-K Filing Date/Period: 2024-02-21 (FY 2023) Statement Type: Consolidated Statements of Income
Specific Metric/Concept:
- Financial line item: Earnings Per Share (Diluted)
- XBRL concept name:
us-gaap:EarningsPerShareDiluted
Data Issue
Expected Value:
- The consolidated Diluted EPS for the fiscal year is $11.93.
- Users expect to be able to identify this as the "Consolidated" value by checking for the absence of dimensions (Axis/Members).
Actual Value from EdgarTools:
- When calling
xbrl.facts.query().to_dataframe(), the library returns multiple rows forEarningsPerShareDilutedincluding a value of 0.05. - The Problem: The resulting DataFrame lacks columns for XBRL Dimensions (Axis/Members). Without these columns, the 0.05 value (which matches "Dividends declared per share" in this specific filing) appears identical in structure to the consolidated 11.93 value.
- Because both rows look "flat" and consolidated in the DataFrame, automated pipelines can easily pick the wrong value (the 0.05) if it appears first or has a more recent context.
Code to reproduce:
from edgar import Company, set_identity
import pandas as pd
# Replace with your identity
set_identity("Name [email protected]")
company = Company("NVDA")
# Accession for the 10-K filed on 2024-02-21
accession = "0001045810-24-000029"
filing = company.get_filings(accession_number=accession)[0]
xbrl = filing.xbrl()
# This returns all facts but flattens/omits the crucial Axis/Member columns
df = xbrl.facts.query().to_dataframe().reset_index()
eps_facts = df[df["concept"].str.contains("EarningsPerShareDiluted", na=False)]
# Both values (11.93 and 0.05) are present, but there is no column
# indicating that 0.05 belongs to a specific Dimension/Member context.
print(eps_facts[["concept", "value", "period_start", "period_end", "context_ref"]])
Cross-Verification
Have you verified this issue with:
- [x] Direct SEC filing comparison (The 0.05 is found in the filing but is NOT the consolidated EPS)
- [x] Structural analysis of the XBRL (The contexts
c-1andc-51have different meanings that are lost in the DataFrame)
Affects multiple periods/companies?
- Observed pattern: This is a systemic issue where facts with dimensions are returned without their axis/member metadata, making them indistinguishable from consolidated facts.
Expected Behavior
What should happen:
The to_dataframe() method should dynamically include columns for every Axis present in the filing's XBRL. For each fact, the corresponding Member should be populated in those columns.
Example of desired output structure:
| concept | value | ... | StatementBusinessSegmentsAxis | InvestmentTypeAxis |
|---|---|---|---|---|
| EarningsPerShareDiluted | 11.93 | ... | NaN (Consolidated) | NaN |
| EarningsPerShareDiluted | 0.05 | ... | SpecificMemberName | OtherMember |
This would allow users to programmatically filter for consolidated data using df[df['StatementBusinessSegmentsAxis'].isna()].
Additional Context
- Current behavior makes it impossible to use
xbrl.factsfor automated financial analysis without risking the injection of segment or footnote data into consolidated metrics. - The value 0.05 in NVDA's 10-K matches the "Dividends declared per common share" but is tagged under a context that includes
EarningsPerShareDilutedin some specific tables. Metadata is the only way to separate them.
Impact Assessment:
- [ ] Major (affects core financial calculations)
- [x] Critical (Produces completely wrong results for major companies because it mixes segments with consolidated data)
Data quality issues are high priority and will be verified against official SEC filings. Accuracy is fundamental to EdgarTools.
Classification: NORMAL BUG (High Priority - P1)
Thank you for this detailed bug report @amcamc92. You're absolutely right that this is a serious data accuracy issue. I've classified this as a NORMAL BUG (high priority P1, not critical P0) for the following reasons:
Why Not Critical (Point Release)
While this has serious implications, it doesn't meet our threshold for an immediate point release:
-
Primary API Unaffected: The
xbrl.statementsAPI (used by 95%+ of users) correctly handles dimensions and multi-valued concepts. This issue only affects the low-levelxbrl.facts.query()API used by advanced users. -
Clear Workaround: You can use the statements API instead of raw facts, or filter dimensional facts manually (see workaround below).
-
Design Limitation: Issue #574 partially addressed dimension metadata by adding
dimension_axis,dimension_member,dimension_member_labelcolumns. However, these only capture the PRIMARY dimension. Full multi-dimensional support was deferred as a design decision.
Why High Priority Anyway
Despite not being critical, this deserves urgent attention:
- Data Accuracy: Any issue where users get wrong financial values is high priority
- Your Assessment: You marked it "Critical" and spent time on detailed reproduction - that signals real pain
- Systematic Impact: Affects all companies with dimensional XBRL facts (majority with segment data)
- API Completeness: Advanced APIs should be production-ready for power users
Workaround
Until we fix this, you can use one of these approaches:
Option 1: Use statements API (recommended)
# Instead of:
facts = xbrl.facts.query().by_concept("us-gaap:EarningsPerShareDiluted").to_dataframe()
# Use:
income_stmt = xbrl.statements.income_statement()
eps_rows = income_stmt.to_dataframe().query("concept == 'us-gaap:EarningsPerShareDiluted'")
# Statements API properly filters dimensional contexts
Option 2: Filter out dimensional facts
# Get only consolidated (non-dimensional) facts
facts = xbrl.facts.query().by_concept("us-gaap:EarningsPerShareDiluted").by_dimension(None).to_dataframe()
Option 3: Manually check dim_ columns*
df = xbrl.facts.query().by_concept("us-gaap:EarningsPerShareDiluted").to_dataframe()
# Filter rows with no dimensions (all dim_* columns are NaN)
dim_cols = [col for col in df.columns if col.startswith('dim_')]
consolidated = df[df[dim_cols].isna().all(axis=1)]
The Fix
We'll expose ALL dimension axes as columns in to_dataframe():
- Current:
dimension_axis,dimension_member(only PRIMARY dimension) - Needed: All
dim_*columns visible, or structured axis columns likeStatementBusinessSegmentsAxis,InvestmentTypeAxis - Consolidated facts: NaN in dimension columns
- Dimensioned facts: Member values visible (e.g., "BuildingMember", "MinimumMember")
This allows filtering like:
# Filter for consolidated data
df[df['StatementBusinessSegmentsAxis'].isna()]
# Filter for specific segment
df[df['StatementBusinessSegmentsAxis'] == 'us-gaap:BuildingMember']
Timeline
- Target Release: v5.13.0 (minor release, scheduled)
- Estimated Effort: 2-5 days (M-L complexity due to multi-dimensional support)
- Tracking: Created Beads issue edgartools-ozey
I appreciate your patience and detailed reporting. This will make the facts API much more robust for production use.
Triaged using EdgarTools Issue-PM Integration Protocol
Fix: is_dimensioned column now included by default
This is fixed on main. The to_dataframe() output now includes an is_dimensioned boolean column that's always present, letting you distinguish consolidated facts from dimensioned facts without needing to enable full dimension columns.
Your exact scenario, fixed
Using your NVDA 10-K reproduction code:
from edgar import Company
company = Company("NVDA")
filing = company.get_filings(accession_number="0001045810-24-000029")[0]
xbrl = filing.xbrl()
df = xbrl.facts.query().to_dataframe()
eps = df[df["concept"].str.contains("EarningsPerShareDiluted", na=False)]
print(eps[["concept", "value", "is_dimensioned", "period_start", "period_end"]])
concept value is_dimensioned period_start period_end
us-gaap:EarningsPerShareDiluted 0.05 True 2023-10-30 2024-01-28
us-gaap:EarningsPerShareDiluted 11.93 False 2023-01-30 2024-01-28
us-gaap:EarningsPerShareDiluted 1.74 False 2022-01-31 2023-01-29
us-gaap:EarningsPerShareDiluted 3.85 False 2021-02-01 2022-01-30
The 0.05 value is now clearly marked is_dimensioned=True. The consolidated 11.93 is False.
Filtering to consolidated-only values
# One-liner to get only consolidated facts
consolidated_eps = eps[~eps["is_dimensioned"]]
concept value is_dimensioned period_start period_end
us-gaap:EarningsPerShareDiluted 11.93 False 2023-01-30 2024-01-28
us-gaap:EarningsPerShareDiluted 1.74 False 2022-01-31 2023-01-29
us-gaap:EarningsPerShareDiluted 3.85 False 2021-02-01 2022-01-30
The problematic 0.05 is gone.
Seeing full dimension details with with_dimensions()
When you need to know which axis/member a dimensioned fact belongs to, chain .with_dimensions():
df = (xbrl.facts.query()
.with_dimensions()
.by_concept("EarningsPerShareDiluted")
.to_dataframe())
print(df[["concept", "value", "is_dimensioned", "dimension", "member", "dimension_label"]])
concept value is_dimensioned dimension member dimension_label
us-gaap:EarningsPerShareDiluted 0.05 True us-gaap:ChangeInAccountingEstimateByTypeAxis us-gaap:ServiceLifeMember Service Life
us-gaap:EarningsPerShareDiluted 11.93 False NaN NaN NaN
us-gaap:EarningsPerShareDiluted 1.74 False NaN NaN NaN
us-gaap:EarningsPerShareDiluted 3.85 False NaN NaN NaN
Now you can see the 0.05 belongs to the ChangeInAccountingEstimateByTypeAxis / ServiceLifeMember context.
Summary of changes
| What | Detail |
|---|---|
is_dimensioned column |
Always present in to_dataframe() output. True if the fact has dimension context, False if consolidated. |
.with_dimensions() |
New chainable method that enables full dim_*, dimension, member, and dimension_label columns. |
| Existing methods | .by_dimension(None) and .exclude_dimensions() continue to work as before. |
The existing workarounds from my earlier comment (.by_dimension(None), statements API) also still work. The is_dimensioned column just makes the default output self-describing so automated pipelines don't need special handling.