Import data from Table of Input-Output from IBGE
Project description
Imput Output Tables to Brazil IOTBR
Generate I O - T A B L E IOTBR.
Instructions
! pip install iotbr==0.0.3
from iotbr import tru as tru
from iotbr import tru_pb as tru_pb
Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/
Collecting iotbr==0.0.3
Downloading iotbr-0.0.3-py3-none-any.whl (7.2 MB)
[2K [90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━[0m [32m7.2/7.2 MB[0m [31m38.7 MB/s[0m eta [36m0:00:00[0m
[?25hRequirement already satisfied: xlrd in /usr/local/lib/python3.10/dist-packages (from iotbr==0.0.3) (2.0.1)
Installing collected packages: iotbr
Successfully installed iotbr-0.0.3
#ler uma variável qualquer dentro da tru
tru.read_var()
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</style>
PT | |
---|---|
produtos | |
Arroz, trigo e outros cereais | 12631 |
Milho em grão | 43663 |
Algodão herbáceo, outras fibras da lav. temporária | 18376 |
Cana-de-açúcar | 57068 |
Soja em grão | 153331 |
... | ... |
Serviços de artes, cultura, esporte e recreação | 45636 |
Organizações patronais, sindicais e outros serviços associativos | 93816 |
Manutenção de computadores, telefones e objetos domésticos | 33107 |
Serviços pessoais | 62283 |
Serviços domésticos | 75158 |
128 rows × 1 columns
<svg xmlns="http://www.w3.org/2000/svg" height="24px"viewBox="0 0 24 24" width="24px">
<style> .colab-df-container { display:flex; flex-wrap:wrap; gap: 12px; } .colab-df-convert { background-color: #E8F0FE; border: none; border-radius: 50%; cursor: pointer; display: none; fill: #1967D2; height: 32px; padding: 0 0 0 0; width: 32px; } .colab-df-convert:hover { background-color: #E2EBFA; box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15); fill: #174EA6; } [theme=dark] .colab-df-convert { background-color: #3B4455; fill: #D2E3FC; } [theme=dark] .colab-df-convert:hover { background-color: #434B5C; box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15); filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3)); fill: #FFFFFF; } </style> <script>
const buttonEl =
document.querySelector('#df-804688f7-1f60-4742-b054-7c72d883e30b button.colab-df-convert');
buttonEl.style.display =
google.colab.kernel.accessAllowed ? 'block' : 'none';
async function convertToInteractive(key) {
const element = document.querySelector('#df-804688f7-1f60-4742-b054-7c72d883e30b');
const dataTable =
await google.colab.kernel.invokeFunction('convertToInteractive',
[key], {});
if (!dataTable) return;
const docLinkHtml = 'Like what you see? Visit the ' +
'<a target="_blank" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'
+ ' to learn more about interactive tables.';
element.innerHTML = '';
dataTable['output_type'] = 'display_data';
await google.colab.output.renderOutput(dataTable, element);
const docLink = document.createElement('div');
docLink.innerHTML = docLinkHtml;
element.appendChild(docLink);
}
</script>
</div>
#ler uma variável específica
tru.read_var('2019','68','MG_tra')
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</style>
MG_tra | |
---|---|
produtos | |
Arroz, trigo e outros cereais | 1405 |
Milho em grão | 2631 |
Algodão herbáceo, outras fibras da lav. temporária | 370 |
Cana-de-açúcar | 2996 |
Soja em grão | 3433 |
... | ... |
Serviços de artes, cultura, esporte e recreação | 0 |
Organizações patronais, sindicais e outros serviços associativos | 0 |
Manutenção de computadores, telefones e objetos domésticos | 0 |
Serviços pessoais | 0 |
Serviços domésticos | 0 |
128 rows × 1 columns
<svg xmlns="http://www.w3.org/2000/svg" height="24px"viewBox="0 0 24 24" width="24px">
<style> .colab-df-container { display:flex; flex-wrap:wrap; gap: 12px; } .colab-df-convert { background-color: #E8F0FE; border: none; border-radius: 50%; cursor: pointer; display: none; fill: #1967D2; height: 32px; padding: 0 0 0 0; width: 32px; } .colab-df-convert:hover { background-color: #E2EBFA; box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15); fill: #174EA6; } [theme=dark] .colab-df-convert { background-color: #3B4455; fill: #D2E3FC; } [theme=dark] .colab-df-convert:hover { background-color: #434B5C; box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15); filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3)); fill: #FFFFFF; } </style> <script>
const buttonEl =
document.querySelector('#df-a86d51f5-4ce0-4242-b2c3-a6892af845fc button.colab-df-convert');
buttonEl.style.display =
google.colab.kernel.accessAllowed ? 'block' : 'none';
async function convertToInteractive(key) {
const element = document.querySelector('#df-a86d51f5-4ce0-4242-b2c3-a6892af845fc');
const dataTable =
await google.colab.kernel.invokeFunction('convertToInteractive',
[key], {});
if (!dataTable) return;
const docLinkHtml = 'Like what you see? Visit the ' +
'<a target="_blank" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'
+ ' to learn more about interactive tables.';
element.innerHTML = '';
dataTable['output_type'] = 'display_data';
await google.colab.output.renderOutput(dataTable, element);
const docLink = document.createElement('div');
docLink.innerHTML = docLinkHtml;
element.appendChild(docLink);
}
</script>
</div>
#ler ler a variável com preços do ano anterior
tru.read_var('2019','68','MG_tra','t-1')
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</style>
MG_tra | |
---|---|
produtos | |
Arroz, trigo e outros cereais | 1322 |
Milho em grão | 2385 |
Algodão herbáceo, outras fibras da lav. temporária | 365 |
Cana-de-açúcar | 2875 |
Soja em grão | 3089 |
... | ... |
Serviços de artes, cultura, esporte e recreação | 0 |
Organizações patronais, sindicais e outros serviços associativos | 0 |
Manutenção de computadores, telefones e objetos domésticos | 0 |
Serviços pessoais | 0 |
Serviços domésticos | 0 |
128 rows × 1 columns
<svg xmlns="http://www.w3.org/2000/svg" height="24px"viewBox="0 0 24 24" width="24px">
<style> .colab-df-container { display:flex; flex-wrap:wrap; gap: 12px; } .colab-df-convert { background-color: #E8F0FE; border: none; border-radius: 50%; cursor: pointer; display: none; fill: #1967D2; height: 32px; padding: 0 0 0 0; width: 32px; } .colab-df-convert:hover { background-color: #E2EBFA; box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15); fill: #174EA6; } [theme=dark] .colab-df-convert { background-color: #3B4455; fill: #D2E3FC; } [theme=dark] .colab-df-convert:hover { background-color: #434B5C; box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15); filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3)); fill: #FFFFFF; } </style> <script>
const buttonEl =
document.querySelector('#df-d740900e-1799-4c36-923a-e761bfa570df button.colab-df-convert');
buttonEl.style.display =
google.colab.kernel.accessAllowed ? 'block' : 'none';
async function convertToInteractive(key) {
const element = document.querySelector('#df-d740900e-1799-4c36-923a-e761bfa570df');
const dataTable =
await google.colab.kernel.invokeFunction('convertToInteractive',
[key], {});
if (!dataTable) return;
const docLinkHtml = 'Like what you see? Visit the ' +
'<a target="_blank" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'
+ ' to learn more about interactive tables.';
element.innerHTML = '';
dataTable['output_type'] = 'display_data';
await google.colab.output.renderOutput(dataTable, element);
const docLink = document.createElement('div');
docLink.innerHTML = docLinkHtml;
element.appendChild(docLink);
}
</script>
</div>
#ler ler a variável com outro nível e ano
tru.read_var('2000','12')
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</style>
PT | |
---|---|
produtos | |
Agropecuária | 87128.07773 |
Indústrias extrativas | 35555.283895 |
Indústrias de transformação | 648818.483278 |
Eletricidade e gás, água, esgoto, atividades de gestão de resíduos | 64680.645095 |
Construção | 146016.177837 |
Comércio | 143766.942246 |
Transporte, armazenagem e correio | 88682.618478 |
Informação e comunicação | 86607.823103 |
Atividades financeiras, de seguros e serviços relacionados | 105414.172763 |
Atividades imobiliárias | 151048.781496 |
Outras atividades de serviços | 320282.96256 |
Administração, defesa, saúde e educação públicas e seguridade social | 209734.795687 |
<svg xmlns="http://www.w3.org/2000/svg" height="24px"viewBox="0 0 24 24" width="24px">
<style> .colab-df-container { display:flex; flex-wrap:wrap; gap: 12px; } .colab-df-convert { background-color: #E8F0FE; border: none; border-radius: 50%; cursor: pointer; display: none; fill: #1967D2; height: 32px; padding: 0 0 0 0; width: 32px; } .colab-df-convert:hover { background-color: #E2EBFA; box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15); fill: #174EA6; } [theme=dark] .colab-df-convert { background-color: #3B4455; fill: #D2E3FC; } [theme=dark] .colab-df-convert:hover { background-color: #434B5C; box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15); filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3)); fill: #FFFFFF; } </style> <script>
const buttonEl =
document.querySelector('#df-b985967a-f875-488f-96a9-618e391cc619 button.colab-df-convert');
buttonEl.style.display =
google.colab.kernel.accessAllowed ? 'block' : 'none';
async function convertToInteractive(key) {
const element = document.querySelector('#df-b985967a-f875-488f-96a9-618e391cc619');
const dataTable =
await google.colab.kernel.invokeFunction('convertToInteractive',
[key], {});
if (!dataTable) return;
const docLinkHtml = 'Like what you see? Visit the ' +
'<a target="_blank" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'
+ ' to learn more about interactive tables.';
element.innerHTML = '';
dataTable['output_type'] = 'display_data';
await google.colab.output.renderOutput(dataTable, element);
const docLink = document.createElement('div');
docLink.innerHTML = docLinkHtml;
element.appendChild(docLink);
}
</script>
</div>
#encontrar matrizes de demanda final (mE) e demanda total (mU) a preços básicos
#usando o métrodo do Prof. Dr. Guilhoto
mU = tru_pb.D_total_pb('2019','68')[0]
mE = tru_pb.D_total_pb('2019','68')[1]
mE[1,:]
array([22855.033437625632, 0.0, 0.0, 3492.9691568353433, 0.0, -481.0],
dtype=object)
#Estimar matriz a preços básicos para anos e níveis diferente
mU = tru_pb.D_total_pb('2010','20')[0]
mE = tru_pb.D_total_pb('2010','20')[1]
mE[1,:]
array([76824.77308806025, 0.0, 0.0, 0.0, 6221.934829327755, -875.0],
dtype=object)
#Estimar matriz a preços básicos para anos, níveis e unidades diferentes
mU = tru_pb.D_total_pb('2010','51','t-1')[0]
mE = tru_pb.D_total_pb('2010','51','t-1')[1]
mU.shape
(107, 51)
#estimar a matrizes do sistema IO
import numpy as np
year = '2019'
level = '68'
unit = 't'
mU = tru_pb.D_total_pb(year,level,unit)[0]
mE = tru_pb.D_total_pb(year,level,unit)[1]
#Estimar matriz (D)
mV = tru.read_var(year,level,'P_matrix',unit).values.T
#Total produzido por produto
#vQ = np.sum(mV, axis=0)
vQ = tru.read_var(year,level,'PT',unit).values
mQChapeu = np.diagflat(1/vQ)
mD = np.dot(mV, mQChapeu)
#Estimar matriz (B)
#Total produzido por setor
vVBP = np.sum(mV, axis=1)
vX = np.copy(vVBP)
mXChapeu = np.diagflat(1/vX)
mB=np.dot(mU,mXChapeu)
mA = np.dot(mD,mB).astype(float)
mY = np.dot(mD,mE).astype(float)
mZ = np.dot(mD,mU).astype(float)
mI = np.eye(int(level))
mLeontief = np.linalg.inv(mI - mA)
mLeontief
array([[1.02795846e+00, 6.63434968e-02, 1.55683119e-02, ...,
2.48657115e-03, 8.87445164e-03, 0.00000000e+00],
[3.46679411e-03, 1.05066335e+00, 7.50231026e-03, ...,
5.04707964e-04, 2.99970714e-03, 0.00000000e+00],
[4.65358841e-03, 1.14566016e-02, 1.06662450e+00, ...,
3.39112179e-04, 7.04559555e-04, 0.00000000e+00],
...,
[2.57040133e-04, 4.90720175e-04, 2.96567252e-04, ...,
1.02021266e+00, 6.72567669e-03, 0.00000000e+00],
[1.72661929e-03, 1.85442303e-03, 1.52402071e-03, ...,
3.19760462e-03, 1.00595709e+00, 0.00000000e+00],
[0.00000000e+00, 0.00000000e+00, 0.00000000e+00, ...,
0.00000000e+00, 0.00000000e+00, 1.00000000e+00]])
#Variáveis que o pkg iotbr reconhece dentro da tru
- níveis 20 e 68 so tem dados a partir de 2010 -níveis 12 e 51 passaram a agregar exportações e importações a partir de 2010
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file iotbr-0.0.19.tar.gz
.
File metadata
- Download URL: iotbr-0.0.19.tar.gz
- Upload date:
- Size: 7.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f4b9c8a3ccecbf2151797f8a61287e50027c27a558bac2fedcad0ef09e0b28f |
|
MD5 | deb4d4e709b1a154996781c2bbd11772 |
|
BLAKE2b-256 | 69962521fb4cfd7aec2b4e7b163d4f3937567dd6c8d7632e9e9260bbd283fa23 |
File details
Details for the file iotbr-0.0.19-py3-none-any.whl
.
File metadata
- Download URL: iotbr-0.0.19-py3-none-any.whl
- Upload date:
- Size: 7.3 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14802395edcb150b15282aa11573287cbf93276fb66b01e6adfe90c500202459 |
|
MD5 | 662a85f343cb504c0039af5d1c002d85 |
|
BLAKE2b-256 | 89b63b685f8ab4ff2e1309527f709807616e0ba972954711cca9c3a9e8414528 |