Is there a way, given a selection to give back the selected data as a dataframe for example?
I've never seen that in Altair but perhaps Jake knows a way. Something similar might be to have the selection displayed as a table (like a heat map but with text marks in the cells), but I know this is not exactly what you are asking.
No, there's no easy way to do that at the moment.
If you write a custom javascript frontend, it is theoretically possible via the vega view api, but I don't know of any example of that.
Making this easier is on the Vega-Lite roadmap, and once it's developed there we can think about how to support it from the Python side.
It would be nice to use the altair chart as a way to let user select input for some other part of code.
Currently I am using streamlit and such a usecase is coming up but I cannot really do anything about it.
Yes, it would be nice, and no, there is still no way to do this, because the selection happens in the Javascript layer and there is no mechanism for the Javascript to communicate back to Python. Enabling this would require changes to Altair, vega-embed, the vega IPython extension, and the vega Jupyter extension. I don't know of anybody working on this – if it's important to you, you might consider exploring what it would take.
Most helpful comment
Yes, it would be nice, and no, there is still no way to do this, because the selection happens in the Javascript layer and there is no mechanism for the Javascript to communicate back to Python. Enabling this would require changes to Altair, vega-embed, the vega IPython extension, and the vega Jupyter extension. I don't know of anybody working on this – if it's important to you, you might consider exploring what it would take.