Skip to content

Commit 06659d5

Browse files
loganthomasZeroto521ericmjl
authored
[DOC] MkDocs Utils Part 4 (#923)
* [INF] simplify a bit linting, use pre-commit as CI linting checker (#892) * [INF] simplify a bit linting There is two similar linting CIs (pre-commit and code-checks) but also have tiny differences. We should use one of them as the standard, not both. * Update CHANGELOG.md * should be `--config` not `-c` `-c` = `--code TEXT`, Format the code passed in as a string. * remove nbstripout keep the same with the old code-checks.yml * lint via pre-commit * Update CHANGELOG.md Co-authored-by: Eric Ma <[email protected]> * DOC: update _sub_expand_grid(pd.DataFrame) in utils * DOC: update _sub_expand_grid(pd.Index) in utils * DOC: update _data_checks_complete() in utils * DOC: update _computations_complete() in utils * DOC: update _create_indexer_for_complete() in utils Co-authored-by: Zero <[email protected]> Co-authored-by: Eric Ma <[email protected]>
1 parent 544dbdc commit 06659d5

File tree

1 file changed

+23
-28
lines changed

1 file changed

+23
-28
lines changed

janitor/utils.py

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -615,13 +615,11 @@ def _sub_expand_grid( # noqa: F811
615615
"""
616616
Expands the DataFrame based on `mgrid_values`.
617617
618-
`mode` parameter is added, to make the function reusable
619-
in the `_computations_complete` function.
620-
Also, allowing `key` as None enables reuse in the
621-
`_computations_complete` function.
618+
The `mode` parameter is added, to make the function reusable in the
619+
`_computations_complete` function. Also, allowing `key` as `None`
620+
enables reuse in the `_computations_complete` function.
622621
623622
Checks for empty dataframe and returns modified keys.
624-
625623
Returns a DataFrame with new column names.
626624
"""
627625
if value.empty:
@@ -648,15 +646,13 @@ def _sub_expand_grid( # noqa: F811
648646
"""
649647
Expands the Index based on `mgrid_values`.
650648
651-
`mode` parameter is added, to make the function reusable
652-
in the `_computations_complete` function.
653-
Also, allowing `key` as None enables reuse in the
654-
`_computations_complete` function.
649+
The `mode` parameter is added, to make the function reusable in the
650+
`_computations_complete` function. Also, allowing `key` as `None`
651+
enables reuse in the `_computations_complete` function.
655652
656653
Checks for empty Index and returns modified keys.
657-
658654
Returns a DataFrame (if MultiIndex) with new column names,
659-
or a Series with a new name.
655+
or a pandas Series with a new name.
660656
"""
661657
if value.empty:
662658
raise ValueError("""Index cannot be empty.""")
@@ -690,12 +686,10 @@ def _data_checks_complete(
690686
types within the `columns` parameter.
691687
692688
Check is conducted to ensure that column names are not repeated.
693-
694689
Also checks that the names in `columns` actually exist in `df`.
695690
696-
Returns `df`, `columns`, `column_checker`,
697-
and `by` if all checks pass.
698-
691+
Returns `df`, `columns`, `column_checker`, and `by` if
692+
all checks pass.
699693
"""
700694
# TODO: get `complete` to work on MultiIndex columns,
701695
# if there is sufficient interest with use cases
@@ -748,21 +742,22 @@ def _computations_complete(
748742
"""
749743
This function computes the final output for the `complete` function.
750744
751-
If `by` is present, then groupby apply is used.
745+
If `by` is present, then `groupby().apply()` is used.
752746
753-
For some cases, the `stack/unstack` combination is preferred; it is more
754-
efficient than `reindex`, as the size of the data grows. It is only
755-
applicable if all the entries in `columns` are strings, there are
756-
no nulls(stacking implicitly removes nulls in columns),
757-
the length of `columns` is greater than 1, and the index
747+
For some cases, the `stack/unstack` combination is preferred;
748+
it is more efficient than `reindex`, as the size of the data grows.
749+
It is only applicable if all the entries in `columns` are strings,
750+
there are no nulls (stacking implicitly removes nulls in columns),
751+
the length of `columns` is greater than `1`, and the index
758752
has no duplicates.
759753
760-
If there is a dictionary in `columns`, it is possible that all the values
761-
of a key, or keys, may not be in the existing column with the same key(s);
762-
as such, a union of the current index and the generated index is executed,
763-
to ensure that all combinations are in the final dataframe.
754+
If there is a dictionary in `columns`, it is possible that all the
755+
values of a key, or keys, may not be in the existing column with
756+
the same key(s); as such, a union of the current index and the
757+
generated index is executed, to ensure that all combinations are
758+
in the final DataFrame.
764759
765-
A dataframe, with rows of missing values, if any, is returned.
760+
Returns a DataFrame with rows of missing values, if any exist.
766761
"""
767762

768763
df, columns, column_checker, by = _data_checks_complete(df, columns, by)
@@ -848,8 +843,8 @@ def _create_indexer_for_complete(
848843
columns: List[Union[List, Dict, str]],
849844
) -> pd.DataFrame:
850845
"""
851-
This creates the index that will be used
852-
to expand the dataframe in the `complete` function.
846+
This creates the index that will be used to expand the DataFrame in
847+
the `complete` function.
853848
854849
A pandas Index is returned.
855850
"""

0 commit comments

Comments
 (0)