glue icon indicating copy to clipboard operation
glue copied to clipboard

Question: How to get Data out of DataCollection by label?

Open pllim opened this issue 4 years ago • 2 comments

Do you have something like this? 'Coz I can't find it in your API doc at http://docs.glueviz.org/en/latest/api/glue.core.data_collection.DataCollection.html

dc = app.data_collection  # Some API that gives me DataCollection object

# What you can do right now
data = dc[0]  # give it index

# What I want to do
data = dc.get_data_by_label(label_name)

pllim avatar May 26 '21 19:05 pllim

Is this what you're looking for?

Accessing the Data Collection

To access the data collection of the current glue session, call the following variable:

self.session.data_collection

This will allow you to directly access the data that is in Glue (the top left panel is a visual of what the data collection is).

WARNING: Do not use the variable "dc" in any of your code for the data viewer. The variable "dc" is already being used in the IPython Terminal as a default variable name for the data collection. If you use the variable "dc", then the IPython Terminal will break and not be able to call "dc". As a result, use a different variable name to assign the data collection. e.g

jk31768 avatar Jun 03 '21 15:06 jk31768

Re: https://github.com/glue-viz/glue/issues/2195#issuecomment-853938899

Thanks, but no.

pllim avatar Jun 03 '21 15:06 pllim