-
Notifications
You must be signed in to change notification settings - Fork 166
Convert dt.isna()
to FExpr
#3444
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
Open
samukweku
wants to merge
54
commits into
main
Choose a base branch
from
samukweku/fexpr_isna
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 45 commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
4c4b05d
add header for isna
samukweku c609de1
implemenation of isna fexpr
samukweku 7acfade
update docs
samukweku d69b35f
modify docs
samukweku adfd351
fixes
samukweku 629df72
add method for isna
samukweku f34944f
add tests for isna method
samukweku 4c5351c
format with clang-format
samukweku 59fc3f6
indent
samukweku 18d1f97
update fexpr_isna
samukweku d30c226
add to api/fexpr.rst
samukweku a704458
fix spelling
samukweku 0fcbd68
fix docs failing
samukweku ae3ee4b
Update docs/api/math/isna.rst
samukweku af6be42
Update docs/api/math/isna.rst
samukweku ff06759
Update docs/api/math/isna.rst
samukweku adb4cf4
Update src/core/expr/funary/isna/fexpr_isna.cc
samukweku 64b86db
ditch isna folder
samukweku d95f0c1
update fexpr
samukweku 0733560
simplify logic for isna
samukweku 80b687f
further simplify isna logic
samukweku d87df85
cleanup fillna.cc
samukweku 7a382b8
use ternary operator where possible
samukweku 781c2c3
fix indent
samukweku 9037d0b
use FExpr_FuncUnary for isna
samukweku 8704c50
updates based on feedback
samukweku 890e56d
fix test fails
samukweku 2a43959
updates based on feedback
samukweku b58e930
restore newline
samukweku 4c90f41
updates
samukweku 8e78f88
move make_isna_col to isna.h
samukweku ef1a9cb
update based on feedback
samukweku 8fdec20
enhance examples
samukweku 1c7098a
move fexpr_isna to main folder
samukweku ed687fe
add isna to docs
samukweku c7dcddf
rename doc_isna to doc_dt_isna
samukweku b32397d
doc_dt_isna
samukweku a734bcf
Implement slicing for categorical columns (#3379)
oleksiyskononenko f59c1b6
Minor refactoring of methods to get the underlying column type (#3458)
oleksiyskononenko 3df983f
Update docs/api/dt/isna.rst
samukweku d41570f
Update docs/api/fexpr.rst
samukweku 55efdfe
Update docs/api/math/isna.rst
samukweku 46535b3
implemenation of isna fexpr
samukweku 8856726
update based on feedback
samukweku 3a6d83b
fixes based on feedback
samukweku b06f1f5
Update src/core/column/isna.h
samukweku 95590b6
Update src/core/expr/fexpr_isna.cc
samukweku 7e70e25
remove irrelevant import
samukweku aa2ee23
updates based on code review
samukweku 05f51ad
fix for isna with non fexprs
samukweku aae69c8
import isna from a single point
samukweku aaec02e
copyright date updates
samukweku 46f53fe
update copyright dates
samukweku a193d14
Merge branch 'main' into samukweku/fexpr_isna
samukweku File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
|
||
.. xfunction:: datatable.isna | ||
:src: src/core/expr/fexpr_isna.cc pyfn_isna | ||
:tests: tests/math/test-isna.py | ||
:cvar: doc_dt_isna | ||
:signature: isna(cols) | ||
|
||
Test if the column elements are missing values. | ||
|
||
Parameters | ||
---------- | ||
cols: FExpr | ||
Input columns. | ||
|
||
return: FExpr | ||
f-expression that returns `0` for valid elements and `1` otherwise. | ||
All the resulting columns will have `bool8` stypes | ||
and as many rows/columns as there are in `cols`. | ||
|
||
Examples | ||
-------- | ||
|
||
.. code-block:: python | ||
|
||
>>> from datatable import dt, f | ||
>>> from datetime import datetime | ||
>>> DT = dt.Frame({'age': [5.0, 6.0, None], | ||
... 'born': [None, | ||
... datetime(1939, 5, 27, 0, 0), | ||
... datetime(1940, 4, 25, 0, 0)], | ||
... 'name': ['Alfred', 'Batman', ''], | ||
... 'toy': [None, 'Batmobile', 'Joker']}) | ||
>>> DT | ||
| age born name toy | ||
| float64 time64 str32 str32 | ||
-- + ------- ------------------- ------ --------- | ||
0 | 5 NA Alfred NA | ||
1 | 6 1939-05-27T00:00:00 Batman Batmobile | ||
2 | NA 1940-04-25T00:00:00 Joker | ||
[3 rows x 4 columns] | ||
>>> DT[:, dt.isna(f[:])] | ||
| age born name toy | ||
| bool8 bool8 bool8 bool8 | ||
-- + ----- ----- ----- ----- | ||
0 | 0 1 0 1 | ||
1 | 0 0 0 0 | ||
2 | 1 0 0 0 | ||
[3 rows x 4 columns] | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
.. xmethod:: datatable.FExpr.isna | ||
:src: src/core/expr/fexpr.cc PyFExpr::isna | ||
:cvar: doc_FExpr_isna | ||
:signature: isna() | ||
|
||
Equivalent to :func:`dt.isna(cols)`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
|
||
.. xfunction:: datatable.math.isna | ||
:src: src/core/expr/funary/floating.cc resolve_op_isna | ||
:src: src/core/expr/fexpr_isna.cc pyfn_isna | ||
:tests: tests/math/test-isna.py | ||
:cvar: doc_math_isna | ||
:signature: isna(x) | ||
:cvar: doc_dt_isna | ||
:signature: isna(cols) | ||
|
||
Same as :func:`dt.isna()`. | ||
|
||
|
||
Returns `True` if the argument is NA, and `False` otherwise. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
//------------------------------------------------------------------------------ | ||
// Copyright 2022-2023 H2O.ai | ||
samukweku marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a | ||
// copy of this software and associated documentation files (the "Software"), | ||
// to deal in the Software without restriction, including without limitation | ||
// the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
// and/or sell copies of the Software, and to permit persons to whom the | ||
// Software is furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
// IN THE SOFTWARE. | ||
//------------------------------------------------------------------------------ | ||
#include "column/const.h" | ||
#include "column/isna.h" | ||
#include "expr/fexpr_column.h" | ||
#include "documentation.h" | ||
#include "expr/fexpr_func_unary.h" | ||
#include "expr/eval_context.h" | ||
#include "expr/workframe.h" | ||
#include "python/xargs.h" | ||
#include "stype.h" | ||
namespace dt { | ||
namespace expr { | ||
|
||
|
||
class FExpr_ISNA : public FExpr_FuncUnary { | ||
public: | ||
using FExpr_FuncUnary::FExpr_FuncUnary; | ||
|
||
|
||
std::string name() const override { | ||
return "isna"; | ||
} | ||
|
||
Column evaluate1(Column&& col) const override{ | ||
return make_isna_col(std::move(col)); | ||
} | ||
}; | ||
|
||
|
||
static py::oobj pyfn_isna(const py::XArgs &args) { | ||
auto isna = args[0].to_oobj(); | ||
return PyFExpr::make(new FExpr_ISNA(as_fexpr(isna))); | ||
} | ||
|
||
DECLARE_PYFN(&pyfn_isna) | ||
->name("isna") | ||
->docs(doc_dt_isna) | ||
->arg_names({"cols"}) | ||
->n_positional_args(1) | ||
->n_required_args(1); | ||
|
||
|
||
}} // dt::expr | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.