Skip to content

Commit 594e72e

Browse files
committed
DOCS-quantopian#22: Update features section
Signed-off-by: Richard Lin <[email protected]>
1 parent dac454f commit 594e72e

File tree

1 file changed

+31
-33
lines changed

1 file changed

+31
-33
lines changed

README.rst

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -51,35 +51,40 @@ If needed, Modin-spreadsheet can be installed through PyPi. ::
5151

5252
pip install modin-spreadsheet
5353

54-
What's New
54+
Features
5555
----------
56-
**Column-specific options (as of 1.1.0)**:
57-
Thanks to a significant `PR from the community <https://github.com/quantopian/qgrid/pull/191>`_, Qgrid users now have the ability to set a number of options on a per column basis. This allows you to do things like explicitly specify which column should be sortable, editable, etc. For example, if you wanted to prevent editing on all columns except for a column named `'A'`, you could do the following::
56+
**Column-specific options**:
57+
The feature enables the ability to set options on a per column basis. This allows you to do things like explicitly
58+
specify which column should be sortable, editable, etc. For example, if you wanted to prevent editing on all columns
59+
except for a column named `'A'`, you could do the following::
5860

5961
col_opts = { 'editable': False }
6062
col_defs = { 'A': { 'editable': True } }
61-
qgrid.show_grid(df, column_options=col_opts, column_definitions=col_defs)
63+
modin_spreadsheet.show_grid(df, column_options=col_opts, column_definitions=col_defs)
6264

63-
See the updated `show_grid <https://qgrid.readthedocs.io/en/v1.1.0/#qgrid.show_grid>`_ documentation for more information.
65+
See the `show_grid <https://qgrid.readthedocs.io/en/v1.1.0/#qgrid.show_grid>`_ documentation for more information.
6466

65-
**Disable editing on a per-row basis (as of 1.1.0)**:
66-
This feature can be thought of as the first row-specific option that qgrid supports. In particular it allows a user to specify, using python code, whether or not a particular row should be editable. For example, to make it so only rows in the grid where the `'status'` column is set to `'active'` are editable, you might use the following code::
67+
**Disable editing on a per-row basis**:
68+
This feature allows a user to specify whether or not a particular row should be editable. For example, to make it so
69+
only rows in the grid where the `'status'` column is set to `'active'` are editable, you might use the following code::
6770

6871
def can_edit_row(row):
6972
return row['status'] == 'active'
7073

71-
qgrid.show_grid(df, row_edit_callback=can_edit_row)
74+
modin_spreadsheet.show_grid(df, row_edit_callback=can_edit_row)
7275

73-
**New API methods for dynamically updating an existing qgrid widget (as of 1.1.0)**:
74-
Adds the following new methods, which can be used to update the state of an existing Qgrid widget without having to call `show_grid` to completely rebuild the widget:
76+
**Dynamically update an existing spreadsheet widget**:
77+
These API allow users to programmatically update the state of an existing spreadsheet widget:
7578

7679
- `edit_cell <https://qgrid.readthedocs.io/en/latest/#qgrid.QgridWidget.edit_cell>`_
7780
- `change_selection <https://qgrid.readthedocs.io/en/latest/#qgrid.QgridWidget.change_selection>`_
7881
- `toggle_editable <https://qgrid.readthedocs.io/en/latest/#qgrid.QgridWidget.toggle_editable>`_
7982
- `change_grid_option <https://qgrid.readthedocs.io/en/latest/#qgrid.QgridWidget.change_grid_option>`_ (experimental)
8083

81-
**Improved MultiIndex Support (as of 1.0.6-beta.6)**:
82-
Qgrid now displays multi-indexed DataFrames with some of the index cells merged for readability, as is normally done when viewing DataFrames as a static html table. The following image shows qgrid displaying a multi-indexed DataFrame that was returned from Quantopian's `Pipeline API <https://www.quantopian.com/tutorials/pipeline?utm_source=github&utm_medium=web&utm_campaign=qgrid-repo>`_:
84+
**MultiIndex Support**:
85+
Modin-spreadsheet displays multi-indexed DataFrames with some of the index cells merged for readability, as is normally
86+
done when viewing DataFrames as a static html table. The following image shows Modin-spreadsheet displaying a
87+
multi-indexed DataFrame:
8388

