Unable to get Business Segment Data #630
-
|
Hi All, Python 3.13.5 bax = Company('BAX') Sort filings by datefilings_sorted = sorted(filings, key=lambda x: x.filing_date, reverse=True) revenue = xbrl.facts.query().by_concept('Revenue').to_dataframe() |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
|
Hi! Thanks for reporting this. Starting in recent versions of edgartools, dimension columns are excluded from DataFrame output by default to produce cleaner output that matches the face of SEC filings. The Quick FixAdd revenue = xbrl.facts.query().by_concept("Revenue").with_dimensions().to_dataframe()This will restore all the Updated Example for Your Use Casefrom edgar import Company
import pandas as pd
bax = Company("BAX")
filing = bax.get_filings(form="10-Q").latest()
xbrl = filing.xbrl()
# Use with_dimensions() to include dim_* columns
revenue = (xbrl.facts.query()
.by_concept("Revenue")
.with_dimensions()
.to_dataframe())
# Filter for segment data
revenue = revenue[
(revenue["concept"].str.contains("Revenue")) &
(revenue["numeric_value"].notnull()) &
(revenue["dim_us-gaap_StatementBusinessSegmentsAxis"].notnull())
]Alternative: Filter by Dimension DirectlyYou can also use # Get revenue broken down by business segment
revenue_by_segment = (xbrl.facts.query()
.by_concept("Revenue")
.by_dimension("StatementBusinessSegmentsAxis")
.to_dataframe())This filters to only facts that have the business segment dimension, and includes structured columns like New Structured Dimension ColumnsIn addition to the
These can be more convenient than the Hope this helps! Let me know if you have any other questions. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the quick response. The first quick fix you suggested did not work for me. bax = Company("BAX") Use with_dimensions() to include dim_* columnsrevenue = (xbrl.facts.query() Filter for segment datarevenue = revenue[ AttributeError Traceback (most recent call last) AttributeError: 'FactQuery' object has no attribute 'with_dimensions' The alternative fix appears to work. |
Beta Was this translation helpful? Give feedback.
-
|
Hi @amismithmoritz — apologies for the confusion! The pip install --upgrade edgartoolsAfter upgrading, both approaches will work: # Option 1: Include all dim_* columns without filtering
revenue = (xbrl.facts.query()
.by_concept("Revenue")
.with_dimensions()
.to_dataframe())
# Option 2: Filter to a specific dimension (also includes dim_* columns automatically)
revenue = (xbrl.facts.query()
.by_concept("Revenue")
.by_dimension("StatementBusinessSegmentsAxis")
.to_dataframe())In the meantime, glad to hear |
Beta Was this translation helpful? Give feedback.
-
|
Hi dgunning, |
Beta Was this translation helpful? Give feedback.
Hi @amismithmoritz — apologies for the confusion! The
with_dimensions()method was added in v5.14.0, so it's not available on your v5.11.2. Upgrading should fix it:After upgrading, both approaches will work:
In the meantime, glad to hear
by_dimension()is working for you — that's been ava…