Example tables¶
This is to show visually what data is returned for the various get_data calls as well as summarizes what uniquely identifies a series.
[ ]:
import pandas as pd
import numpy as np
import beaapi
from dotenv import dotenv_values
beakey = dotenv_values()["beakey"]
Series identification¶
Dataset |
TimeSeries ID |
Notes |
|---|---|---|
NIPA |
SeriesCode x Frequency |
|
NIUnderlyingDetail |
SeriesCode x Frequency |
|
MNE |
SeriesID x RowCode x Row (just when |
(Frequency currently only annual) |
FixedAssets |
SeriesCode |
(Frequency currently only annual) |
ITA |
TimeSeriesId (TSI_Ita{Indicator}{AreaOrCountry}_{Frequency}) |
|
IIP |
TimeSeriesId (TSI_Iip{TypeOfInvestment}{Component}_{Frequency}) |
|
InputOutput |
TableID + RowCode x ColCode |
(Frequency currently only annual) |
IntlServTrade |
TimeSeriesId (TSI_Ist{TypeOfService}{TradeDirection abbr}{AreaOr Country}{Affiliation abbr}_{Frequency}) |
|
IntlServSTA |
TimeSeriesId (typically TSI_Ssta{Channel}{Destination}{Industry}{AreaOrCountry}_{Frequency} but can reword) |
|
GDPbyIndustry |
TableID x Industry x Frequency |
|
Regional |
Code ({tableID}-{LineNumber}) x GeoFips |
(tableID uniquely defines frequency) |
UnderlyingGDPbyIndustry |
TableID x Industry x Frequency |
NIPA¶
[3]:
bea_tbl = beaapi.get_data(beakey, datasetname='NIPA', TableName='T20305', Frequency='A', Year='2015')
display(bea_tbl.head(2))
print(bea_tbl.attrs)
| TableName | SeriesCode | LineNumber | LineDescription | TimePeriod | METRIC_NAME | CL_UNIT | UNIT_MULT | DataValue | NoteRef | |
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | T20305 | DPCERC | 1 | Personal consumption expenditures (PCE) | 2015 | Current Dollars | Level | 6 | 12297438 | T20305 |
| 1 | T20305 | DGDSRC | 2 | Goods | 2015 | Current Dollars | Level | 6 | 3955130 | T20305 |
{'params': [{'ParameterName': 'TABLENAME', 'ParameterValue': 'T20305'}, {'ParameterName': 'FREQUENCY', 'ParameterValue': 'A'}, {'ParameterName': 'YEAR', 'ParameterValue': '2015'}, {'ParameterName': 'USERID', 'ParameterValue': 'F0E378A4-7FF1-4196-9892-CD98178FCA82'}, {'ParameterName': 'METHOD', 'ParameterValue': 'GETDATA'}, {'ParameterName': 'DATASETNAME', 'ParameterValue': 'NIPA'}, {'ParameterName': 'RESULTFORMAT', 'ParameterValue': 'JSON'}, {'ParameterName': 'ShowMillions', 'ParameterValue': 'N'}], 'response_size': 10203, 'detail': {'Statistic': 'NIPA Table', 'UTCProductionTime': '2025-06-27T14:01:05.397', 'Dimensions': Ordinal Name DataType IsValue
0 1 TableName string 0
1 2 SeriesCode string 0
2 3 LineNumber numeric 0
3 4 LineDescription string 0
4 5 TimePeriod string 0
5 6 CL_UNIT string 0
6 7 UNIT_MULT numeric 0
7 8 METRIC_NAME string 0
8 9 DataValue numeric 1, 'Notes': NoteRef NoteText
0 T20305 Table 2.3.5. Personal Consumption Expenditures...
1 T20305.1 1. Net expenses of NPISHs, defined as their gr...
2 T20305.2 2. Gross output is net of unrelated sales, sec...
3 T20305.3 3. Excludes unrelated sales, secondary sales, ...
4 T20305.4 4. Food consists of food and beverages purchas...
5 T20305.5 5. Consists of gasoline and other energy goods...
6 T20305.6 6. Market-based PCE is a supplemental measure ...}, 'time_invariant_keys': ['LineNumber'], 'time_invariant_vars': ['TableName', 'SeriesCode', 'LineDescription', 'METRIC_NAME', 'CL_UNIT', 'UNIT_MULT', 'NoteRef'], 'time_variant_keys': ['TimePeriod'], 'time_variant_vars': ['DataValue'], 'time_variant_only_vars': [], 'index_cols': ['LineNumber', 'TimePeriod'], 'release_date': datetime.date(2025, 6, 26)}
NIUnderlyingDetail¶
[ ]:
bea_tbl = beaapi.get_data(beakey, 'NIUnderlyingDetail', Frequency='A', Year='2020', TableName='U001B')
display(bea_tbl.head(2))
print(bea_tbl.attrs)
| TableName | SeriesCode | LineNumber | LineDescription | TimePeriod | METRIC_NAME | CL_UNIT | UNIT_MULT | DataValue | NoteRef | |
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | U001B | KSMT | 1 | Manufacturing and trade industries | 2020Q1 | Chained Dollars | Level | 6 | 2189521 | U001B |
| 1 | U001B | KSMT | 1 | Manufacturing and trade industries | 2020Q2 | Chained Dollars | Level | 6 | 2125377 | U001B |
| 2 | U001B | KSMT | 1 | Manufacturing and trade industries | 2020Q3 | Chained Dollars | Level | 6 | 2148893 | U001B |
| 3 | U001B | KSMT | 1 | Manufacturing and trade industries | 2020Q4 | Chained Dollars | Level | 6 | 2170189 | U001B |
| 4 | U001B | N376RX | 2 | Manufacturing industries | 2020Q1 | Chained Dollars | Level | 6 | 825052 | U001B |
| 5 | U001B | N376RX | 2 | Manufacturing industries | 2020Q2 | Chained Dollars | Level | 6 | 833251 | U001B |
{'params': [{'ParameterName': 'FREQUENCY', 'ParameterValue': 'Q'}, {'ParameterName': 'YEAR', 'ParameterValue': '2020'}, {'ParameterName': 'TABLENAME', 'ParameterValue': 'U001B'}, {'ParameterName': 'USERID', 'ParameterValue': 'F0E378A4-7FF1-4196-9892-CD98178FCA82'}, {'ParameterName': 'METHOD', 'ParameterValue': 'GETDATA'}, {'ParameterName': 'DATASETNAME', 'ParameterValue': 'NIUNDERLYINGDETAIL'}, {'ParameterName': 'RESULTFORMAT', 'ParameterValue': 'JSON'}], 'response_size': 61157, 'detail': {'Statistic': 'NIPA Table', 'UTCProductionTime': '2025-06-27T14:04:26.747', 'Dimensions': Ordinal Name DataType IsValue
0 1 TableName string 0
1 2 SeriesCode string 0
2 3 LineNumber numeric 0
3 4 LineDescription string 0
4 5 TimePeriod string 0
5 6 CL_UNIT string 0
6 7 UNIT_MULT numeric 0
7 8 METRIC_NAME string 0
8 9 DataValue numeric 1, 'Notes': NoteRef NoteText
0 U001B Table 1BU. Real Manufacturing and Trade Invent...
1 U001B.1 Note. Estimates in this table are based on the...
2 U001B.2 Chained (2017) dollar inventory series are cal...}, 'time_invariant_keys': ['LineNumber'], 'time_invariant_vars': ['TableName', 'SeriesCode', 'LineDescription', 'METRIC_NAME', 'CL_UNIT', 'UNIT_MULT', 'NoteRef'], 'time_variant_keys': ['TimePeriod'], 'time_variant_vars': ['DataValue'], 'time_variant_only_vars': [], 'index_cols': ['LineNumber', 'TimePeriod'], 'release_date': datetime.date(2025, 6, 26)}
MNE¶
[41]:
print("DI")
bea_tbl = beaapi.get_data(beakey, "MNE", DirectionOfInvestment="Outward",
Classification="Country", Year="2010", GetFootnotes='Yes')
display(bea_tbl.head(2))
print(bea_tbl.attrs)
print("AMNE")
bea_tbl = beaapi.get_data(beakey, "MNE", DirectionOfInvestment="Outward",
OwnershipLevel="1", NonBankAffiliatesOnly="0", Classification="Country", Year="2010",
GetFootnotes='Yes')
display(bea_tbl.head(2))
print(bea_tbl.attrs)
DI
| Year | SeriesID | SeriesName | Row | ColumnGParent | ColumnParent | Column | RowCode | ColumnCode | ColumnParentCode | ColumnGParentCode | TableScale | DataValueUnformatted | TableColumnDisplayOrder | TableRowDisplayOrder | DataValue | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 2010 | 33 | Debt Instruments Outflows | All Countries Total | None | None | Debt Outflows | 000 | 0000 | 0 | 0 | Millions of Dollars | -41960 | 1.00 | 1.00 | -41,960 |
| 1 | 2010 | 32 | Equity Outflows Other than Reinvestment of Ear... | All Countries Total | None | None | Equity Outflows | 000 | 0000 | 0 | 0 | Millions of Dollars | 40550 | 1.00 | 1.00 | 40,550 |
{'params': [{'ParameterName': 'DIRECTIONOFINVESTMENT', 'ParameterValue': 'OUTWARD'}, {'ParameterName': 'CLASSIFICATION', 'ParameterValue': 'COUNTRY'}, {'ParameterName': 'YEAR', 'ParameterValue': '2010'}, {'ParameterName': 'GETFOOTNOTES', 'ParameterValue': 'YES'}, {'ParameterName': 'USERID', 'ParameterValue': 'F0E378A4-7FF1-4196-9892-CD98178FCA82'}, {'ParameterName': 'METHOD', 'ParameterValue': 'GETDATA'}, {'ParameterName': 'DATASETNAME', 'ParameterValue': 'MNE'}, {'ParameterName': 'RESULTFORMAT', 'ParameterValue': 'JSON'}, {'ParameterName': 'NonbankAffiliatesOnly', 'ParameterValue': '2'}, {'ParameterName': 'OwnershipLevel', 'ParameterValue': '2'}, {'ParameterName': 'SeriesID', 'ParameterValue': 'all'}], 'response_size': 370528, 'detail': {'Table_Count': '6', 'rowTypeID': '4,10', 'InvestmentType': 'U.S. Direct Investment Abroad', 'DataType': 'Balance of Payments and Direct Investment Position Data', 'Entity': 'None', 'IndustryClassification': 'NAICS', 'YearList': '2010', 'DIRECTIONOFINVESTMENT': 'OUTWARD', 'OwnershipLevel': '2', 'NonbankAffiliatesOnly': '2', 'Tables': '13,16,17,210,211,212', 'cnt': '858', 'Dimensions': Ordinal Name DataType IsValue
0 1 Year numeric 0
1 2 SeriesID numeric 0
2 3 SeriesName string 0
3 4 Row string 0
4 5 Column string 0
5 6 RowCode string 0
6 7 ColumnCode string 0
7 8 TableScale string 0
8 9 DataValueUnformatted string 1
9 10 DataValue string 1, 'Notes': NoteText NoteRef
0 <strong>n.s.</strong> Not shown. Data may no... 2.00
1 ⢠The data appear on another line in this ta... 4.00
2 ⢠The data are not shown in this table but m... 6.00
3 ⢠The data are not available, do not apply, ... 8.00
4 <strong>(*)</strong> A nonzero value that roun... 10.00
5 <strong>(D)</strong> indicates that the data i... 12.00
6 Balance of payments transactions (and associat... 34.00
7 The composition of the "Other" categories show... 36.00
8 Source: U.S. Bureau of Economic Analysis 41.00
9 1. The âUnited Kingdom Islands, Caribbeanâ... 100.10
10 1. Prior to 2011, included data for Curacao, S... 100.20
11 1. The "United Kingdom Islands, Caribbean" is ... 113.00
12 2. Data for the European Union (EU) reflect th... 114.00
13 3. OPEC (Organization of Petroleum Exporting C... 115.00
14 2. The "United Kingdom Islands, Caribbean" is ... 117.01
15 2. Data for the European Union (EU) reflect th... 118.00
16 3. OPEC (Organization of Petroleum Exporting C... 119.00
17 2. The âUnited Kingdom Islands, Caribbeanâ... 222.00
18 3. Prior to 2011, data were included in the Ne... 223.00
19 4. Starting in 2021, data for Western Sahara a... 224.00
20 5. Prior to 2011, included data for South Sudan. 225.00
21 6. Prior to 2023, included data for Cook Islan... 225.10
22 7. Prior to 2023, data were included in New Ze... 227.10
23 If you have a question about the availability ... 10000.00}, 'time_invariant_keys': ['SeriesID', 'RowCode', 'Row', 'ColumnCode', 'Column', 'ColumnGParentCode'], 'time_invariant_vars': ['SeriesName', 'ColumnGParent', 'ColumnParent', 'ColumnParentCode', 'TableScale'], 'time_variant_keys': ['Year', 'TableRowDisplayOrder', 'TableColumnDisplayOrder'], 'time_variant_vars': ['DataValueUnformatted', 'DataValue'], 'time_variant_only_vars': [], 'index_cols': ['SeriesID', 'RowCode', 'Row', 'ColumnCode', 'Column', 'ColumnGParentCode', 'Year', 'TableRowDisplayOrder', 'TableColumnDisplayOrder']}
AMNE
| Year | SeriesID | SeriesName | Row | ColumnGParent | ColumnParent | Column | RowCode | ColumnCode | ColumnParentCode | ColumnGParentCode | TableScale | DataValueUnformatted | TableColumnDisplayOrder | TableRowDisplayOrder | DataValue | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 2010 | 7 | Compensation of Employees | All Countries Total | None | None | Compensation of Employees | 000 | 0 | 0 | 0 | Millions of Dollars | 559135 | 1.00 | 1.00 | 559,135 |
| 1 | 2010 | 8 | Employment | All Countries Total | None | None | Employees | 000 | 0 | 0 | 0 | Thousands of Employees | 13495.6 | 1.00 | 1.00 | 13,495.6 |
{'params': [{'ParameterName': 'DIRECTIONOFINVESTMENT', 'ParameterValue': 'OUTWARD'}, {'ParameterName': 'OWNERSHIPLEVEL', 'ParameterValue': '1'}, {'ParameterName': 'NONBANKAFFILIATESONLY', 'ParameterValue': '0'}, {'ParameterName': 'CLASSIFICATION', 'ParameterValue': 'COUNTRY'}, {'ParameterName': 'YEAR', 'ParameterValue': '2010'}, {'ParameterName': 'GETFOOTNOTES', 'ParameterValue': 'YES'}, {'ParameterName': 'USERID', 'ParameterValue': 'F0E378A4-7FF1-4196-9892-CD98178FCA82'}, {'ParameterName': 'METHOD', 'ParameterValue': 'GETDATA'}, {'ParameterName': 'DATASETNAME', 'ParameterValue': 'MNE'}, {'ParameterName': 'RESULTFORMAT', 'ParameterValue': 'JSON'}, {'ParameterName': 'SeriesID', 'ParameterValue': 'all'}], 'response_size': 478307, 'detail': {'Table_Count': '7', 'rowTypeID': '4,10', 'InvestmentType': 'U.S. Direct Investment Abroad', 'DataType': 'Data on activities of multinational enterprises', 'Entity': 'All Foreign Affiliates (data for 2009 and forward)', 'IndustryClassification': 'NAICS', 'YearList': '2010', 'DIRECTIONOFINVESTMENT': 'OUTWARD', 'OwnershipLevel': '1', 'NonbankAffiliatesOnly': '0', 'Tables': '309,310,311,312,313,327,329', 'cnt': '1237', 'Dimensions': Ordinal Name DataType IsValue
0 1 Year numeric 0
1 2 SeriesID numeric 0
2 3 SeriesName string 0
3 4 Row string 0
4 5 Column string 0
5 6 RowCode string 0
6 7 ColumnCode string 0
7 8 TableScale string 0
8 9 DataValueUnformatted string 1
9 10 DataValue string 1, 'Notes': NoteText NoteRef
0 <strong>n.s.</strong> Not shown. Data may no... 2.00
1 ⢠The data appear on another line in this ta... 4.00
2 ⢠The data are not shown in this table but m... 6.00
3 ⢠The data are not available, do not apply, ... 8.00
4 <strong>(*)</strong> A nonzero value that roun... 10.00
5 <strong>(D)</strong> indicates that the data i... 12.00
6 Size ranges are given in employment cells that... 16.00
7 Data for each foreign affiliate are classified... 32.00
8 The composition of the "Other" categories show... 36.00
9 Source: U.S. Bureau of Economic Analysis 41.00
10 If you have a question about the availability ... 10000.00}, 'time_invariant_keys': ['SeriesID', 'RowCode', 'Row', 'ColumnCode', 'Column', 'ColumnGParentCode'], 'time_invariant_vars': ['SeriesName', 'ColumnGParent', 'ColumnParent', 'ColumnParentCode', 'TableScale'], 'time_variant_keys': ['Year', 'TableRowDisplayOrder', 'TableColumnDisplayOrder'], 'time_variant_vars': ['DataValueUnformatted', 'DataValue'], 'time_variant_only_vars': [], 'index_cols': ['SeriesID', 'RowCode', 'Row', 'ColumnCode', 'Column', 'ColumnGParentCode', 'Year', 'TableRowDisplayOrder', 'TableColumnDisplayOrder']}
MNE weirdos
[ ]:
mne_set0 = ['SeriesID', 'RowCode', 'Row', 'ColumnCode', 'Column', 'ColumnGParentCode']
bea_tbl1 = beaapi.get_data(beakey, "MNE", DirectionOfInvestment="Outward", Classification="StatebyCountryofUBO", Year="2020")
display(bea_tbl1.head(3))
print(f"duplicate ids set 1? {bea_tbl1.duplicated(subset=mne_set0).any()}")
mne_set1a = mne_set0 + ['TableRowDisplayOrder']
#display(bea_tbl1[bea_tbl1.duplicated(subset=mne_set0, keep=False)].sort_values(by=mne_set1a))
print(f"duplicate ids set 2? {bea_tbl1.duplicated(subset=mne_set1a).any()}")
print(f"just copied rows? {(bea_tbl1.duplicated(subset=mne_set0)==bea_tbl1.duplicated(subset=mne_set0 + ['DataValue'])).all()}")
bea_tbl2 = beaapi.get_data(beakey, "MNE", DirectionOfInvestment="Inward", Classification="StatebyCountryofUBO", Year="2020")
display(bea_tbl2.head(3))
print(f"duplicates set1? {bea_tbl2.duplicated(subset=mne_set0).any()}")
#display(bea_tbl2[bea_tbl2.duplicated(subset=mne_set0, keep=False)].sort_values(by=mne_set1a))
mne_set2a = mne_set1a + ['TableColumnDisplayOrder']
print(f"duplicates set2? {bea_tbl2.duplicated(subset=mne_set2a).any()}")
print(f"just re-ordering? {(bea_tbl2.duplicated(subset=mne_set1a)==bea_tbl2.duplicated(subset=mne_set1a + ['DataValue'])).all()}")
duplicates set 1? True
duplicates set 2? False
just re-ordering? True
| Year | SeriesID | SeriesName | Row | ColumnGParent | ColumnParent | Column | RowCode | ColumnCode | ColumnParentCode | ColumnGParentCode | TableScale | DataValueUnformatted | TableColumnDisplayOrder | TableRowDisplayOrder | DataValue | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 2020 | 69 | Balance Sheet of New Affiliates | All Countries Total | Assets | Total | Balance Sheet of New Affiliates | 000 | 000 | 000 | 164 | Millions of Dollars | 112521 | 1.00 | 1.00 | 112,521 |
| 1 | 2020 | 26 | Debt Instruments Inflows | All Countries Total | None | None | Debt Inflows | 000 | 0000 | 0 | 0 | Millions of Dollars | -61765 | 1.00 | 1.00 | -61,765 |
| 2 | 2020 | 64 | Employment of New Affiliates | All Countries Total | Current employment | Total | Employment of New Affiliates | 000 | 000 | 000 | 150 | Thousands of Employees | 229.8 | 1.00 | 1.00 | 229.8 |
duplicates set1? True
| Year | SeriesID | SeriesName | Row | ColumnGParent | ColumnParent | Column | RowCode | ColumnCode | ColumnParentCode | ColumnGParentCode | TableScale | DataValueUnformatted | TableColumnDisplayOrder | TableRowDisplayOrder | DataValue | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 145 | 2020 | 22 | Foreign Direct Investment Position in the Unit... | All Countries Total | None | Manufacturing | Position | 000 | 3999 | 3000 | 0 | Millions of Dollars | 503150 | 9.50 | 1.00 | 503,150 |
| 152 | 2020 | 22 | Foreign Direct Investment Position in the Unit... | All Countries Total | None | Manufacturing | Position | 000 | 3999 | 3000 | 0 | Millions of Dollars | 503150 | 10.00 | 1.00 | 503,150 |
| 153 | 2020 | 22 | Foreign Direct Investment Position in the Unit... | All Countries Total | None | None | Position | 000 | 4200 | 0 | 0 | Millions of Dollars | 447756 | 10.00 | 1.00 | 447,756 |
| 157 | 2020 | 22 | Foreign Direct Investment Position in the Unit... | All Countries Total | None | None | Position | 000 | 4200 | 0 | 0 | Millions of Dollars | 447756 | 11.00 | 1.00 | 447,756 |
| 158 | 2020 | 22 | Foreign Direct Investment Position in the Unit... | All Countries Total | None | None | Position | 000 | 4400 | 0 | 0 | Millions of Dollars | 141680 | 11.00 | 1.00 | 141,680 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 10796 | 2020 | 27 | Direct Investment Income Without Current-Cost ... | Asia and Pacific | None | None | Income | 699 | 5300 | 0 | 0 | Millions of Dollars | 1600 | 16.00 | 48.00 | 1,600 |
| 2444 | 2020 | 27 | Direct Investment Income Without Current-Cost ... | Asia and Pacific | None | None | Income | 699 | 5400 | 0 | 0 | Millions of Dollars | 348 | 15.00 | 1.86 | 348 |
| 10805 | 2020 | 27 | Direct Investment Income Without Current-Cost ... | Asia and Pacific | None | None | Income | 699 | 5400 | 0 | 0 | Millions of Dollars | 240 | 17.00 | 48.00 | 240 |
| 2446 | 2020 | 27 | Direct Investment Income Without Current-Cost ... | Asia and Pacific | None | None | Income | 699 | 9999 | 0 | 0 | Millions of Dollars | -938 | 16.00 | 1.86 | -938 |
| 10806 | 2020 | 27 | Direct Investment Income Without Current-Cost ... | Asia and Pacific | None | None | Income | 699 | 9999 | 0 | 0 | Millions of Dollars | 215 | 18.00 | 48.00 | 215 |
4523 rows × 16 columns
duplicates set2? False
just re-ordering? True
[ ]:
# Diagnosing why the second call has to depende on TableRowDisplayOrder
# Country codes https://www.bea.gov/sites/default/files/2024-01/Guide-to-Reporting-Countries-on-BEA-Surveys.pdf
bea_tbl2['DataValue'] = pd.to_numeric(bea_tbl2['DataValueUnformatted'], errors='coerce')
bea_tbl2_sml = bea_tbl2.groupby(mne_set0)['DataValue'].agg(['min', 'max']).reset_index()
bea_tbl2_sml['same'] = np.isclose(bea_tbl2_sml['max'], bea_tbl2_sml['min'], equal_nan=True)
#display(bea_tbl2_sml)
print((bea_tbl2_sml['same']==False).sum())
print((bea_tbl2.duplicated(subset=mne_set0)==bea_tbl2.duplicated(subset=mne_set0 + ['DataValue'])).all())
bea_tbl2_merge = bea_tbl2.merge(bea_tbl2_sml.drop(columns=["max", "min"]), on=mne_set0, how='left')
display(bea_tbl2_merge[bea_tbl2_merge['same']==False].sort_values(by=mne_set0))
display(bea_tbl2[bea_tbl2["DataValueUnformatted"]=="487449"])
905
False
| Year | SeriesID | SeriesName | Row | ColumnGParent | ColumnParent | Column | RowCode | ColumnCode | ColumnParentCode | ColumnGParentCode | TableScale | DataValueUnformatted | TableColumnDisplayOrder | TableRowDisplayOrder | DataValue | same | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 250 | 2020 | 22 | Foreign Direct Investment Position in the Unit... | Canada | None | None | Position | 100 | 0000 | 0 | 0 | Millions of Dollars | 569718 | 1.00 | 1.02 | 569718.0 | False |
| 2801 | 2020 | 22 | Foreign Direct Investment Position in the Unit... | Canada | None | None | Position | 100 | 0000 | 0 | 0 | Millions of Dollars | 487449 | 1.00 | 2.00 | 487449.0 | False |
| 4958 | 2020 | 22 | Foreign Direct Investment Position in the Unit... | Canada | None | None | Position | 100 | 0000 | 0 | 0 | Millions of Dollars | 569718 | 1.00 | 16.00 | 569718.0 | False |
| 253 | 2020 | 22 | Foreign Direct Investment Position in the Unit... | Canada | None | Manufacturing | Position | 100 | 3000 | 3000 | 0 | Millions of Dollars | 63468 | 2.00 | 1.02 | 63468.0 | False |
| 2808 | 2020 | 22 | Foreign Direct Investment Position in the Unit... | Canada | None | Manufacturing | Position | 100 | 3000 | 3000 | 0 | Millions of Dollars | 76858 | 2.00 | 2.00 | 76858.0 | False |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 10796 | 2020 | 27 | Direct Investment Income Without Current-Cost ... | Asia and Pacific | None | None | Income | 699 | 5300 | 0 | 0 | Millions of Dollars | 1600 | 16.00 | 48.00 | 1600.0 | False |
| 2444 | 2020 | 27 | Direct Investment Income Without Current-Cost ... | Asia and Pacific | None | None | Income | 699 | 5400 | 0 | 0 | Millions of Dollars | 348 | 15.00 | 1.86 | 348.0 | False |
| 10805 | 2020 | 27 | Direct Investment Income Without Current-Cost ... | Asia and Pacific | None | None | Income | 699 | 5400 | 0 | 0 | Millions of Dollars | 240 | 17.00 | 48.00 | 240.0 | False |
| 2446 | 2020 | 27 | Direct Investment Income Without Current-Cost ... | Asia and Pacific | None | None | Income | 699 | 9999 | 0 | 0 | Millions of Dollars | -938 | 16.00 | 1.86 | -938.0 | False |
| 10806 | 2020 | 27 | Direct Investment Income Without Current-Cost ... | Asia and Pacific | None | None | Income | 699 | 9999 | 0 | 0 | Millions of Dollars | 215 | 18.00 | 48.00 | 215.0 | False |
1947 rows × 17 columns
| Year | SeriesID | SeriesName | Row | ColumnGParent | ColumnParent | Column | RowCode | ColumnCode | ColumnParentCode | ColumnGParentCode | TableScale | DataValueUnformatted | TableColumnDisplayOrder | TableRowDisplayOrder | DataValue | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2801 | 2020 | 22 | Foreign Direct Investment Position in the Unit... | Canada | None | None | Position | 100 | 0000 | 0 | 0 | Millions of Dollars | 487449 | 1.00 | 2.00 | 487449.0 |
[ ]:
# MWE to show Ryan
bea_tbl2s = beaapi.get_data(beakey, "MNE", DirectionOfInvestment="Inward", Classification="StatebyCountryofUBO", SeriesID=22, Year="2020", Country="100")
display(bea_tbl2s[np.logical_and(bea_tbl2s['Row'] == "Canada", bea_tbl2s['ColumnCode'] == "0000")].drop(columns=["Year", "TableScale", "Row", "ColumnCode"]))
| SeriesID | SeriesName | ColumnGParent | ColumnParent | Column | RowCode | ColumnParentCode | ColumnGParentCode | DataValueUnformatted | TableColumnDisplayOrder | TableRowDisplayOrder | DataValue | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 28 | 22 | Foreign Direct Investment Position in the Unit... | None | None | Position | 100 | 0 | 0 | 569718 | 1.00 | 1.02 | 569,718 |
| 911 | 22 | Foreign Direct Investment Position in the Unit... | None | None | Position | 100 | 0 | 0 | 487449 | 1.00 | 2.00 | 487,449 |
| 1255 | 22 | Foreign Direct Investment Position in the Unit... | None | None | Position | 100 | 0 | 0 | 569718 | 1.00 | 16.00 | 569,718 |
[ ]:
# bea_tbl2sm = beaapi.get_data(beakey, "MNE", DirectionOfInvestment="Inward", Classification="StatebyCountryofUBO", SeriesID=22, Year="2020")
bea_tbl2sm['TableRowDisplayOrder_int'] = pd.to_numeric(bea_tbl2sm['TableRowDisplayOrder'], errors='coerce').astype('int') # round-down
bea_tbl2sm['RowCode_len'] = bea_tbl2sm['RowCode'].str.len()
bea_tbl2sm['RowCode_len_max'] = bea_tbl2sm.groupby(['TableRowDisplayOrder_int'])['RowCode_len'].transform('max').values
display(bea_tbl2sm.groupby(['TableRowDisplayOrder_int'])['RowCode_len'].agg(['max']))
display(bea_tbl2sm)
#display(bea_tbl2sm[np.logical_and(bea_tbl2sm['Row'] == "Malaysia", bea_tbl2sm['ColumnCode'] == "0000")].drop(columns=["Year", "TableScale", "Row", "ColumnCode"]))
Year int64
SeriesID int64
SeriesName string
Row string
ColumnGParent string
ColumnParent string
Column string
RowCode string
ColumnCode string
ColumnParentCode string
ColumnGParentCode string
TableScale string
DataValueUnformatted string
TableColumnDisplayOrder string
TableRowDisplayOrder string
DataValue string
TableRowDisplayOrder_int int32
RowCode_len Int64
RowCode_len_max Int64
dtype: object
| max | |
|---|---|
| TableRowDisplayOrder_int | |
| 1 | 4 |
| 2 | 4 |
| 3 | 4 |
| 4 | 4 |
| 5 | 4 |
| ... | ... |
| 335 | 4 |
| 336 | 4 |
| 337 | 4 |
| 338 | 1 |
| 339 | 4 |
332 rows × 1 columns
((2712, 19), (2712,))
| Year | SeriesID | SeriesName | Row | ColumnGParent | ColumnParent | Column | RowCode | ColumnCode | ColumnParentCode | ColumnGParentCode | TableScale | DataValueUnformatted | TableColumnDisplayOrder | TableRowDisplayOrder | DataValue | TableRowDisplayOrder_int | RowCode_len | RowCode_len_max | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 2020 | 22 | Foreign Direct Investment Position in the Unit... | All Countries Total | None | None | Position | 000 | 0000 | 0 | 0 | Millions of Dollars | 4613481 | 1.00 | 1.00 | 4,613,481 | 1 | 3 | 4 |
| 1 | 2020 | 22 | Foreign Direct Investment Position in the Unit... | All Industries Total | None | None | Position | 0000 | 000 | 0 | 0 | Millions of Dollars | 4613481 | 1.00 | 1.00 | 4,613,481 | 1 | 4 | 4 |
| 2 | 2020 | 22 | Foreign Direct Investment Position in the Unit... | All Countries Total | None | Manufacturing | Position | 000 | 3000 | 3000 | 0 | Millions of Dollars | 1924468 | 2.00 | 1.00 | 1,924,468 | 1 | 3 | 4 |
| 3 | 2020 | 22 | Foreign Direct Investment Position in the Unit... | All Countries Total | None | Manufacturing | Position | 000 | 3110 | 3000 | 0 | Millions of Dollars | 112432 | 3.00 | 1.00 | 112,432 | 1 | 3 | 4 |
| 4 | 2020 | 22 | Foreign Direct Investment Position in the Unit... | All Countries Total | None | Manufacturing | Position | 000 | 3250 | 3000 | 0 | Millions of Dollars | 728731 | 4.00 | 1.00 | 728,731 | 1 | 3 | 4 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 2707 | 2020 | 22 | Foreign Direct Investment Position in the Unit... | Personal and laundry services | None | None | Position | 8120 | 000 | 0 | 0 | Millions of Dollars | 2039 | 1.00 | 336.00 | 2,039 | 336 | 4 | 4 |
| 2708 | 2020 | 22 | Foreign Direct Investment Position in the Unit... | Religious, grantmaking, civic, professional, a... | None | None | Position | 8130 | 000 | 0 | 0 | Millions of Dollars | -1 | 1.00 | 337.00 | -1 | 337 | 4 | 4 |
| 2709 | 2020 | 22 | Foreign Direct Investment Position in the Unit... | Public administration | None | None | Position | 000 | 0 | 0 | Millions of Dollars | 0 | 1.00 | 337.50 | 0 | 337 | 1 | 4 | |
| 2710 | 2020 | 22 | Foreign Direct Investment Position in the Unit... | Addendum: | None | None | Position | 000 | 0 | 0 | Millions of Dollars | n.a. | 1.00 | 338.00 | n.a. | 338 | 1 | 1 | |
| 2711 | 2020 | 22 | Foreign Direct Investment Position in the Unit... | Petroleum | None | None | Position | 8999 | 000 | 0 | 0 | Millions of Dollars | 235326 | 1.00 | 339.00 | 235,326 | 339 | 4 | 4 |
2712 rows × 19 columns
FixedAssets¶
[8]:
bea_tbl = beaapi.get_data(beakey, 'FixedAssets', Year='2020', TableName="FAAt201")
display(bea_tbl.head(2))
print(bea_tbl.attrs)
| TableName | SeriesCode | LineNumber | LineDescription | TimePeriod | METRIC_NAME | CL_UNIT | UNIT_MULT | DataValue | NoteRef | |
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | FAAt201 | k1ptotl1es00 | 1 | Private fixed assets | 2020 | Current Dollars | Level | 6 | 51906171 | FAAt201 |
| 1 | FAAt201 | k1ptotl1eq00 | 2 | Equipment | 2020 | Current Dollars | Level | 6 | 7526475 | FAAt201 |
{'params': [{'ParameterName': 'YEAR', 'ParameterValue': '2020'}, {'ParameterName': 'TABLENAME', 'ParameterValue': 'FAAT201'}, {'ParameterName': 'USERID', 'ParameterValue': 'F0E378A4-7FF1-4196-9892-CD98178FCA82'}, {'ParameterName': 'METHOD', 'ParameterValue': 'GETDATA'}, {'ParameterName': 'DATASETNAME', 'ParameterValue': 'FIXEDASSETS'}, {'ParameterName': 'RESULTFORMAT', 'ParameterValue': 'JSON'}], 'response_size': 29004, 'detail': {'Statistic': 'NIPA Table', 'UTCProductionTime': '2025-06-27T12:50:30.020', 'Dimensions': Ordinal Name DataType IsValue
0 1 TableName string 0
1 2 SeriesCode string 0
2 3 LineNumber numeric 0
3 4 LineDescription string 0
4 5 TimePeriod string 0
5 6 CL_UNIT string 0
6 7 UNIT_MULT numeric 0
7 8 METRIC_NAME string 0
8 9 DataValue numeric 1, 'Notes': NoteRef NoteText
0 FAAT201 Table 2.1. Current-Cost Net Stock of Private F...
1 FAAT201.1 1. Consists of office buildings, except those ...
2 FAAT201.10 10. Includes private universities and colleges...
3 FAAT201.11 n.e.c. Not elsewhere classified
4 FAAT201.2 2. Includes buildings and structures used by t...
5 FAAT201.3 3. Consists primarily of railroads.
6 FAAT201.4 4. Includes water supply, sewage and waste dis...
7 FAAT201.5 5. Consists of brokers' commissions on sale of...
8 FAAT201.6 6. Consists primarily of dormitories and of fr...
9 FAAT201.7 7. Excludes software "embedded" or bundled in ...
10 FAAT201.8 8. Research and development (R&D) asset ty...
11 FAAT201.9 9. R&D net stock excludes software develop...}, 'time_invariant_keys': ['SeriesCode', 'LineNumber'], 'time_invariant_vars': ['TableName', 'LineDescription', 'METRIC_NAME', 'CL_UNIT', 'UNIT_MULT', 'NoteRef'], 'time_variant_keys': ['TimePeriod'], 'time_variant_vars': ['DataValue'], 'time_variant_only_vars': [], 'index_cols': ['SeriesCode', 'LineNumber', 'TimePeriod'], 'release_date': datetime.date(2024, 10, 2)}
[37]:
class_MNE = beaapi.get_parameter_values(beakey, 'MNE', 'Classification')
print(class_MNE)
key \
0 Country
1 CountryByDestination
2 CountryByIndustry
3 CountrybyType
4 CountryofUBO
5 CountryofUBObyDestination
6 CountryofUBObyIndustry
7 countryofUBObyType
8 Industry
9 IndustryByCountry
10 IndustrybyCountryofUBO
11 IndustryByDestination
12 IndustrybyType
13 IndustryofSales
14 IndustryofUSParent
15 IndustryofUSParentAllIndustries
16 IndustryofUSParentByCountry
17 StatebyCountryofUBO
18 StatebyType
19 TypeofExpenditure
desc
0 Set to classification equal to 'country' to ob...
1 CountryByDestination returns values for countr...
2 CountryByIndustry provides data for a large se...
3 Country by Type of Investment returns data on ...
4 â Presents data on foreign direct investment...
5 Presents data on services supplied by U.S. aff...
6 Presents data on foreign direct investment in ...
7 Country of UBO by Type of Investment returns d...
8 Set to classification equal to 'industry' to o...
9 IndustryByCountry provides data for a large se...
10 Presents foreign direct investment data broken...
11 IndustryByDestination returns values for indus...
12 Industry by Type of Investment returns data on...
13 Industry of Sales provides data on employment ...
14 = IndustryofUSParent provides data for foreign...
15 IndustryofUSParentAllIndustries provides data ...
16 IndustryofUSParentByCountry provides data for ...
17 Presents selected activities of multinational ...
18 State by Type of Investment returns data on ne...
19 Type of Expenditure returns values on investme...
ITA¶
[12]:
# One indicator
#bea_tbl = beaapi.get_data(beakey, "ITA", Indicator="BalCapAcct", Year="2020")
#display(bea_tbl.head(2))
#print(bea_tbl.attrs)
bea_tbl = beaapi.get_data(beakey, "ITA", Indicator='ExpGdsAutoEngAndEngParts', Frequency="A", Year="2020", AreaOrCountry="All")
display(bea_tbl.head(3))
print(bea_tbl.attrs)
## One Area
#bea_tbl = beaapi.get_data(beakey, "ITA", AreaOrCountry="Canada")
#display(bea_tbl.head(2))
#print(bea_tbl.attrs)
| Indicator | AreaOrCountry | Frequency | Year | TimeSeriesId | TimeSeriesDescription | TimePeriod | CL_UNIT | UNIT_MULT | DataValue | NoteRef | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | ExpGdsAutoEngAndEngParts | AllOthThanCanada | A | 2020 | TSI_ItaExpGdsAutoEngAndEngPartsAllOthThanCanada_A | Exports of automotive engines and engine parts... | 2020 | USD | 6 | 12075 | |
| 1 | ExpGdsAutoEngAndEngParts | Canada | A | 2020 | TSI_ItaExpGdsAutoEngAndEngPartsCanada_A | Exports of automotive engines and engine parts... | 2020 | USD | 6 | 5211 |
{'params': [{'ParameterName': 'INDICATOR', 'ParameterValue': 'EXPGDSAUTOENGANDENGPARTS'}, {'ParameterName': 'FREQUENCY', 'ParameterValue': 'A'}, {'ParameterName': 'YEAR', 'ParameterValue': '2020'}, {'ParameterName': 'AREAORCOUNTRY', 'ParameterValue': 'ALL'}, {'ParameterName': 'USERID', 'ParameterValue': 'F0E378A4-7FF1-4196-9892-CD98178FCA82'}, {'ParameterName': 'METHOD', 'ParameterValue': 'GETDATA'}, {'ParameterName': 'DATASETNAME', 'ParameterValue': 'ITA'}, {'ParameterName': 'RESULTFORMAT', 'ParameterValue': 'JSON'}], 'response_size': 2002, 'detail': {'TsLastUpdated': '2025-06-24 08:30:00.000', 'Dimensions': Ordinal Name DataType IsValue
0 1 Indicator string 0
1 2 AreaOrCountry string 0
2 3 Frequency string 0
3 4 Year string 0
4 5 TimeSeriesId string 0
5 6 TimeSeriesDescription string 0
6 7 TimePeriod string 0
7 8 CL_UNIT string 0
8 9 UNIT_MULT string 0
9 10 DataValue numeric 1}, 'time_invariant_keys': ['Indicator', 'AreaOrCountry', 'Frequency'], 'time_invariant_vars': ['TimeSeriesId', 'TimeSeriesDescription', 'CL_UNIT', 'UNIT_MULT'], 'time_variant_keys': ['TimePeriod'], 'time_variant_vars': ['DataValue', 'NoteRef'], 'time_variant_only_vars': ['Year'], 'index_cols': ['Indicator', 'AreaOrCountry', 'Frequency', 'TimePeriod'], 'release_date': datetime.datetime(2025, 6, 24, 8, 30)}
IIP¶
[ ]:
#year_IIP = beaapi.get_parameter_values(beakey, 'IIP', 'Year')
#print(year_IIP)
bea_tbl = beaapi.get_data(beakey, "IIP", Year="2020")
display(bea_tbl.head(2))
print(bea_tbl.attrs)
| TypeOfInvestment | Component | Frequency | Year | TimeSeriesId | TimeSeriesDescription | TimePeriod | CL_UNIT | UNIT_MULT | DataValue | NoteRef | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | CurrAndDepAssets | ChgPos | A | 2020 | TSI_IipCurrAndDepAssetsChgPos_A | U.S. assets; other investment; currency and de... | 2020 | USD | 6 | 132685.0 | |
| 1 | CurrAndDepAssets | ChgPosNie | A | 2020 | TSI_IipCurrAndDepAssetsChgPosNie_A | U.S. assets; other investment; currency and de... | 2020 | USD | 6 | 3500.0 | IIP1.3:2 |
{'params': [{'ParameterName': 'YEAR', 'ParameterValue': '2020'}, {'ParameterName': 'USERID', 'ParameterValue': 'F0E378A4-7FF1-4196-9892-CD98178FCA82'}, {'ParameterName': 'METHOD', 'ParameterValue': 'GETDATA'}, {'ParameterName': 'DATASETNAME', 'ParameterValue': 'IIP'}, {'ParameterName': 'RESULTFORMAT', 'ParameterValue': 'JSON'}, {'ParameterName': 'TypeOfInvestment', 'ParameterValue': 'ALL'}, {'ParameterName': 'Component', 'ParameterValue': 'ALL'}, {'ParameterName': 'Frequency', 'ParameterValue': 'ALL'}], 'response_size': 772250, 'detail': {'TsLastUpdated': '2025-03-26 08:30:00.000', 'Dimensions': Ordinal Name DataType IsValue
0 1 TypeOfInvestment string 0
1 2 Component string 0
2 4 Frequency string 0
3 5 Year string 0
4 6 TimeSeriesId string 0
5 7 TimeSeriesDescription string 0
6 8 TimePeriod string 0
7 9 CL_UNIT string 0
8 10 UNIT_MULT string 0
9 11 DataValue numeric 1, 'Notes': NoteRef NoteText
0 ..... Not applicable
1 0 Transactions or other changes are possible but...
2 IIP1.3:1 Represents gains or losses on foreign-currency...
3 IIP1.3:2 Changes in volume and valuation n.i.e. (not in...
4 IIP1.3:3 Financial transactions and other changes in fi...
5 IIP1.3:4 Data are not separately available for price ch...
6 IIP2.1:1 Positions on an asset/liability basis are orga...
7 IIP2.1:2 Positions on a directional basis are organized...
8 IIP2.2:1 Positions on an asset/liability basis are orga...
9 IIP2.2:2 U.S. affiliates' foreign parent group members ...
10 IIP2.2:3 U.S. parents can be U.S. SPEs, but such SPEs a...
11 IIP4.1:0 Positions are possible but are zero for a give...
12 IIP4.1:1 Includes commingled original and remaining mat...
13 IIP4.1:2 Corresponds to debt instruments in the direct ...
14 IIP4.1:3 Includes all reserve assets, including monetar...
15 n.a. Not available}, 'time_invariant_keys': ['Frequency', 'TypeOfInvestment', 'Component'], 'time_invariant_vars': ['TimeSeriesId', 'TimeSeriesDescription', 'CL_UNIT', 'UNIT_MULT'], 'time_variant_keys': ['TimePeriod'], 'time_variant_vars': ['DataValue', 'NoteRef'], 'time_variant_only_vars': ['Year'], 'index_cols': ['Frequency', 'TypeOfInvestment', 'Component', 'TimePeriod'], 'release_date': datetime.datetime(2025, 3, 26, 8, 30)}
InputOutput¶
[ ]:
bea_tbl = beaapi.get_data(beakey, 'InputOutput', Year="2010", tableID="56")
display(bea_tbl.head(2))
print(bea_tbl.attrs)
| TableID | Year | RowCode | RowDescr | RowType | ColCode | ColDescr | ColType | DataValue | NoteRef | |
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 56 | 2010 | Total industry output requirement | Industry | Used | Scrap, used and secondhand goods | Commodity | 1.988514 | 56 | |
| 1 | 56 | 2010 | Total industry output requirement | Industry | PROF | Professional and business services | Commodity | 1.595640 | 56 |
{'params': [{'ParameterName': 'YEAR', 'ParameterValue': '2010'}, {'ParameterName': 'TABLEID', 'ParameterValue': '56'}, {'ParameterName': 'USERID', 'ParameterValue': 'F0E378A4-7FF1-4196-9892-CD98178FCA82'}, {'ParameterName': 'METHOD', 'ParameterValue': 'GETDATA'}, {'ParameterName': 'DATASETNAME', 'ParameterValue': 'INPUTOUTPUT'}, {'ParameterName': 'RESULTFORMAT', 'ParameterValue': 'JSON'}], 'response_size': 63226, 'detail': {'Statistic': 'Input-Output Table', 'UTCProductionTime': '2025-06-27T12:49:50.750', 'Dimensions': Ordinal Name DataType IsValue
0 1 TableID numeric 0
1 2 Year string 0
2 3 RowCode string 0
3 4 RowDescr string 0
4 5 RowType string 0
5 6 ColCode string 0
6 7 ColDescr string 0
7 8 ColType string 0
8 9 DataValue numeric 1, 'Notes': NoteText NoteRef
0 Note. Detail may not add to total due to round... <NA>
1 Industry-by-Commodity Total Requirements, Afte... 6003}, 'time_invariant_keys': ['TableID', 'RowCode', 'ColCode'], 'time_invariant_vars': ['RowDescr', 'RowType', 'ColType', 'ColDescr', 'NoteRef'], 'time_variant_keys': ['Year'], 'time_variant_vars': ['DataValue'], 'time_variant_only_vars': [], 'index_cols': ['TableID', 'RowCode', 'ColCode', 'Year']}
IntlServTrade¶
[35]:
bea_tbl = beaapi.get_data(beakey, "IntlServTrade", AreaOrCountry="Canada")
display(bea_tbl.head(2))
print(bea_tbl.attrs)
| TypeOfService | TradeDirection | Affiliation | AreaOrCountry | Year | TimeSeriesId | TimeSeriesDescription | TimePeriod | CL_UNIT | UNIT_MULT | DataValue | NoteRef | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | AccountAuditBookkeep | Exports | AllAffiliations | Canada | 1999 | TSI_IstAccountAuditBookkeepExpCanadaAllAff_A | Exports of accounting, auditing, and bookkeepi... | 1999 | USD | 6 | NaN | n.a. |
| 1 | AccountAuditBookkeep | Exports | AllAffiliations | Canada | 2000 | TSI_IstAccountAuditBookkeepExpCanadaAllAff_A | Exports of accounting, auditing, and bookkeepi... | 2000 | USD | 6 | NaN | n.a. |
{'params': [{'ParameterName': 'AREAORCOUNTRY', 'ParameterValue': 'CANADA'}, {'ParameterName': 'USERID', 'ParameterValue': 'F0E378A4-7FF1-4196-9892-CD98178FCA82'}, {'ParameterName': 'METHOD', 'ParameterValue': 'GETDATA'}, {'ParameterName': 'DATASETNAME', 'ParameterValue': 'INTLSERVTRADE'}, {'ParameterName': 'RESULTFORMAT', 'ParameterValue': 'JSON'}, {'ParameterName': 'TypeOfService', 'ParameterValue': 'ALL'}, {'ParameterName': 'TradeDirection', 'ParameterValue': 'ALL'}, {'ParameterName': 'Affiliation', 'ParameterValue': 'ALL'}, {'ParameterName': 'Year', 'ParameterValue': 'ALL'}], 'response_size': 2046433, 'detail': {'TsLastUpdated': '2024-07-03 10:00:00.000', 'EarliestFullYear': '1999', 'LatestFullYear': '2023', 'Dimensions': Ordinal Name DataType IsValue
0 1 TypeOfService string 0
1 2 TradeDirection string 0
2 3 Affiliation string 0
3 4 AreaOrCountry string 0
4 5 Year string 0
5 6 TimeSeriesId string 0
6 7 TimeSeriesDescription string 0
7 8 TimePeriod string 0
8 9 CL_UNIT string 0
9 10 UNIT_MULT string 0
10 11 DataValue numeric 1, 'Notes': NoteRef NoteText
0 (*) Transactions between zero and +/- $500,000.
1 (D) Suppressed to avoid the disclosure of data of ...
2 0 Transactions are possible but are zero for a g...
3 IntlServ2.2:1 Courier services are included in "Air transpor...
4 IntlServ2.2:2 Insurance services transactions are considered...
5 IntlServ2.2:3 Outcomes of research and development include p...
6 IntlServ2.2:4 This category includes installation, alteratio...
7 IntlServ2.3:1 Courier services are included in "Air transpor...
8 IntlServ2.3:2 Insurance services transactions are considered...
9 IntlServ2.3:3 Outcomes of research and development include p...
10 IntlServ2.3:4 This category includes installation, alteratio...
11 n.a. Transactions are possible, but data are not av...}, 'time_invariant_keys': ['TypeOfService', 'TradeDirection', 'Affiliation', 'AreaOrCountry'], 'time_invariant_vars': ['TimeSeriesId', 'TimeSeriesDescription', 'CL_UNIT', 'UNIT_MULT'], 'time_variant_keys': ['TimePeriod'], 'time_variant_vars': ['DataValue', 'NoteRef'], 'time_variant_only_vars': ['Year'], 'index_cols': ['TypeOfService', 'TradeDirection', 'Affiliation', 'AreaOrCountry', 'TimePeriod'], 'release_date': datetime.datetime(2024, 7, 3, 10, 0)}
IntlServSTA¶
[14]:
bea_tbl = beaapi.get_data(beakey, 'IntlServSTA', Year="2020")
display(bea_tbl.head(3))
print(bea_tbl.attrs)
| Channel | Destination | Industry | AreaOrCountry | Year | TimeSeriesId | TimeSeriesDescription | TimePeriod | CL_UNIT | UNIT_MULT | DataValue | NoteRef | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | AllChannels | AllForeign | AllInd | AllCountries | 2020 | TSI_SstaServicesSuppliedByUsFirmsToForeignPers... | Services supplied by U.S.-based firms to forei... | 2020 | USD | 6 | 2265072.0 | |
| 1 | AllChannels | AllUs | AllInd | AllCountries | 2020 | TSI_SstaServicesSuppliedToUsPersonsByForeignFi... | Services supplied to U.S. persons by foreign-b... | 2020 | USD | 6 | 1317130.0 | |
| 2 | Mofas | AllForeign | Accommodation | AllCountries | 2020 | TSI_SstaMofasAllForeignAccommodationAllCountri... | Services supplied through MOFAs in accommodati... | 2020 | USD | 6 | 10154.0 |
{'params': [{'ParameterName': 'YEAR', 'ParameterValue': '2020'}, {'ParameterName': 'USERID', 'ParameterValue': 'F0E378A4-7FF1-4196-9892-CD98178FCA82'}, {'ParameterName': 'METHOD', 'ParameterValue': 'GETDATA'}, {'ParameterName': 'DATASETNAME', 'ParameterValue': 'INTLSERVSTA'}, {'ParameterName': 'RESULTFORMAT', 'ParameterValue': 'JSON'}, {'ParameterName': 'Channel', 'ParameterValue': 'ALL'}, {'ParameterName': 'Destination', 'ParameterValue': 'ALL'}, {'ParameterName': 'Industry', 'ParameterValue': 'ALL'}, {'ParameterName': 'AreaOrCountry', 'ParameterValue': 'AllCountries'}], 'response_size': 528632, 'detail': {'TsLastUpdated': '2024-10-08 10:00:00.000', 'EarliestFullYear': '2013', 'LatestFullYear': '2022', 'Dimensions': Ordinal Name DataType IsValue
0 1 TypeOfService string 0
1 2 TradeDirection string 0
2 3 Affiliation string 0
3 4 AreaOrCountry string 0
4 5 Year string 0
5 6 TimeSeriesId string 0
6 7 TimeSeriesDescription string 0
7 8 TimePeriod string 0
8 9 CL_UNIT string 0
9 10 UNIT_MULT string 0
10 11 DataValue numeric 1, 'Notes': NoteRef NoteText
0 (*) Transactions between zero and +/- $500,000.
1 (D) Suppressed to avoid the disclosure of data of ...
2 0 Transactions are possible but are zero for a g...
3 IntlServ1.1:1 U.S. exports by MOUSAs of foreign MNEs are inc...
4 IntlServ1.1:2 For 1986-1988, these statistics are rounded to...
5 IntlServ1.1:3 For 1986-1988, the statistics have been adjust...
6 IntlServ1.1:4 Prior to 1999, sales by foreign affiliates wer...
7 IntlServ1.1:5 Prior to 2004, services provided by bank affil...
8 IntlServ1.1:6 The large increase in 2014 can be mostly attri...
9 IntlServ1.1:7 U.S. imports from MOFAs of U.S. MNEs are subtr...
10 IntlServ1.1:8 Prior to 1997, sales by U.S. affiliates were c...
11 IntlServ4.1:1 Beginning in 2019, data for wired telecommunic...
12 IntlServ4.1:2 Because sales resulting from construction acti...
13 IntlServ4.2:1 Services supplied by an affiliate to persons i...
14 IntlServ4.2:2 Services supplied by an affiliate to persons i...
15 IntlServ4.2:3 These only include transactions with foreign a...
16 IntlServ4.3:1 Services supplied by an affiliate to persons i...
17 IntlServ4.3:2 Services supplied by an affiliate to persons i...
18 IntlServ4.3:3 These only include transactions with foreign a...
19 IntlServ4.3:4 Beginning in 2019, data for wired telecommunic...
20 IntlServ4.3:5 Because sales resulting from construction acti...
21 IntlServ5.1:1 This industry was reclassified, beginning in 2...
22 IntlServ5.1:2 This industry was reclassified, beginning in 2...
23 IntlServ5.1:3 For 2002-2016, data for wired telecommunicatio...
24 IntlServ5.1:4 Because sales resulting from construction acti...
25 IntlServ5.3:1 This industry was reclassified, beginning in 2...
26 IntlServ5.3:2 This industry was reclassified, beginning in 2...
27 IntlServ5.3:3 For 2002-2016, data for wired telecommunicatio...
28 IntlServ5.3:4 Because sales resulting from construction acti...
29 n.a. Transactions are possible, but data are not av...}, 'time_invariant_keys': ['Channel', 'Destination', 'Industry', 'AreaOrCountry'], 'time_invariant_vars': ['TimeSeriesId', 'TimeSeriesDescription', 'CL_UNIT', 'UNIT_MULT'], 'time_variant_keys': ['TimePeriod'], 'time_variant_vars': ['DataValue', 'NoteRef'], 'time_variant_only_vars': ['Year'], 'index_cols': ['Channel', 'Destination', 'Industry', 'AreaOrCountry', 'TimePeriod'], 'release_date': datetime.datetime(2024, 10, 8, 10, 0)}
GDPbyIndustry¶
[ ]:
bea_tbl = beaapi.get_data(beakey, 'GDPbyIndustry', Year='2020', Industry='ALL', tableID='1', Frequency="Q")
display(bea_tbl.head(2))
print(bea_tbl.attrs)
| TableID | Frequency | Year | Quarter | Industry | IndustrYDescription | DataValue | NoteRef | |
|---|---|---|---|---|---|---|---|---|
| 0 | 1 | Q | 2020 | I | 11 | Agriculture, forestry, fishing, and hunting | 175.7 | 1 |
| 1 | 1 | Q | 2020 | I | 111CA | Farms | 131.6 | 1 |
{'params': [{'ParameterName': 'YEAR', 'ParameterValue': '2020'}, {'ParameterName': 'INDUSTRY', 'ParameterValue': 'ALL'}, {'ParameterName': 'TABLEID', 'ParameterValue': '1'}, {'ParameterName': 'FREQUENCY', 'ParameterValue': 'Q'}, {'ParameterName': 'USERID', 'ParameterValue': 'F0E378A4-7FF1-4196-9892-CD98178FCA82'}, {'ParameterName': 'METHOD', 'ParameterValue': 'GETDATA'}, {'ParameterName': 'DATASETNAME', 'ParameterValue': 'GDPBYINDUSTRY'}, {'ParameterName': 'RESULTFORMAT', 'ParameterValue': 'JSON'}], 'response_size': 68239, 'detail': {'Statistic': 'GDP by Industry Table', 'UTCProductionTime': '2025-06-27T12:48:06.283', 'Dimensions': Ordinal Name DataType IsValue
0 1 TableID numeric 0
1 2 Frequency string 0
2 3 Year string 0
3 4 Quarter string 0
4 5 Industry string 0
5 6 IndustryDescription string 0
6 7 DataValue numeric 1, 'Notes': NoteRef NoteText
0 1.1.Q 1. Consists of agriculture, forestry, fishing,...
1 1.2.Q 2. Consists of utilities; wholesale trade; ret...
2 1.3.Q 3. Consists of computer and electronic product...
3 1.0.Q Note. Detail may not add to total due to round...
4 1 Value Added by Industry [Billions of dollars]}, 'time_invariant_keys': ['TableID', 'Industry', 'IndustrYDescription'], 'time_invariant_vars': ['NoteRef'], 'time_variant_keys': ['Frequency', 'Year', 'Quarter'], 'time_variant_vars': ['DataValue'], 'time_variant_only_vars': [], 'index_cols': ['TableID', 'Industry', 'IndustrYDescription', 'Frequency', 'Year', 'Quarter']}
Regional¶
[32]:
print("1 linecode")
bea_tbl = beaapi.get_data(beakey, 'Regional', TableName="CAGDP1", LineCode="1", Year="2020", GeoFips="State")
display(bea_tbl.head(2))
print(bea_tbl.attrs)
#print("1 geo")
#bea_tbl = beaapi.get_data(beakey, 'Regional', TableName="CAGDP1", LineCode="All", Year="2020", GeoFips="00000")
#display(bea_tbl.head(2))
#print(bea_tbl.attrs)
1 linecode
| Code | GeoFips | GeoName | TimePeriod | CL_UNIT | UNIT_MULT | DataValue | |
|---|---|---|---|---|---|---|---|
| 0 | CAGDP1-1 | 00000 | United States | 2020 | Thousands of chained 2017 dollars | 3 | 20267585000 |
| 1 | CAGDP1-1 | 01000 | Alabama | 2020 | Thousands of chained 2017 dollars | 3 | 222288753 |
{'params': [{'ParameterName': 'TABLENAME', 'ParameterValue': 'CAGDP1'}, {'ParameterName': 'LINECODE', 'ParameterValue': '1'}, {'ParameterName': 'YEAR', 'ParameterValue': '2020'}, {'ParameterName': 'GEOFIPS', 'ParameterValue': 'STATE'}, {'ParameterName': 'USERID', 'ParameterValue': 'F0E378A4-7FF1-4196-9892-CD98178FCA82'}, {'ParameterName': 'METHOD', 'ParameterValue': 'GETDATA'}, {'ParameterName': 'DATASETNAME', 'ParameterValue': 'REGIONAL'}, {'ParameterName': 'RESULTFORMAT', 'ParameterValue': 'JSON'}], 'response_size': 11405, 'detail': {'Statistic': 'Real Gross Domestic Product (GDP)', 'UnitOfMeasure': 'Thousands of chained 2017 dollars', 'PublicTable': 'CAGDP1 County and MSA gross domestic product (GDP) summary', 'UTCProductionTime': '2025-06-27T13:13:35.550', 'NoteRef': ' ', 'Dimensions': Name DataType IsValue
0 Code string 0
1 GeoFips string 0
2 GeoName string 0
3 TimePeriod string 0
4 DataValue numeric 1
5 CL_UNIT string 0
6 UNIT_MULT numeric 0, 'Notes': NoteRef NoteText
0 Metropolitan Areas are defined (geographically...
1 Last updated: December 4, 2024-- new statistic...}, 'time_invariant_keys': ['Code', 'GeoFips'], 'time_invariant_vars': ['GeoName', 'CL_UNIT', 'UNIT_MULT'], 'time_variant_keys': ['TimePeriod'], 'time_variant_vars': ['DataValue'], 'time_variant_only_vars': [], 'index_cols': ['Code', 'GeoFips', 'TimePeriod'], 'release_date': datetime.date(2024, 12, 4)}
underlyingGDPbyIndustry¶
[15]:
bea_tbl = beaapi.get_data(beakey, 'underlyingGDPbyIndustry', Year='2020', Industry='ALL', tableID='210', Frequency="A")
display(bea_tbl.head(2))
print(bea_tbl.attrs)
| TableID | Frequency | Year | Industry | IndustrYDescription | DataValue | NoteRef | |
|---|---|---|---|---|---|---|---|
| 0 | 210 | A | 2020 | 11 | Agriculture, forestry, fishing, and hunting | 162.9 | 210 |
| 1 | 210 | A | 2020 | 111 | Crop production | 51.7 | 210 |
{'params': [{'ParameterName': 'YEAR', 'ParameterValue': '2020'}, {'ParameterName': 'INDUSTRY', 'ParameterValue': 'ALL'}, {'ParameterName': 'TABLEID', 'ParameterValue': '210'}, {'ParameterName': 'FREQUENCY', 'ParameterValue': 'A'}, {'ParameterName': 'USERID', 'ParameterValue': 'F0E378A4-7FF1-4196-9892-CD98178FCA82'}, {'ParameterName': 'METHOD', 'ParameterValue': 'GETDATA'}, {'ParameterName': 'DATASETNAME', 'ParameterValue': 'UNDERLYINGGDPBYINDUSTRY'}, {'ParameterName': 'RESULTFORMAT', 'ParameterValue': 'JSON'}], 'response_size': 33360, 'detail': {'Statistic': 'GDP by Industry Table', 'UTCProductionTime': '2025-06-27T14:32:04.730', 'Dimensions': Ordinal Name DataType IsValue
0 1 TableID numeric 0
1 2 Frequency string 0
2 3 Year string 0
3 4 Quarter string 0
4 5 Industry string 0
5 6 IndustryDescription string 0
6 7 DataValue numeric 1, 'Notes': NoteRef NoteText
0 210.1.A 1. Consists of agriculture, forestry, fishing,...
1 210.2.A 2. Consists of utilities; wholesale trade; ret...
2 210.3.A 3. Consists of computer and electronic product...
3 210.0.A Note. Detail may not add to total due to round...
4 210.0.A Note. The Bureau of Economic Analysis does not...
5 210 U.Value Added by Industry [Billions of dollars]}, 'time_invariant_keys': ['TableID', 'Industry'], 'time_invariant_vars': ['Frequency', 'IndustrYDescription', 'NoteRef'], 'time_variant_keys': ['Year'], 'time_variant_vars': ['DataValue'], 'time_variant_only_vars': [], 'index_cols': ['TableID', 'Industry', 'Year']}