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.

Name and location of json files created by `alt.data_transformers.enable('json')`

See original GitHub issue

Hello, First, I love this package that I discovered recently and was able to get up to speed really quickly with the tutorials, so thank you!

I use alt.data_transformers.enable('json') to manage fairly large datasets, but when I make several graphs in a notebook, I get a bunch of altair-data-11217bb8-d26d-481e-99d3-8e8701d4e6cf.json-like files, and it is not easy to know which one is which. Is there a way to:

  1. Select a location (e.g. a figure file containing those files) ?
  2. Choose a name when rendering the file (maybe with the name of the Chart if provided) ?

Thank you

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jakevdpcommented, Sep 13, 2020

You can always find the filename in the serialized chart:

import altair as alt
import pandas as pd
df = pd.DataFrame({'x': range(5)})

alt.data_transformers.enable('json')
chart = alt.Chart(df).mark_bar().encode(x='x:Q')

print(chart.to_dict()['data']['url'])

Better would probably be to do the transformation manually if you want to manipulate the output file directly:

data = alt.to_json(df)
print(data['url'])
chart = alt.Chart(data).mark_bar().encode(x='x:Q')
1reaction
jakevdpcommented, Sep 13, 2020

I’m not sure that would work, because the dataset is not known at the time that the transformer is enabled.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Data transformers — Altair 4.2.0 documentation
Storing JSON data in a separate directory . When creating many charts with alt.data_transformers.enable('json') the working directory can get a bit cluttered....
Read more >
Data is getting embedded via a local json file - altair
alt.data_transformers.enable('json'). If you want to restore the default data transformer which embeds data directly into the chart, run
Read more >
Using JSON data transformer for large dataset - Google Groups
I am plotting a large dataset, so I am trying to use the JSON data transformer: alt.data_transformers.enable('json').
Read more >
JSON Files - Spark 3.3.1 Documentation
Property Name Default Scope primitivesAsString false read prefersDecimal false read allowComments false read
Read more >
An Introduction to JSON | DigitalOcean
As its name suggests, JSON is derived from the JavaScript ... values can also be made up of the complex data types of...
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