mario.Database.to_region_subset#
Keep a selected subset of regions explicit while treating the remaining
regions as exogenous imports and exports. This generalizes
Database.to_single_region(...) to the case where more than one region must
remain endogenous.
- Database.to_region_subset(regions, inplace=True, trade_mode='aggregate')#
Keep one explicit region subset and externalize the remaining regions.
- Parameters:
regions – One region label or an iterable of region labels to keep explicit.
inplace – When
True, mutate the current database. WhenFalse, return a transformed copy.trade_mode –
"aggregate"collapses the excluded regions into one aggregated imports row plus export categories."by_region"keeps one explicit import row and one explicit export category per excluded region.
- Returns:
Transformed database when
inplace=False, otherwiseNone.- Return type:
Database | None
Notes
The selected regions keep their endogenous transactions with each other. All excluded regions are moved outside the endogenous system and are represented as exogenous imports and exports.
Use
trade_mode="aggregate"to collapse the excluded regions into a singleimportsrow plus aggregate export categories, ortrade_mode="by_region"to preserve one import row and one export category per excluded region.Examples
Keep
ITandFRexplicit while treating the remaining regions as exogenous trade:subset = db.to_region_subset(["IT", "FR"], inplace=False)
Keep the same subset but preserve exogenous trade partner detail:
subset = db.to_region_subset( ["IT", "FR"], inplace=False, trade_mode="by_region", )