-
Notifications
You must be signed in to change notification settings - Fork 793
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a7bc4f
commit c572180
Showing
1 changed file
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,15 +143,51 @@ def __call__( | |
"""Get a remote dataset and load as tabular data.""" | ||
return self._reader.dataset(name, suffix, tag=tag, **kwds) | ||
|
||
# TODO: docs (parameters, examples) | ||
def url( | ||
self, | ||
name: DatasetName | LiteralString, | ||
suffix: Extension | None = None, | ||
/, | ||
tag: VersionTag | None = None, | ||
) -> str: | ||
"""Return the address of a remote dataset.""" | ||
""" | ||
Return the address of a remote dataset. | ||
Parameters | ||
---------- | ||
name | ||
Name of the dataset/`stem`_ of filename. | ||
suffix | ||
File extension/`Path.suffix`_. | ||
.. note:: | ||
Only needed if ``name`` is available in multiple formats. | ||
tag | ||
`vega-datasets release`_ version. | ||
.. _stem: | ||
https://docs.python.org/3/library/pathlib.html#pathlib.PurePath.stem | ||
.. _Path.suffix: | ||
https://docs.python.org/3/library/pathlib.html#pathlib.PurePath.suffix | ||
.. _vega-datasets release: | ||
https://github.com/vega/vega-datasets/releases | ||
Examples | ||
-------- | ||
The returned url will always point to an accessible dataset: | ||
import altair as alt | ||
from altair.datasets import Loader | ||
data = Loader.with_backend("polars") | ||
data.url("cars", tag="v2.9.0") | ||
'https://cdn.jsdelivr.net/npm/[email protected]/data/cars.json' | ||
We can pass the result directly to a chart: | ||
url = data.url("cars", tag="v2.9.0") | ||
alt.Chart(url).mark_point().encode(x="Horsepower:Q", y="Miles_per_Gallon:Q") | ||
""" | ||
return self._reader.url(name, suffix, tag=tag) | ||
|
||
@property | ||
|