Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document using an OR condition in filter #427

Merged
merged 5 commits into from
Jun 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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