Path: blob/master/tutorials-and-examples/feature-tutorials/DataViewer.ipynb
3253 views
Data Viewer
This notebook demonstrates the use of the DataViewer control.
It provides some basic features that let you browse pandas DataFrames more easily:
Scrollable data viewer taking fixed amount of output cell space
Sorting data by column
Column selection
Data filtering
Read in some data to demonstrate
Use the DataViewer to display a DataFrame
Specify an initial set of columns
Use "Choose columns" to select which columns to display
The right side list contains the available columns in the DataFrame, the left side is the list of columns to display.
Use the Add/Remove buttons to add or remove columns from the selected set. You can select multiple columns using Ctrl+Click or Shift+Click (the former selects or deselects an item for each click, the latter selects a range of items between the last item selected and the currently-clicked item).
Click on Apply columns to update the data view.
Filtering the data
You can apply multiple filters - each filter is additive, i.e. each is logically ANDed with the others.
The "Filter data" drop down shows the following controls:
Filter expression editor
Column selector drop-down - which column you want the filter to apply to
Not checkbox - invert the logic of the filter (for this filter item only)
Operator drop-down - the available operators are different for string and non-string (numeric and dates)
Expression text box - type in the expression that you want to match
Add filter - adds the current filter items as a new filter expression to Current filters
Update filter - overwrites the selected filter in Current filters with the current filter expression
Current filters
Select the filter expression you want to operate on from the Filters list
Delete filter deletes the selected item
Clear all filters removes all filter expressions
Apply filter - applies the filter items to the data and updates the display
Advanced querying with filter query operator
The query operator lets you type in a pandas query expression.
Note, the selected column is not relevant for this operator since you specify the column name
within the query expression. You can select any column name.
See this documentation for the syntax of the pandas query method
Accessing the filtered data
Use the filtered_data property of the DataViewer to retrieve a DataFrame corresponding to the current column and row filtering.
Note column sorting is not captured in this data.