Skip to main content

The purpose of the pyeviews package is to make it easier for EViews and Python to talk to each other, so Python programmers can use the econometric engine of EViews directly from Python. We’ve written a Python package, pyeviews, that uses COM to transfer data between Python and EViews. (For more information on COM and EViews, take a look at our whitepaper on the subject.)

Here’s a simple example going from Python to EViews. We’re going to use the popular Chow-Lin interpolation routine in EViews using data created in Python. Chow-Lin interpolation is a regression-based technique to transform low-frequency data (in our example, annual) into higher-frequency data (in our example, quarterly). It has the ability to use a higher-frequency series as a pattern for the interpolated series to follow. The quarterly interpolated series is chosen to match the annual benchmark series in one of four ways: first (the first quarter value of the interpolated series matches the annual series), last (same, but for the fourth quarter value), sum (the sum of the first through fourth quarters matches the annual series), and average (the average of the first through fourth quarters matches the annual series).

We’re going to create two series in Python using the time series functionality of the pandas package, transfer it to EViews, perform Chow-Lin interpolation on our series, and bring it back into Python. The data are taken from [BLO2001] in an example originally meant for Denton interpolation.

  1. If you don’t have Python, we recommend the Anaconda distribution, which will include most of the packages we’ll need. Then head over to the Python Package Index and get the pyeviews module by opening a Windows command line program (e.g., Command Prompt or PowerShell) and using the command:

:: python

$ pip install package

or by downloading the package, navigating to your installation directory, and using the command

$ python setup.py install
  1. Create two time series using pandas. We’ll call the annual series “benchmark” and the quarterly series “indicator”:

>>> import numpy as np
>>> import pandas as pa
>>> dtsa = pa.date_range('1998', periods = 3, freq = 'A')
>>> benchmark = pa.Series([4000.,4161.4,np.nan], index=dtsa, name = 'benchmark')
>>> dtsq = pa.date_range('1998q1', periods = 12, freq = 'Q')
>>> indicator = pa.Series([98.2, 100.8, 102.2, 100.8, 99., 101.6, 102.7, 101.5, 100.5, 103., 103.5, 101.5], index = dtsq, name = 'indicator')`
  1. Load the pyeviews package and create a custom COM application object so we can customize our settings. Set “showwindow” (which displays the EViews window) to True. Then call the “PutPythonAsWF” function to create pages for the benchmark and indicator series:

>>> import pyeviews as evp
>>> eviewsapp = evp.GetEViewsApp(instance='new', showwindow=True)
>>> evp.PutPythonAsWF(benchmark, app=eviewsapp)
>>> evp.PutPythonAsWF(indicator, app=eviewsapp, newwf=False)
  1. Name the pages of the workfile:

>>> evp.Run('pageselect Untitled', app=eviewsapp)
>>> evp.Run('pagerename Untitled annual', app=eviewsapp)
>>> evp.Run('pageselect Untitled1', app=eviewsapp)
>>> evp.Run('pagerename Untitled1 quarterly', app=eviewsapp)
  1. Use the EViews copy command to copy the benchmark series in the annual page to the quarterly page, using the indicator series in the quarterly page as the high-frequency indicator and matching the sum of the benchmarked series for each year (four quarters) with the matching annual value of the benchmark series:

>>> evp.Run('copy(rho=.7, c=chowlins, overwrite) annual\\benchmark quarterly\\benchmarked @indicator indicator', app=eviewsapp)
  1. Bring the new series back into Python:

>>> benchmarked = evp.GetWFAsPython(app=eviewsapp, pagename= 'quarterly', namefilter= 'benchmarked ')
>>> print benchmarked
            BENCHMARKED
1998-03-01          NaN
1998-06-01          NaN
1998-09-01          NaN
1998-12-01   991.746591
1999-03-01   925.719318
1999-06-01  1021.092045
1999-09-01  1061.442045
1999-12-01  1017.423864
2000-03-01   980.742045
2000-06-01  1072.446591
2000-09-01  1090.787500
2000-12-01  1017.423864
  1. Release the memory allocated to the COM process (this does not happen automatically in interactive mode):

>>> eviewsapp.Hide()
>>> eviewsapp = None
>>> evp.Cleanup()

Note that if you choose not to create a custom COM application object (the GetEViewsApp function), you won’t need to use the first two lines in the last step. You only need to call Cleanup(). If you create a custom object but choose not to show it, you won’t need to use the first line (the Hide() function).

References

[BLO2001]

Bloem, A.M, Dippelsman, R.J. and Maehle, N.O. 2001 Quarterly National Accounts Manual–Concepts, Data Sources, and Compilation. IMF. http://www.imf.org/external/pubs/ft/qna/2000/Textbook/index.htm

Metadata

Release files for pyeviews 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyeviews 0.1.1
File Size Uploaded Provenance Actions
pyeviews-0.1.1.zip 25.7 kB Without provenance Details for pyeviews-0.1.1.zip

Release files / pyeviews-0.1.1.zip

Download URL pyeviews-0.1.1.zip
Size 25.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7b4d31b0f122ddcf7d9902357e249f3a049d423fb12bb8d67bfd3b526e813ac0
BLAKE2b-256 checksum
How to use checksums
c6e8b0d8451fd32e352adc42e0874aafd8219d7cd9ef774a3548952c0b85f667
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for pyeviews 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page