The Python statsmodels library grants access to many R-datasets which can be downloaded e.g. with:

import statsmodels.api as sm
df = sm.datasets.get_rdataset(dataname='iris', package='datasets').data

But for this you have to know the id or the name of the dataset.

Signature: sm.datasets.get_rdataset(dataname, package='datasets', cache=False)
def get_rdataset(dataname, package="datasets", cache=False):
    """download and return R dataset

    dataname : str
        The name of the dataset you want to download

There is a list of available datasets here, but this list does not contain the identifiers. Also not the detailed view.

Is there an overview of all the available datasets that contains the ids e.g. "iris"?

There is an index that is supposed to list all the datasets, but e.g. 'rice' as a name does not work.


Here is the website of the creator of rdatasets I guess with the info you are looking for:


Here is a short look at it:

Package     Item    Title   Rows    Cols    n_binary    n_character     n_factor    n_logical   n_numeric   CSV     Doc
boot    acme    Monthly Excess Returns  60  3   0   1   0   0   2   CSV     DOC
boot    aids    Delay in AIDS Reporting in England and Wales    570     6   1   0   0   0   6   CSV     DOC
boot    aircondit   Failures of Air-conditioning Equipment  12  1   0   0   0   0   1   CSV     DOC
boot    aircondit7  Failures of Air-conditioning Equipment  24  1   0   0   0   0   1   CSV     DOC
boot    amis    Car Speeding and Warning Signs  8437    4   1   0   0   0   4   CSV     DOC
boot    aml     Remission Times for Acute Myelogenous Leukaemia     23  3   2   0   0   0   3   CSV     DOC 

I assume the Item column are the identifiers.

  • $\begingroup$ As stated above, that does not seem to work. Try for example 'rice'. $\endgroup$
    – Soren
    Dec 20 '19 at 14:15
  • $\begingroup$ Did you change the package parameter to DAAG for the dataset rice? Since it’s not in the package datasets according to the index site. $\endgroup$
    – voiDnyx
    Dec 22 '19 at 11:18

You can view all the available datasets at this URL https://github.com/vincentarelbundock/Rdatasets/blob/master/datasets.csv

The available ones in statsmodels are those with the tag datasets which looks like line 372 - 455.

I didn't test them all, but everyone I tried from a small random sample seemed to work fine.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.