b5dca485575de7052f2ce8f39ea845e848e1ac89,janitor/functions.py,,fill_direction,#Any#Any#Any#,4261

Before Change


        raise ValueError(f"Column {outcome} does not exist in the dataframe.")

    // check that the right directions are provided
    set_directions = {"up", "down", "updown", "downup"}

    // linter throws an error when I use dictionary.values()
    // it assumes that dictionary is a dataframe
    directions_values = [value for key, value in directions.items()]
    wrong_directions_provided = set(directions_values).difference(
        set_directions
    )
    if any(wrong_directions_provided):
        raise ValueError(
            The direction should be a string and should be one of `up`,
            `down`, `updown`, or `downup`.
        )

    for column, direction in directions.items():
        if direction == "up":
            df.loc[:, column] = df.loc[:, column].bfill(limit=limit)
        elif direction == "down":

After Change


    check_column(df, directions)

    for _, direction in directions.items():
        if direction not in {"up", "down", "updown", "downup"}:
            raise ValueError(
                
                The direction should be a string and should be one of
                `up`, `down`, `updown`, or `downup`.
                
            )

    // TODO: option to specify limit per column; current implementation
    // is one `limit` for all the columns. Might need refactoring, or an
    // API change.
    for column, direction in directions.items():
        if direction == "up":
            df.loc[:, column] = df.loc[:, column].bfill(limit=limit)
        elif direction == "down":
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 6

Instances


Project Name: ericmjl/pyjanitor
Commit Name: b5dca485575de7052f2ce8f39ea845e848e1ac89
Time: 2020-12-09
Author: samueloranyeli@gmail.com
File Name: janitor/functions.py
Class Name:
Method Name: fill_direction


Project Name: dit/dit
Commit Name: 3181b06a66ee5a2185f637e4072cc8e24d0801ec
Time: 2015-03-05
Author: chebee7i@gmail.com
File Name: dit/validate.py
Class Name:
Method Name: validate_outcomes


Project Name: pantsbuild/pants
Commit Name: 7819724acb0f0e6fd83a3cd9ec6b5b72a9799721
Time: 2019-02-26
Author: codealchemy@users.noreply.github.com
File Name: src/python/pants/task/task.py
Class Name: TaskBase
Method Name: get_targets