-
Notifications
You must be signed in to change notification settings - Fork 21
Add null
object, and update top-level API specification
#157
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
Changes from 3 commits
7676a90
3489e31
55d53b6
ea276ca
884c67b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
""" | ||
from __future__ import annotations | ||
|
||
from typing import Mapping, Sequence | ||
from typing import Mapping, Sequence, Any | ||
|
||
from .column_object import * | ||
from .dataframe_object import * | ||
|
@@ -14,8 +14,9 @@ | |
|
||
__dataframe_api_version__: str = "YYYY.MM" | ||
""" | ||
String representing the version of the DataFrame API specification to which the | ||
conforming implementation adheres. | ||
String representing the version of the DataFrame API specification to which | ||
the conforming implementation adheres. Set to a concrete value for a stable | ||
implementation of the dataframe API standard. | ||
""" | ||
|
||
def concat(dataframes: Sequence[DataFrame]) -> DataFrame: | ||
|
@@ -73,3 +74,48 @@ def dataframe_from_dict(data: Mapping[str, Column]) -> DataFrame: | |
DataFrame | ||
""" | ||
... | ||
|
||
class null: | ||
""" | ||
A `null` object to represent missing data. | ||
|
||
``null`` is a scalar, and may be used when constructing a `Column` from a | ||
Python sequence with `column_from_sequence`. It does not support ``is``, | ||
``==`` or ``bool``. | ||
|
||
Raises | ||
------ | ||
TypeError | ||
From ``__eq__`` and from ``__bool__``. | ||
|
||
For ``_eq__``: a missing value must not be compared for equality | ||
directly. Instead, use `DataFrame.isnull` or `Column.isnull` to check | ||
for presence of missing values. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How can one check if a scalar is null reliably then? Do we need a namespace I.E. someone runs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question, I see a few options:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think the first two options are viable: A free There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a free |
||
|
||
For ``__bool__``: truthiness of a missing value is ambiguous. | ||
|
||
Notes | ||
----- | ||
Like for Python scalars, the ``null`` object may be duck typed so it can | ||
reside on (e.g.) a GPU. Hence, the builtin ``is`` keyword should not be | ||
used to check if an object *is* the ``null`` object. | ||
|
||
""" | ||
... | ||
|
||
def isnull(value: Any, /) -> bool: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can always address this later though - I'd say let's just get this in now There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure, let's do that now. and you made that review comment on another PR before, sorry I forgot about it. will update in a minute. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sure. There's nothing saying that those exist or must be used, right? This seems like a detail that an implementer has to get right. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah it's just easier for the implementer to get it right if the type checker flags to them if they're using something which all python objects don't have |
||
""" | ||
Check if an object is a `null` scalar. | ||
|
||
Parameters | ||
---------- | ||
value : Any | ||
Any input type is valid. | ||
|
||
Returns | ||
------- | ||
bool | ||
True if the input is a `null` object from the same library which | ||
implements the dataframe API standard, False otherwise. | ||
|
||
""" |
Uh oh!
There was an error while loading. Please reload this page.