Data source in Jupyter needs full URL
See original GitHub issueIn Jupyter Lab I have seattle-weather.csv, bar.vl.json and a notebook all in the same folder. The data is from the example data sets, as is the Vega Lite:
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {"url": "seattle-weather.csv"},
"mark": "bar",
"encoding": {
"x": {"timeUnit": "month", "field": "date", "type": "ordinal"},
"y": {"aggregate": "count", "type": "quantitative"},
"color": {"field": "weather", "type": "nominal"}
}
}
Opening the Vega Lite file directly creates a tab with the bar chart rendered as expected. In the notebook I need to pass the full URL to Altair to create the same visualisation:
alt.Chart('http://localhost:8888/files/seattle-weather.csv').mark_bar().encode(
x='month(date):O',
y='count():Q',
color='weather:N'
)
Why does alt.Chart('seattle-weather.csv').....
not work in the notebook? Can the docs be updated to include guidance around this use case scenario?
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
JupyterLab URLs — JupyterLab 3.6.0a5 documentation
A workspace file in a JSON file with a specific spec. There are two top level keys requires, data , and metadata ....
Read more >can't access data from URL in pandas/jupyter notebook
1 Answer 1 · The data source you are using has discontinued publishing the 'recovery' statistic. You can read the details here. It...
Read more >Access ODBC Data Sources in Jupyter Python Notebook ...
Querying Data from Python Notebook Start Jupyter by running the command jupyter notebook. You should see browser open up and load the homepage...
Read more >How to Upload Source Data to Jupyter Notebook in Python
Example data used in this lecture: FBOne.csvhttps://drive.google.com/file/d/1luLaEPCWIPiy74ohsV-Xpkx79vtSnRUG/view?usp=sharingFacebook stock ...
Read more >Loading and accessing data in a notebook
To access data from a local file, you can load the file from within a notebook, or first load the file into your...
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 just discovered that it works as expected with
/files
instead of justfiles
.I don’t think the full URL is actually required. For example, I ran this in a local JupyterLab instance and it produced a correctly rendered chart:
(This will only work if you have not used the
%cd
magic command to change the working directory from the JupyterLab root. I believe there are also caveats about different ways to start kernels and different jupyter configuration settings that will make this fail, because the location in which thecurl
command is run can diverge from the JupyterLab root directory)