cran_downloads¶
In [1]: from cranlogs import cran_downloads
Parameters:
- packages: a string representing one package, or a list of multiple packages.
- when: “last-day”, “last-week”, or “last-month”. When defined, start and end will be ignored.
- start: start date with format year-month-day.
- end: end date with format year-month-day.
Examples¶
To get daily downloads for package ggplot2 from 2019-08-01 to 2019-08-03, we need to define the packages as ggplot2, start time as 2019-08-01, and the end time as 2019-08-03.
In [2]: cran_downloads(packages='ggplot2', start='2019-08-01', end='2019-08-03')
Out[2]:
date count package
0 2019-08-01 25366 ggplot2
1 2019-08-02 22690 ggplot2
2 2019-08-03 12069 ggplot2
We can also get the package downloads for last day, last week, and last month by defining when=’last-day’, when=’last-week’, or when=’last-month’.
In [3]: cran_downloads(packages='ggplot2', when='last-day')
Out[3]:
date count package
0 2019-08-10 11743 ggplot2
In fact, if no timing information is defined, the default will be ‘last-day’.
In [4]: cran_downloads(packages='ggplot2')
Out[4]:
date count package
0 2019-08-10 11743 ggplot2
We can get data for multiple packages.
In [5]: cran_downloads(packages=['ggplot2','dplyr'], start='2019-08-01', end='2019-08-03' )
Out[5]:
date count package
0 2019-08-01 25366 ggplot2
1 2019-08-02 22690 ggplot2
2 2019-08-03 12069 ggplot2
3 2019-08-01 31006 dplyr
4 2019-08-02 29209 dplyr
5 2019-08-03 16614 dplyr
And we can get data for R installers downloads.
In [6]: cran_downloads(packages=['R'], when='last-week' )
Out[6]:
day os version downloads
0 2019-08-04 osx 3.2.0 2
1 2019-08-04 osx latest 194
2 2019-08-04 osx 3.3.2 1
3 2019-08-04 osx 3.2.3 1
4 2019-08-04 osx 3.2.4 4
.. ... ... ... ...
607 2019-08-10 src 3.6.1 36
608 2019-08-10 osx 2.11.0 1
609 2019-08-10 osx 3.1.1 2
610 2019-08-10 osx 2.12.2 1
611 2019-08-10 osx 3.5.1 1
[612 rows x 4 columns]