Skip to main content

WRDS-Py from Wharton Research Data Services

WRDS-Py is a Python package for examining datasets on the Wharton Research Data Services (WRDS) platform, and extracting data to Pandas dataframes. A WRDS account is required.

Installation

The WRDS-Py package is supported on Python 3.8 through 3.12. To ensure you have a supported Python version, type python --version at a command line interface, and check that it is between 3.8 and 3.12. On some systems, Python may be in installed as python3. You can download Python here if it isn't installed.

The WRDS-Py package must be installed before it can be used for the first time. The recommended method is to use a virtual environment (venv), so you can import it to use in Python. This example will install the WRDS-Py package (wrds) and IPython, which provides a much nicer command line interface than is included with Python.

Linux or MacOS

$ python -m venv --copies --prompt wrds-py wrds-py
$ source wrds-py/bin/activate
(wrds-py) $ python -m pip install -U pip wheel wrds ipython

In this example, Python will create a venv in your current directory ./wrds-py, so that when you want to use it again, you can simply activate it:

$ source wrds-py/bin/activate

Windows

C:\Users\username> python -m venv --copies --prompt wrds-py wrds-py
C:\Users\username> wrds-py\Scripts\activate
(wrds-py) C:\Users\username> python -m pip install -U pip wheel wrds ipython

In this example, Python will create a venv in the directory C:\Users\username\wrds-py, so that when you want to use it again, you can simply activate it:

C:\Users\username> wrds-py\Scripts\activate

For detailed information on installation of the module, please see PYTHON: From Your Computer (Jupyter/Spyder)

Using the Py-WRDS Package

Type ipython to start the IPython command line interface.

For detailed information on use of the module, please see Querying WRDS Data using Python

A quick tutorial:

In [1]: import wrds
In [2]: db = wrds.Connection()
Enter your credentials.
Username: <your_username>
Password: <your_password>
In [3]: db.list_libraries()
['audit', 'bank', 'block', 'bvd', 'bvdtrial', 'cboe', ...]
In [4]: db.list_tables(library="crsp")
['aco_amda', 'aco_imda', 'aco_indfnta', 'aco_indfntq', ...]
In [5]: db.describe_table(library="crsp", table="stocknames")
Approximately 58957 rows in crsp.stocknames.
       name    nullable              type
0      permno      True  DOUBLE PRECISION
1      namedt      True              DATE
2   nameenddt      True              DATE
...

In [6]: stocknames = db.get_table(library="crsp", table="stocknames", rows=10)
In [7]: stocknames.head()
   permno  permco      namedt   nameenddt     cusip    ncusip ticker  \
0  10000.0  7952.0  1986-01-07  1987-06-11  68391610  68391610  OMFGA
1  10001.0  7953.0  1986-01-09  1993-11-21  36720410  39040610   GFGC
2  10001.0  7953.0  1993-11-22  2008-02-04  36720410  29274A10   EWST
3  10001.0  7953.0  2008-02-05  2009-08-03  36720410  29274A20   EWST
4  10001.0  7953.0  2009-08-04  2009-12-17  36720410  29269V10   EGAS

In [7]: db.close()  # Close the connection to the database.

In [8]: with wrds.Connection() as db:  # You can use a context manager
   ...:     stocknames = db.get_table(library='crsp', table='stocknames', rows=10)
   ...: stocknames.head()
   permno  permco      namedt   nameenddt     cusip    ncusip ticker  \
0  10000.0  7952.0  1986-01-07  1987-06-11  68391610  68391610  OMFGA
1  10001.0  7953.0  1986-01-09  1993-11-21  36720410  39040610   GFGC
2  10001.0  7953.0  1993-11-22  2008-02-04  36720410  29274A10   EWST
3  10001.0  7953.0  2008-02-05  2009-08-03  36720410  29274A20   EWST
4  10001.0  7953.0  2009-08-04  2009-12-17  36720410  29269V10   EGAS

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wrds-3.3.0.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wrds-3.3.0-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file wrds-3.3.0.tar.gz.

File metadata

  • Download URL: wrds-3.3.0.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.1

File hashes

Hashes for wrds-3.3.0.tar.gz
Algorithm Hash digest
SHA256 1f589276518c925ba16cbbae8589045e7927cc9d6d141288b4a121356218c097
MD5 1aa2bebb4c165573500fa751fd5b9e23
BLAKE2b-256 681b324cec3869fedbb83ace293bdd982f4ba3cf4bea96274feb414a7ab0dade

See more details on using hashes here.

File details

Details for the file wrds-3.3.0-py3-none-any.whl.

File metadata

  • Download URL: wrds-3.3.0-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.1

File hashes

Hashes for wrds-3.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f3edeb7ec7ed453345b81990296cea2758fd19f33ff25875963b1042100e9ee8
MD5 8355c8f3d9d130f90ff53b202bcaec63
BLAKE2b-256 abf2a376cd0828c06c58da6194b5bf952529713aa0bb690ab03e6935111d744b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page