question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

problem: import vega_datasets.data as ...

See original GitHub issue

Please forgive me as I am a Python “newbie” and may be asking an ignorant question.

I would like to be able to use the form:

import vega_datasets.data as data

instead of

from vega_datasets import data

My motivation is that I can use something analogous to the first form when using the import() function in the R reticulate package.

If I try this (in Python):

from vega_datasets import data
dir(data)

I get (as I expect):

['7zip',
 'airports',
 'anscombe',
 'barley',
 ...
 'zipcodes']

However, if I try this:

import vega_datasets.data as data2
dir(data2)

I get:

['__doc__', '__loader__', '__name__', '__package__', '__path__', '__spec__']

whereas I am hoping to replicate the first behavior.

By contrast, this works as I expect:

import scipy.stats as stats
dir(stats)

Question: could it be possible for import vega_datasets.data as data to work like from vega_datasets import data?

Thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
realkrantzcommented, Jan 1, 2019

Solved. Thanks, @ijlyttle.

1reaction
ijlyttlecommented, Dec 31, 2018
Read more comments on GitHub >

github_iconTop Results From Across the Web

import_vega_data: Import Vega datasets in altair - Rdrr.io
Lets you access Vega datasets. Usage. import_vega_data(). Details. Returns the data object in the Python package vega-datasets. In the documentation for this ...
Read more >
ModuleNotFoundError: No module named 'vega_datasets'
Have you tried to import these vega datasets into your script via: from vega_datasets import data. Thanks,
Read more >
Vega Datasets • altair
We can access the Vega datasets using the import_vega_data() function. ... from vega_datasets import data cars = data.cars().
Read more >
vega-datasets - PyPI
The main object in this library is data : >>> from vega_datasets import data. It contains attributes that access all available datasets, ...
Read more >
vega_datasets: A Python Package for Datasets
has solved the dataset problem with a relatively new package called vega_datasets. ... from vega_datasets import data import pandas as pd.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found