Skip to content

Commit

Permalink
Add date examples to cookbook. Closes #113.
Browse files Browse the repository at this point in the history
  • Loading branch information
onyxfish committed Sep 7, 2015
1 parent 663759f commit 46a870d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
17 changes: 17 additions & 0 deletions docs/cookbook/filtering.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,23 @@ This snippet filters the dataset to incomes between 100,000 and 200,000.
new_table = table.where(lambda row: 100000 < row['income'] < 200000)
Filter to date range
====================
This snippet filters the dataset to events during the summer of 2015:
.. code-block:: python
import datetime
new_table = table.where(lambda row: datetime.datetime(2015, 6, 1) <= row['date'] <= datetime.datetime(2015, 8, 31))
If you want to filter to events during the summer of any year:
.. code-block:: python
new_table = table.where(lambda row: 6 <= row['date'].month <= 8)
Filter to top x%
================
Expand Down
9 changes: 8 additions & 1 deletion docs/cookbook/sorting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ Order a table by the :code:`last_name` column:
new_table = table.order_by('last_name')
Sort by date
============

Sorting by dates also wrks as expected:

.. code-block:: python
new_table = table.order_by('birthdate')
Multicolumn sort
================
Expand All @@ -31,4 +39,3 @@ Randomizing order
import random
new_table = table.order_by(lambda row: random.random())

0 comments on commit 46a870d

Please sign in to comment.