ENH: Build vega_datasets into altair?
See original GitHub issueThis is something that @palewire mentioned a while ago, and the idea has been growing on me.
Currently, many of our examples are like this:
import altair as alt
from vega_datasets import data
cars = data.cars()
alt.Chart(cars)...
What if we were to import vega_datasets into Altair’s namespace by default, so instead it would be
import altair as alt
cars = alt.datasets.cars()
alt.Chart(cars)...
The advantage is fewer imports and less boilerplate.
A minor disadvantage is that vega_datasets would become a hard requirement for Altair (unless we did some kind of lazy import mechanism, which would add complication).
A more major disadvantage is that it would obscure the fact that vega_datasets
is a separate package, rather than a part of Altair, which might confuse people.
Thoughts?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:24 (15 by maintainers)
Top Results From Across the Web
Installation — Altair 4.2.0 documentation
Installation . Altair can be installed, along with the example datasets in vega_datasets, using: $ pip install altair vega_datasets.
Read more >Learning Observable Plot via Altair / Eitan Lees
Before we make any plots we need data. Most of the Altair examples utilize the Vega Datasets repository, which can easily be integrated...
Read more >Taking Data Visualization to Another Level | HackerNoon
Altair is a declarative statistical visualization library and it is based on Vega and Vega-Lite. Altair enables you to build a wide range...
Read more >Altair Python Vega Dataset Example | How to Install Altair
Learn how to install Altair, work with vega datasetsinstall Altair ViewerWork with the vega dataset. Altair charts like bar charts, ...
Read more >Enhancement Shaman DPS Spec, Builds, and Talents
Find out the best talents in each tier for your Enhancement Shaman in WoW Dragonflight 10.0.2.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I really appreciate everyone weighing in here. Overall, I think the key points on either side are:
Pros
Cons
vega_datasets
package makes it less clear how to debug issues that arise, particularly for beginnersWith those in mind, how about a compromise: make
vega_datasets
a soft requirement accessible from the Altair namespace. We could add adatasets
object at the top-level of the module which provides access to everything in vega-datasets (if it is installed) and raises an informative error (if it is not). I’d imagine something like this:Then the hard dependencies of Altair would not change, but it would make the following available to users who do have vega_datasets installed:
If
vega_datasets
is installed, this will work as expected. If not, it will give the user an informative error.We could then adjust all our “getting started” installation instructions to include installation of vega_datasets (as they probably already should).
The more I think about it, the more I like the compromise I mentioned above, particularly as I develop the Altair tutorial.
After PyCon, I’m going to look at implementing this unless people have objections (@ellisonbg – I’d love to hear your thoughts)