man-group / dtale

Visualizer for pandas data structures
http://alphatechadmin.pythonanywhere.com
GNU Lesser General Public License v2.1
4.62k stars 390 forks source link

Access Altered DF Results (after filtering, sorting, etc.) #858

Closed eunosm3 closed 2 months ago

eunosm3 commented 2 months ago

Does D-Tale provide a method to access the results of a filtered/sorted/altered DF? For instance, if you sort by column X, filter by a value range and then add a column, is it possible to access those results in another cell using code like dtale.show(updatedDF, ...), etc.?

aschonfeld commented 2 months ago

So you can access the underlying data w/ any edits & sorting you've made, but no filtering. An example is this:

d = dtale.show(df)

#make some edits or add some columns using the UI

d.data  # this should return a dataframe with those edits

I'm going to add another property called view_data which will include any filtering

aschonfeld commented 2 months ago

@eunosm3 this update has been included in v3.12.0 which has just been released to pypi (soon to be on conda-forge as well). So to get the filtered data simply do something like

d = dtale.show(df)
d.view_data