跳转到主要内容

经济学数据处理和函数

项目描述

economics 提供了一个基于data.okfn.org数据的经济学计算工具包。

功能

  • CPI

  • 通货膨胀(默认基于CPI)

需求

CPI

>> from economics import CPI
>> import datetime
>>
>> # Create a new CPI instance
>> cpi = CPI()
>>
>> # Get CPI for Iceland in 2007
>> cpi.get(datetime.date(2007,1,1), 'Iceland')
CPI(date=datetime.date(2007, 1, 1), value=112.07753358)
>>
>> # We're going to work with Iceland so set default country
>> # (we're creating a new instance but the country variable can be set)
>> iceland = CPI(country='Iceland')
>>
>> # Get CPI in 2012 (not in the data)
>> iceland.get(datetime.date(2012,1,1))
...
KeyError: 'Date 2012-01-01 not found in data'
>>
>> # Get the closest CPI value sintead
>> iceland.closest(datetime.date(2012,1,1))
CPI(date=datetime.date(2011, 1, 1), value=155.03663004)

通货膨胀

>> from economics import Inflation
>> import datetime
>>
>> # Create a new Inflation instance
>> inflation = Inflation()
>>
>> # How many US $ would I need in 2011 to pay for what cost $5 in 2007
>> inflation.inflate(5, datetime.date(2011,1,1), datetime.date(2007,1,1), 'United States')
5.424340332378624
>>
>> # We can also set the reference year and the country
>> usa_2007 = Inflation(reference=datetime.date(2007,1,1), country='United States')
>>
>> # Get the inflation for 2007 in the United States
>> usa_2007.get(datetime.date(2011,1,1))
Inflation(factor=1.0848680664757249, value=0.08486806647572484)

许可协议

economics 在GNU通用公共许可证v3下可用。有关详细信息,请参阅LICENCE。

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源代码分发

economics-0.1.2.tar.gz (17.2 kB 查看哈希)

上传时间: 源代码

由以下支持