Skip to main content

PyWRDS from Wharton Research Data Services

PyWRDS 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 PyWRDS 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 PyWRDS 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 PyWRDS 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 pywrds pywrds
$ source pywrds/bin/activate
(pywrds) $ python -m pip install -U pip wheel wrds

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

$ source pywrds/bin/activate

Windows

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

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

C:\Users\username> pywrds\Scripts\activate

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

Using the PyWRDS 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

Development and Test Suite

Clone the repository and install with pip install -e .[dev]. Then run pytest.

Metadata

Release files for wrds 3.5.0

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

Source distribution (sdist)

Source distribution for wrds 3.5.0
File Size Uploaded
wrds-3.5.0.tar.gz 20.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wrds 3.5.0
File Interpreter ABI Platform
wrds-3.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 36.4 kB

Release files / wrds-3.5.0.tar.gz

Download URL wrds-3.5.0.tar.gz
Size 20.3 kB
Tags Source
SHA-256 checksum
How to use checksums
1c6f63a9e370e216b6d6f31da23d9fdb3b9cf4a93e7870449e11c4c597f3825f
BLAKE2b-256 checksum
How to use checksums
e2f30e3baedf7ad4dbdca68766f24b107cca939474c43eccd048a1f1aa154dab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.1

Release files / wrds-3.5.0-py3-none-any.whl

Download URL wrds-3.5.0-py3-none-any.whl
Size 16.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e5da209e8f84e75800b0c38237569a0ae0deb670707fabfb7036a9625392ced9
BLAKE2b-256 checksum
How to use checksums
54655ee72a4d1dba095b1068c7c8d5872d3d8c27bc7e8b7c3001ad6d09307838
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.1

Release history Release notifications | RSS feed

This release

3.5.0 This release

2 release files

3.4.0

2 release files

3.3.0

2 release files

3.2.0

2 release files

3.1.6

2 release files

3.1.5

2 release files

3.1.3

2 release files

3.1.2

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.10

2 release files

3.0.8

2 release files

3.0.7

5 release files

3.0.6

3 release files

3.0.5

2 release files

3.0.4

3 release files

3.0.3

2 release files

3.0.2

1 release file

3.0.1

1 release file

3.0

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.0

2 release files

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