8489
.. figure:: https://s3.amazonaws.com/quantopian-forums/pipeline_with_qgrid.png
8590
:align: left
@@ -133,33 +138,26 @@ of the repository.
133138

134139
Events API
135140
----------
136-
As of qgrid 1.0.3 there are new ``on`` and ``off`` methods in qgrid which can be used to attach/detach event handlers. They're available on both the ``modin_spreadsheet`` module (see `qgrid.on <https://qgrid.readthedocs.io/en/latest/#qgrid.on>`_), and on individual SpreadsheetWidget instances (see `qgrid.QgridWidget.on <https://qgrid.readthedocs.io/en/latest/#qgrid.QgridWidget.on>`_). Previously the only way to listen for events was to use undocumented parts of the API.
141+
The Events API provides ``on`` and ``off`` methods which can be used to attach/detach event handlers. They're available
142+
on both the ``modin_spreadsheet`` module (see `qgrid.on <https://qgrid.readthedocs.io/en/latest/#qgrid.on>`_), and on
143+
individual SpreadsheetWidget instances (see `qgrid.QgridWidget.on <https://qgrid.readthedocs.io/en/latest/#qgrid.QgridWidget.on>`_).
137144

138-
Having the ability to attach event handlers allows us to do some interesting things in terms of using modin-spreadsheet in conjunction with other widgets/visualizations. One example is using modin-spreadsheet to filter a DataFrame that's also being displayed by another visualization.
145+
Having the ability to attach event handlers allows us to do some interesting things in terms of using modin-spreadsheet
146+
in conjunction with other widgets/visualizations. One example is using modin-spreadsheet to filter a DataFrame that's
147+
also being displayed by another visualization.
139148

140-
If you previously used the ``observe`` method to respond to modin-spreadsheet events, lets see how your code might be updated to use the new ``on`` method::
149+
Here's how you would use the ``on`` method to print the DataFrame every time there's a change made::
141150

142-
# Before upgrading to 1.0.3
143-
def handle_df_change(change):
144-
print(change['new'])
145-
146-
qgrid_widget.observe(handle_df_change, names=['_df'])
147-
148-
When you upgrade to 1.0.3, you have more granular control over which events you do an don't listen to, but you can also replicate the previous behavior of calling ``print`` every time the state of the internal DataFrame is changed. Here's what that would look like using the new ``on`` method::
149-
150-
# After upgrading to 1.0.3
151-
def handle_json_updated(event, qgrid_widget):
151+
def handle_json_updated(event, spreadsheet_widget):
152152
# exclude 'viewport_changed' events since that doesn't change the DataFrame
153153
if (event['triggered_by'] != 'viewport_changed'):
154-
print(qgrid_widget.get_changed_df())
155-
156-
qgrid_widget.on('json_updated', handle_json_updated)
154+
print(spreadsheet_widget.get_changed_df())
157155

158-
See the `events notebook <https://mybinder.org/v2/gh/quantopian/qgrid-notebooks/master?filepath=events.ipynb>`_ for more examples of using these new API methods.
156+
spreadsheet_widget.on('json_updated', handle_json_updated)
159157

160-
For people who would rather not go to another page to try out the events notebook, here are a couple of gifs to give you an idea of what you can do with it.
158+
Here are some examples of how the Events API can be applied.
161159

162-
The first gif shows how you can use modin-spreadsheet to filter the data that's being shown by a matplotlib scatter plot:
160+
This shows how you can use modin-spreadsheet to filter the data that's being shown by a matplotlib scatter plot:
163161

164162
.. figure:: docs/images/linked_to_scatter.gif
165163
:align: left
@@ -168,8 +166,8 @@ The first gif shows how you can use modin-spreadsheet to filter the data that's
168166

169167
A brief demo showing modin-spreadsheet hooked up to a matplotlib plot
170168

171-
The second gif shows how events are recorded. The layout is specific to JupyterLab, which is not yet supported, but the
172-
Events API is the same on Jupyter notebook.
169+
This shows how events are recorded in real-time. The demo is recorded on JupyterLab, which is not yet supported, but
170+
the functionality is the same on Jupyter Notebook.
173171

174172
.. figure:: docs/images/events_api.gif
175173
:align: left

0 commit comments

Comments
 (0)