Skip to content

Commit

Permalink
rewrite Check class docstrings to remove pandas assumption (unionai-o…
Browse files Browse the repository at this point in the history
…ss#1614)

Signed-off-by: cosmicBboy <niels.bantilan@gmail.com>
Signed-off-by: Connor Stabnick <cstabnick@gmail.com>
  • Loading branch information
cosmicBboy authored and cstabnick committed May 6, 2024
1 parent 4724036 commit 29eb843
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions pandera/api/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(
) -> None:
"""Apply a validation function to a data object.
:param check_fn: A function to check pandas data structure. For Column
:param check_fn: A function to check data object. For Column
or SeriesSchema checks, if element_wise is True, this function
should have the signature: ``Callable[[pd.Series],
Union[pd.Series, bool]]``, where the output series is a boolean
Expand Down Expand Up @@ -106,6 +106,9 @@ def __init__(
:example:
The example below uses ``pandas``, but will apply to any of the supported
:ref:`dataframe libraries <dataframe-libraries>`.
>>> import pandas as pd
>>> import pandera as pa
>>>
Expand Down Expand Up @@ -202,9 +205,9 @@ def __call__(
column: Optional[str] = None,
) -> CheckResult:
# pylint: disable=too-many-branches
"""Validate pandas DataFrame or Series.
"""Validate DataFrame or Series.
:param check_obj: pandas DataFrame of Series to validate.
:param check_obj: DataFrame of Series to validate.
:param column: for dataframe checks, apply the check function to this
column.
:returns: CheckResult tuple containing:
Expand All @@ -216,10 +219,10 @@ def __call__(
passed overall.
``checked_object``: the checked object itself. Depending on the
options provided to the ``Check``, this will be a pandas Series,
DataFrame, or if the ``groupby`` option is specified, a
``Dict[str, Series]`` or ``Dict[str, DataFrame]`` where the keys
are distinct groups.
options provided to the ``Check``, this will be a Series,
DataFrame, or if the ``groupby`` option is supported by the validation
backend and specified, a ``Dict[str, Series]`` or ``Dict[str, DataFrame]``
where the keys are distinct groups.
``failure_cases``: subset of the check_object that failed.
"""
Expand All @@ -230,7 +233,7 @@ def __call__(
def equal_to(cls, value: Any, **kwargs) -> "Check":
"""Ensure all elements of a data container equal a certain value.
:param value: values in this pandas data structure must be
:param value: values in this data object must be
equal to this value.
"""
return cls.from_builtin_check_name(
Expand All @@ -244,8 +247,7 @@ def equal_to(cls, value: Any, **kwargs) -> "Check":
def not_equal_to(cls, value: Any, **kwargs) -> "Check":
"""Ensure no elements of a data container equals a certain value.
:param value: This value must not occur in the checked
:class:`pandas.Series`.
:param value: This value must not occur in the data object.
"""
return cls.from_builtin_check_name(
"not_equal_to",
Expand All @@ -261,7 +263,7 @@ def greater_than(cls, min_value: Any, **kwargs) -> "Check":
value.
:param min_value: Lower bound to be exceeded. Must be a type comparable
to the dtype of the :class:`pandas.Series` to be validated (e.g. a
to the dtype of the data object to be validated (e.g. a
numerical type for float or int and a datetime for datetime).
"""
if min_value is None:
Expand All @@ -277,8 +279,8 @@ def greater_than(cls, min_value: Any, **kwargs) -> "Check":
def greater_than_or_equal_to(cls, min_value: Any, **kwargs) -> "Check":
"""Ensure all values are greater or equal a certain value.
:param min_value: Allowed minimum value for values of a series. Must be
a type comparable to the dtype of the :class:`pandas.Series` to be
:param min_value: Allowed minimum value for values of the data. Must be
a type comparable to the dtype of the data object to be
validated.
"""
if min_value is None:
Expand All @@ -296,7 +298,7 @@ def less_than(cls, max_value: Any, **kwargs) -> "Check":
:param max_value: All elements of a series must be strictly smaller
than this. Must be a type comparable to the dtype of the
:class:`pandas.Series` to be validated.
data object to be validated.
"""
if max_value is None:
raise ValueError("max_value must not be None")
Expand All @@ -312,7 +314,7 @@ def less_than_or_equal_to(cls, max_value: Any, **kwargs) -> "Check":
"""Ensure values of a series are strictly below a maximum value.
:param max_value: Upper bound not to be exceeded. Must be a type
comparable to the dtype of the :class:`pandas.Series` to be
comparable to the dtype of the data object to be
validated.
"""
if max_value is None:
Expand Down

0 comments on commit 29eb843

Please sign in to comment.