You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having an issue with density transforms that seems to occur when providing data in the form of link to a .csv file. So far, this does not seem to be an issue when passing in the data as a link to a .json file.
As background, I'm coming to this from Altair. Starting from the Altair example for a Density plot, here is the original example in Altair:
import altair as alt
from vega_datasets import data
alt.Chart(data.movies.url).transform_density(
'IMDB_Rating',
as_=['IMDB_Rating', 'density'],
).mark_area().encode(
x="IMDB_Rating:Q",
y='density:Q',
)
which produces the following vega-lite specification (which works fine). Note that the url links to a json file:
However, if I change the data source to the seattle_weather dataset, and plot the temp_max variable in that dataset, the chart it produces is empty.
Here is the altair code:
import altair as alt
from vega_datasets import data
alt.Chart(data.seattle_weather.url).transform_density(
'temp_max',
as_=['temp_max', 'density'],
).mark_area().encode(
x="temp_max:Q",
y='density:Q',
)
which produces the following vega-lite specification (which links to a .csv file):
Interestingly, this works fine if I use vega datasets to convert the url into a dataframe, which embeds the entire dataset in the vega-lite specificaiton. Here is the working Altair code, which is the same, except for how the data source is specified:
import altair as alt
from vega_datasets import data
alt.Chart(data.seattle_weather()).transform_density(
'temp_max',
as_=['temp_max', 'density'],
).mark_area().encode(
x="temp_max:Q",
y='density:Q',
)
And the example in the editor, which similarly works.
Also, other types of plots also work with the seattle_weather data when using the url. For example, here is a scatter plot using the same variable in Altair:
which works find and produces the following vega-lite code in the editor.
I'm not 100% sure, but I think the problem arises when passing in data in the form of a URL that points to a .csv file. Here is another example using the Disasters dataset. In this case, the plot is not blank, but it is not correct (as can be verified by changing the altair code to embed the data in the vega-light specification, as above). Here is the Altair code:
dallascard
changed the title
Bug with density transform when providing data as a url
Bug with density transform when providing data as a url to a csv file
Nov 7, 2023
dallascard
changed the title
Bug with density transform when providing data as a url to a csv file
Bug with density transform when providing csv data as a url
Nov 7, 2023
Still working on this, but I think this issue is generated during process with csv extension.
In below example, use json file works fine Open the Chart in the Vega Editor
I'm having an issue with density transforms that seems to occur when providing data in the form of link to a .csv file. So far, this does not seem to be an issue when passing in the data as a link to a .json file.
As background, I'm coming to this from Altair. Starting from the Altair example for a Density plot, here is the original example in Altair:
which produces the following vega-lite specification (which works fine). Note that the url links to a json file:
(or in the vega-lite editor)
However, if I change the data source to the
seattle_weather
dataset, and plot thetemp_max
variable in that dataset, the chart it produces is empty.Here is the altair code:
which produces the following vega-lite specification (which links to a .csv file):
Example in Editor, which shows a blank plot.
Interestingly, this works fine if I use vega datasets to convert the url into a dataframe, which embeds the entire dataset in the vega-lite specificaiton. Here is the working Altair code, which is the same, except for how the data source is specified:
And the example in the editor, which similarly works.
Also, other types of plots also work with the
seattle_weather
data when using the url. For example, here is a scatter plot using the same variable in Altair:which works find and produces the following vega-lite code in the editor.
I'm not 100% sure, but I think the problem arises when passing in data in the form of a URL that points to a .csv file. Here is another example using the Disasters dataset. In this case, the plot is not blank, but it is not correct (as can be verified by changing the altair code to embed the data in the vega-light specification, as above). Here is the Altair code:
and the vega-lite specification:
and the live example in the editor.
The text was updated successfully, but these errors were encountered: