Skip to content

Commit

Permalink
docs: Replace outdated docs
Browse files Browse the repository at this point in the history
- Using `load` instead of `data`
- Don't mention multi-versions, as that was dropped
  • Loading branch information
dangotbanned committed Jan 17, 2025
1 parent 5dc227e commit ba01af1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
34 changes: 17 additions & 17 deletions altair/datasets/_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class Loader(Generic[IntoDataFrameT, IntoFrameT]):
from altair.datasets import Loader
data = Loader.from_backend("polars")
>>> data # doctest: +SKIP
load = Loader.from_backend("polars")
>>> load # doctest: +SKIP
Loader[polars]
.. _vega-datasets:
Expand Down Expand Up @@ -94,24 +94,24 @@ def from_backend(cls, backend_name: _Backend, /) -> Loader[Any, Any]:
from altair.datasets import Loader
data = Loader.from_backend("polars")
cars = data("cars")
load = Loader.from_backend("polars")
cars = load("cars")
>>> type(cars) # doctest: +SKIP
polars.dataframe.frame.DataFrame
Using ``pandas``:
data = Loader.from_backend("pandas")
cars = data("cars")
load = Loader.from_backend("pandas")
cars = load("cars")
>>> type(cars) # doctest: +SKIP
pandas.core.frame.DataFrame
Using ``pandas``, backed by ``pyarrow`` dtypes:
data = Loader.from_backend("pandas[pyarrow]")
cars = data("cars")
load = Loader.from_backend("pandas[pyarrow]")
cars = load("cars")
>>> type(cars) # doctest: +SKIP
pandas.core.frame.DataFrame
Expand Down Expand Up @@ -165,8 +165,8 @@ def __call__(
from altair.datasets import Loader
data = Loader.from_backend("polars")
source = data("iowa-electricity")
load = Loader.from_backend("polars")
source = load("iowa-electricity")
>>> source.columns # doctest: +SKIP
['year', 'source', 'net_generation']
Expand All @@ -193,8 +193,8 @@ def __call__(
Using ``pandas``:
data = Loader.from_backend("pandas")
source = data("iowa-electricity")
load = Loader.from_backend("pandas")
source = load("iowa-electricity")
>>> source.columns # doctest: +SKIP
Index(['year', 'source', 'net_generation'], dtype='object')
Expand All @@ -217,8 +217,8 @@ def __call__(
Using ``pyarrow``:
data = Loader.from_backend("pyarrow")
source = data("iowa-electricity")
load = Loader.from_backend("pyarrow")
source = load("iowa-electricity")
>>> source.column_names # doctest: +SKIP
['year', 'source', 'net_generation']
Expand Down Expand Up @@ -266,13 +266,13 @@ def url(
import altair as alt
from altair.datasets import Loader
data = Loader.from_backend("polars")
>>> data.url("cars") # doctest: +SKIP
load = Loader.from_backend("polars")
>>> load.url("cars") # doctest: +SKIP
'https://cdn.jsdelivr.net/npm/[email protected]/data/cars.json'
We can pass the result directly to a chart:
url = data.url("cars")
url = load.url("cars")
alt.Chart(url).mark_point().encode(x="Horsepower:Q", y="Miles_per_Gallon:Q")
"""
return self._reader.url(name, suffix)
Expand Down
4 changes: 3 additions & 1 deletion altair/datasets/_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,16 @@ def query(
self, *predicates: OneOrSeq[IntoExpr], **constraints: Unpack[Metadata]
) -> nw.DataFrame[IntoDataFrameT]:
"""
Query multi-version trees metadata.
Query a tabular version of `vega-datasets/datapackage.json`_.
Applies a filter, erroring out when no results would be returned.
Notes
-----
Arguments correspond to those seen in `pl.LazyFrame.filter`_.
.. _vega-datasets/datapackage.json:
https://github.com/vega/vega-datasets/blob/main/datapackage.json
.. _pl.LazyFrame.filter:
https://docs.pola.rs/api/python/stable/reference/lazyframe/api/polars.LazyFrame.filter.html
"""
Expand Down

0 comments on commit ba01af1

Please sign in to comment.