neylsoncrepalde / deflatebr Goto Github PK
View Code? Open in Web Editor NEWDeflate Nominal Brazilian Reais - Based on Fernando Meireles's homonymous R package
License: MIT License
Deflate Nominal Brazilian Reais - Based on Fernando Meireles's homonymous R package
License: MIT License
deflate()
method does not support a situation when I have multiple values for one date. I know this is not a 'series' but it would be great to deflate a bigger data frame where I just several wage observations for the same timebox.
A reproducible example
import pandas as pd
from deflatebr import deflate
test = pd.DataFrame({'wage':[1000,1100,1150, 1000, 1200, 1250],
'nom_dates': ['2018-01-01','2018-01-01','2018-01-01',
'2018-08-01','2018-08-01','2018-08-01']})
print(test)
deflate(nominal_dates=test.nom_dates, nominal_values=test.wage, real_date='2020-01')
wage nom_dates
0 1000 2018-01-01
1 1100 2018-01-01
2 1150 2018-01-01
3 1000 2018-08-01
4 1200 2018-08-01
5 1250 2018-08-01
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-346-db2259f977d9> in <module>
4 '2018-08-01','2018-08-01','2018-08-01']})
5 print(test)
----> 6 deflate(nominal_dates=test.nom_dates, nominal_values=test.wage, real_date='2020-01')
~\Anaconda3\lib\site-packages\deflatebr\deflate.py in deflate(nominal_values, nominal_dates, real_date, index)
72 indice['indx'] = indice.VALVALOR[indice.VALDATA == real_date].values / indice.VALVALOR.values
73
---> 74 return (indice.loc[indice.VALDATA.isin(nominal_dates),'indx'] * nominal_values).values
~\Anaconda3\lib\site-packages\pandas\core\ops\__init__.py in wrapper(left, right)
1046
1047 with np.errstate(all="ignore"):
-> 1048 result = na_op(lvalues, rvalues)
1049 return construct_result(
1050 left, result, index=left.index, name=res_name, dtype=None
~\Anaconda3\lib\site-packages\pandas\core\ops\__init__.py in na_op(x, y)
966
967 try:
--> 968 result = expressions.evaluate(op, str_rep, x, y, **eval_kwargs)
969 except TypeError:
970 result = masked_arith_op(x, y, op)
~\Anaconda3\lib\site-packages\pandas\core\computation\expressions.py in evaluate(op, op_str, a, b, use_numexpr, **eval_kwargs)
219 use_numexpr = use_numexpr and _bool_arith_check(op_str, a, b)
220 if use_numexpr:
--> 221 return _evaluate(op, op_str, a, b, **eval_kwargs)
222 return _evaluate_standard(op, op_str, a, b)
223
~\Anaconda3\lib\site-packages\pandas\core\computation\expressions.py in _evaluate_standard(op, op_str, a, b, **eval_kwargs)
68 _store_test_result(False)
69 with np.errstate(all="ignore"):
---> 70 return op(a, b)
71
72
ValueError: operands could not be broadcast together with shapes (2,) (6,)
Progress bar not showing in Jupyter lab.
Bom dia,
Não importa o formato que eu use, sempre retorna esse erro.
O campo de data está, originalmente, como date no formato 2022-12-01.
Já converti para string e para datetime, mas sempre retorna Unknown string format.
df = df.withColumn("salario_real", dbr.deflate(
nominal_values = "salario",
nominal_dates = "data",
real_date = "2022-12",
index = "inpc"
))
Já converti o dataframe pra Pandas também e dá o mesmo erro.
pandasDF = df.toPandas()
pandasDF["salario_real"] = dbr.deflate(
nominal_values = "salario",
nominal_dates = "data",
real_date = "2022-12",
index = "inpc"
))
ParserError: Unknown string format: data
Olá, Neylson! Tudo bem?
Na empresa em que trabalho, utilizam o pacote DeflateBR na linguagem R e funciona super bem, mas começamos a transcrever os códigos no Databricks e não conseguimos puxar o pacote em R para lá. Seria possível atualizar essa biblioteca em Python?
Ajudaria demais!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.