Skip to content

Commit

Permalink
Merge pull request #427 from machow/docs-filter
Browse files Browse the repository at this point in the history
document using an OR condition in filter
  • Loading branch information
machow authored Jun 26, 2022
2 parents fe1155c + d8acea6 commit 74502e8
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
31 changes: 31 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-20.04
tools:
python: "3.9"
# You can also specify other tool versions:
# nodejs: "16"
# rust: "1.55"
# golang: "1.17"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

# If using Sphinx, optionally build your docs in additional formats such as PDF
# formats:
# - pdf

# Optionally declare the Python requirements required to build your docs
python:
install:
- requirements: requirements-dev.txt
- method: pip
path: .
15 changes: 15 additions & 0 deletions docs/api_table_core/01_filter.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@ For example, in the code below, a row must meet two conditions to be kept in the
mtcars >> filter(_.cyl == 4, _.gear == 5)
```

### Filters with OR conditions

In order to keep a row when one of several conditions is met, use the bar (`|`) operator.

```{python}
mtcars >> filter((_.cyl == 4) | (_.gear == 5))
```

The code above keeps rows where `cyl` is equal to 4 OR `gear` is equal to 5.

Be sure to explicitly put parentheses around both sides.
Otherwise, python will group the operation like `_.cyl == (4 | _.gear) == 5`.

### Dropping NAs

As with most subsetting in pandas, when a condition evalutes to an `NA` value, the row is automatically excluded. This is different from pandas indexing, where `NA` values produce errors.

```{python}
Expand Down
1 change: 0 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
:caption: Reference

api_user_index
api_developer/index
api_extra/index


Expand Down

0 comments on commit 74502e8

Please sign in to comment.