The following issues were found

asv_bench/benchmarks/indexing_engines.py
14 issues
Unable to import 'pandas._libs'
Error

Line: 10 Column: 1

              
import numpy as np

from pandas._libs import index as libindex


def _get_numeric_engines():
    engine_names = [
        ("Int64Engine", np.int64),

            

Reported by Pylint.

Attribute 'data' defined outside __init__
Error

Line: 51 Column: 9

                          "non_monotonic": np.array([1, 2, 3] * N, dtype=dtype),
        }[index_type]

        self.data = engine(lambda: arr, len(arr))
        # code belows avoids populating the mapping etc. while timing.
        self.data.get_loc(2)

    def time_get_loc(self, engine_and_dtype, index_type):
        self.data.get_loc(2)

            

Reported by Pylint.

Unused argument 'engine_and_dtype'
Error

Line: 55 Column: 28

                      # code belows avoids populating the mapping etc. while timing.
        self.data.get_loc(2)

    def time_get_loc(self, engine_and_dtype, index_type):
        self.data.get_loc(2)


class ObjectEngineIndexing:


            

Reported by Pylint.

Unused argument 'index_type'
Error

Line: 55 Column: 46

                      # code belows avoids populating the mapping etc. while timing.
        self.data.get_loc(2)

    def time_get_loc(self, engine_and_dtype, index_type):
        self.data.get_loc(2)


class ObjectEngineIndexing:


            

Reported by Pylint.

Attribute 'data' defined outside __init__
Error

Line: 73 Column: 9

                          "non_monotonic": np.array(list("abc") * N, dtype=object),
        }[index_type]

        self.data = libindex.ObjectEngine(lambda: arr, len(arr))
        # code belows avoids populating the mapping etc. while timing.
        self.data.get_loc("b")

    def time_get_loc(self, index_type):
        self.data.get_loc("b")

            

Reported by Pylint.

Unused argument 'index_type'
Error

Line: 77 Column: 28

                      # code belows avoids populating the mapping etc. while timing.
        self.data.get_loc("b")

    def time_get_loc(self, index_type):
        self.data.get_loc("b")

            

Reported by Pylint.

Missing class docstring
Error

Line: 33 Column: 1

                  ]


class NumericEngineIndexing:

    params = [
        _get_numeric_engines(),
        ["monotonic_incr", "monotonic_decr", "non_monotonic"],
    ]

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 41 Column: 5

                  ]
    param_names = ["engine_and_dtype", "index_type"]

    def setup(self, engine_and_dtype, index_type):
        engine, dtype = engine_and_dtype
        N = 10 ** 5
        values = list([1] * N + [2] * N + [3] * N)
        arr = {
            "monotonic_incr": np.array(values, dtype=dtype),

            

Reported by Pylint.

Variable name "N" doesn't conform to snake_case naming style
Error

Line: 43 Column: 9

              
    def setup(self, engine_and_dtype, index_type):
        engine, dtype = engine_and_dtype
        N = 10 ** 5
        values = list([1] * N + [2] * N + [3] * N)
        arr = {
            "monotonic_incr": np.array(values, dtype=dtype),
            "monotonic_decr": np.array(list(reversed(values)), dtype=dtype),
            "non_monotonic": np.array([1, 2, 3] * N, dtype=dtype),

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 55 Column: 5

                      # code belows avoids populating the mapping etc. while timing.
        self.data.get_loc(2)

    def time_get_loc(self, engine_and_dtype, index_type):
        self.data.get_loc(2)


class ObjectEngineIndexing:


            

Reported by Pylint.

pandas/core/reshape/api.py
14 issues
Unused concat imported from pandas.core.reshape.concat
Error

Line: 3 Column: 1

              # flake8: noqa

from pandas.core.reshape.concat import concat
from pandas.core.reshape.melt import (
    lreshape,
    melt,
    wide_to_long,
)
from pandas.core.reshape.merge import (

            

Reported by Pylint.

Unused lreshape imported from pandas.core.reshape.melt
Error

Line: 4 Column: 1

              # flake8: noqa

from pandas.core.reshape.concat import concat
from pandas.core.reshape.melt import (
    lreshape,
    melt,
    wide_to_long,
)
from pandas.core.reshape.merge import (

            

Reported by Pylint.

Unused melt imported from pandas.core.reshape.melt
Error

Line: 4 Column: 1

              # flake8: noqa

from pandas.core.reshape.concat import concat
from pandas.core.reshape.melt import (
    lreshape,
    melt,
    wide_to_long,
)
from pandas.core.reshape.merge import (

            

Reported by Pylint.

Unused wide_to_long imported from pandas.core.reshape.melt
Error

Line: 4 Column: 1

              # flake8: noqa

from pandas.core.reshape.concat import concat
from pandas.core.reshape.melt import (
    lreshape,
    melt,
    wide_to_long,
)
from pandas.core.reshape.merge import (

            

Reported by Pylint.

Unused merge_ordered imported from pandas.core.reshape.merge
Error

Line: 9 Column: 1

                  melt,
    wide_to_long,
)
from pandas.core.reshape.merge import (
    merge,
    merge_asof,
    merge_ordered,
)
from pandas.core.reshape.pivot import (

            

Reported by Pylint.

Unused merge imported from pandas.core.reshape.merge
Error

Line: 9 Column: 1

                  melt,
    wide_to_long,
)
from pandas.core.reshape.merge import (
    merge,
    merge_asof,
    merge_ordered,
)
from pandas.core.reshape.pivot import (

            

Reported by Pylint.

Unused merge_asof imported from pandas.core.reshape.merge
Error

Line: 9 Column: 1

                  melt,
    wide_to_long,
)
from pandas.core.reshape.merge import (
    merge,
    merge_asof,
    merge_ordered,
)
from pandas.core.reshape.pivot import (

            

Reported by Pylint.

Unused crosstab imported from pandas.core.reshape.pivot
Error

Line: 14 Column: 1

                  merge_asof,
    merge_ordered,
)
from pandas.core.reshape.pivot import (
    crosstab,
    pivot,
    pivot_table,
)
from pandas.core.reshape.reshape import get_dummies

            

Reported by Pylint.

Unused pivot imported from pandas.core.reshape.pivot
Error

Line: 14 Column: 1

                  merge_asof,
    merge_ordered,
)
from pandas.core.reshape.pivot import (
    crosstab,
    pivot,
    pivot_table,
)
from pandas.core.reshape.reshape import get_dummies

            

Reported by Pylint.

Unused pivot_table imported from pandas.core.reshape.pivot
Error

Line: 14 Column: 1

                  merge_asof,
    merge_ordered,
)
from pandas.core.reshape.pivot import (
    crosstab,
    pivot,
    pivot_table,
)
from pandas.core.reshape.reshape import get_dummies

            

Reported by Pylint.

pandas/tests/frame/indexing/test_take.py
14 issues
Unable to import 'pytest'
Error

Line: 1 Column: 1

              import pytest

import pandas._testing as tm


class TestDataFrameTake:
    def test_take(self, float_frame):
        # homogeneous
        order = [3, 1, 2, 0]

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import pytest

import pandas._testing as tm


class TestDataFrameTake:
    def test_take(self, float_frame):
        # homogeneous
        order = [3, 1, 2, 0]

            

Reported by Pylint.

Missing class docstring
Error

Line: 6 Column: 1

              import pandas._testing as tm


class TestDataFrameTake:
    def test_take(self, float_frame):
        # homogeneous
        order = [3, 1, 2, 0]
        for df in [float_frame]:


            

Reported by Pylint.

Method could be a function
Error

Line: 7 Column: 5

              

class TestDataFrameTake:
    def test_take(self, float_frame):
        # homogeneous
        order = [3, 1, 2, 0]
        for df in [float_frame]:

            result = df.take(order, axis=0)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 7 Column: 5

              

class TestDataFrameTake:
    def test_take(self, float_frame):
        # homogeneous
        order = [3, 1, 2, 0]
        for df in [float_frame]:

            result = df.take(order, axis=0)

            

Reported by Pylint.

Variable name "df" doesn't conform to snake_case naming style
Error

Line: 10 Column: 13

                  def test_take(self, float_frame):
        # homogeneous
        order = [3, 1, 2, 0]
        for df in [float_frame]:

            result = df.take(order, axis=0)
            expected = df.reindex(df.index.take(order))
            tm.assert_frame_equal(result, expected)


            

Reported by Pylint.

Variable name "df" doesn't conform to snake_case naming style
Error

Line: 23 Column: 13

              
        # negative indices
        order = [2, 1, -1]
        for df in [float_frame]:

            result = df.take(order, axis=0)
            expected = df.reindex(df.index.take(order))
            tm.assert_frame_equal(result, expected)


            

Reported by Pylint.

Method could be a function
Error

Line: 48 Column: 5

                      with pytest.raises(IndexError, match=msg):
            df.take([3, 1, 2, -5], axis=1)

    def test_take_mixed_type(self, float_string_frame):

        # mixed-dtype
        order = [4, 1, 2, 0, 3]
        for df in [float_string_frame]:


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 48 Column: 5

                      with pytest.raises(IndexError, match=msg):
            df.take([3, 1, 2, -5], axis=1)

    def test_take_mixed_type(self, float_string_frame):

        # mixed-dtype
        order = [4, 1, 2, 0, 3]
        for df in [float_string_frame]:


            

Reported by Pylint.

Variable name "df" doesn't conform to snake_case naming style
Error

Line: 52 Column: 13

              
        # mixed-dtype
        order = [4, 1, 2, 0, 3]
        for df in [float_string_frame]:

            result = df.take(order, axis=0)
            expected = df.reindex(df.index.take(order))
            tm.assert_frame_equal(result, expected)


            

Reported by Pylint.

pandas/tests/arrays/floating/test_repr.py
14 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

import pandas as pd
from pandas.core.arrays.floating import (
    Float32Dtype,
    Float64Dtype,
)


            

Reported by Pylint.

Expression "np.dtype(dtype.type).kind == 'f'" is assigned to nothing
Error

Line: 14 Column: 5

              def test_dtypes(dtype):
    # smoke tests on auto dtype construction

    np.dtype(dtype.type).kind == "f"
    assert dtype.name is not None


@pytest.mark.parametrize(
    "dtype, expected",

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

import pandas as pd
from pandas.core.arrays.floating import (
    Float32Dtype,
    Float64Dtype,
)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 11 Column: 1

              )


def test_dtypes(dtype):
    # smoke tests on auto dtype construction

    np.dtype(dtype.type).kind == "f"
    assert dtype.name is not None


            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 15
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                  # smoke tests on auto dtype construction

    np.dtype(dtype.type).kind == "f"
    assert dtype.name is not None


@pytest.mark.parametrize(
    "dtype, expected",
    [(Float32Dtype(), "Float32Dtype()"), (Float64Dtype(), "Float64Dtype()")],

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 21 Column: 1

              @pytest.mark.parametrize(
    "dtype, expected",
    [(Float32Dtype(), "Float32Dtype()"), (Float64Dtype(), "Float64Dtype()")],
)
def test_repr_dtype(dtype, expected):
    assert repr(dtype) == expected


def test_repr_array():

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 23
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                  [(Float32Dtype(), "Float32Dtype()"), (Float64Dtype(), "Float64Dtype()")],
)
def test_repr_dtype(dtype, expected):
    assert repr(dtype) == expected


def test_repr_array():
    result = repr(pd.array([1.0, None, 3.0]))
    expected = "<FloatingArray>\n[1.0, <NA>, 3.0]\nLength: 3, dtype: Float64"

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 26 Column: 1

                  assert repr(dtype) == expected


def test_repr_array():
    result = repr(pd.array([1.0, None, 3.0]))
    expected = "<FloatingArray>\n[1.0, <NA>, 3.0]\nLength: 3, dtype: Float64"
    assert result == expected



            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 29
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

              def test_repr_array():
    result = repr(pd.array([1.0, None, 3.0]))
    expected = "<FloatingArray>\n[1.0, <NA>, 3.0]\nLength: 3, dtype: Float64"
    assert result == expected


def test_repr_array_long():
    data = pd.array([1.0, 2.0, None] * 1000)
    expected = """<FloatingArray>

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 32 Column: 1

                  assert result == expected


def test_repr_array_long():
    data = pd.array([1.0, 2.0, None] * 1000)
    expected = """<FloatingArray>
[ 1.0,  2.0, <NA>,  1.0,  2.0, <NA>,  1.0,  2.0, <NA>,  1.0,
 ...
 <NA>,  1.0,  2.0, <NA>,  1.0,  2.0, <NA>,  1.0,  2.0, <NA>]

            

Reported by Pylint.

pandas/core/indexers/objects.py
14 issues
No name 'indexers' in module 'pandas._libs.window'
Error

Line: 8 Column: 1

              
import numpy as np

from pandas._libs.window.indexers import calculate_variable_window_bounds
from pandas.util._decorators import Appender

from pandas.core.dtypes.common import ensure_platform_int

from pandas.tseries.offsets import Nano

            

Reported by Pylint.

Unable to import 'pandas._libs.window.indexers'
Error

Line: 8 Column: 1

              
import numpy as np

from pandas._libs.window.indexers import calculate_variable_window_bounds
from pandas.util._decorators import Appender

from pandas.core.dtypes.common import ensure_platform_int

from pandas.tseries.offsets import Nano

            

Reported by Pylint.

Unused variable 'key'
Error

Line: 327 Column: 13

                      start_arrays = []
        end_arrays = []
        window_indicies_start = 0
        for key, indices in self.groupby_indicies.items():
            index_array: np.ndarray | None

            if self.index_array is not None:
                index_array = self.index_array.take(ensure_platform_int(indices))
            else:

            

Reported by Pylint.

Constant name "get_window_bounds_doc" doesn't conform to UPPER_CASE naming style
Error

Line: 15 Column: 1

              
from pandas.tseries.offsets import Nano

get_window_bounds_doc = """
Computes the bounds of a window.

Parameters
----------
num_values : int, default 0

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 40 Column: 1

              """


class BaseIndexer:
    """Base class for window bounds calculations."""

    def __init__(
        self, index_array: np.ndarray | None = None, window_size: int = 0, **kwargs
    ):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 59 Column: 5

                          setattr(self, key, value)

    @Appender(get_window_bounds_doc)
    def get_window_bounds(
        self,
        num_values: int = 0,
        min_periods: int | None = None,
        center: bool | None = None,
        closed: str | None = None,

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 70 Column: 1

                      raise NotImplementedError


class FixedWindowIndexer(BaseIndexer):
    """Creates window boundaries that are of fixed length."""

    @Appender(get_window_bounds_doc)
    def get_window_bounds(
        self,

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 100 Column: 1

                      return start, end


class VariableWindowIndexer(BaseIndexer):
    """Creates window boundaries that are of variable length, namely for time series."""

    @Appender(get_window_bounds_doc)
    def get_window_bounds(
        self,

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 126 Column: 1

                      )


class VariableOffsetWindowIndexer(BaseIndexer):
    """Calculate window boundaries based on a non-fixed offset such as a BusinessDay"""

    def __init__(
        self,
        index_array: np.ndarray | None = None,

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 208 Column: 1

                      return start, end


class ExpandingIndexer(BaseIndexer):
    """Calculate expanding window bounds, mimicking df.expanding()"""

    @Appender(get_window_bounds_doc)
    def get_window_bounds(
        self,

            

Reported by Pylint.

pandas/tests/arrays/categorical/test_subclass.py
14 issues
Missing module docstring
Error

Line: 1 Column: 1

              from pandas import Categorical
import pandas._testing as tm


class TestCategoricalSubclassing:
    def test_constructor(self):
        sc = tm.SubclassedCategorical(["a", "b", "c"])
        assert isinstance(sc, tm.SubclassedCategorical)
        tm.assert_categorical_equal(sc, Categorical(["a", "b", "c"]))

            

Reported by Pylint.

Missing class docstring
Error

Line: 5 Column: 1

              import pandas._testing as tm


class TestCategoricalSubclassing:
    def test_constructor(self):
        sc = tm.SubclassedCategorical(["a", "b", "c"])
        assert isinstance(sc, tm.SubclassedCategorical)
        tm.assert_categorical_equal(sc, Categorical(["a", "b", "c"]))


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 6 Column: 5

              

class TestCategoricalSubclassing:
    def test_constructor(self):
        sc = tm.SubclassedCategorical(["a", "b", "c"])
        assert isinstance(sc, tm.SubclassedCategorical)
        tm.assert_categorical_equal(sc, Categorical(["a", "b", "c"]))

    def test_from_codes(self):

            

Reported by Pylint.

Method could be a function
Error

Line: 6 Column: 5

              

class TestCategoricalSubclassing:
    def test_constructor(self):
        sc = tm.SubclassedCategorical(["a", "b", "c"])
        assert isinstance(sc, tm.SubclassedCategorical)
        tm.assert_categorical_equal(sc, Categorical(["a", "b", "c"]))

    def test_from_codes(self):

            

Reported by Pylint.

Variable name "sc" doesn't conform to snake_case naming style
Error

Line: 7 Column: 9

              
class TestCategoricalSubclassing:
    def test_constructor(self):
        sc = tm.SubclassedCategorical(["a", "b", "c"])
        assert isinstance(sc, tm.SubclassedCategorical)
        tm.assert_categorical_equal(sc, Categorical(["a", "b", "c"]))

    def test_from_codes(self):
        sc = tm.SubclassedCategorical.from_codes([1, 0, 2], ["a", "b", "c"])

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 8
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

              class TestCategoricalSubclassing:
    def test_constructor(self):
        sc = tm.SubclassedCategorical(["a", "b", "c"])
        assert isinstance(sc, tm.SubclassedCategorical)
        tm.assert_categorical_equal(sc, Categorical(["a", "b", "c"]))

    def test_from_codes(self):
        sc = tm.SubclassedCategorical.from_codes([1, 0, 2], ["a", "b", "c"])
        assert isinstance(sc, tm.SubclassedCategorical)

            

Reported by Bandit.

Method could be a function
Error

Line: 11 Column: 5

                      assert isinstance(sc, tm.SubclassedCategorical)
        tm.assert_categorical_equal(sc, Categorical(["a", "b", "c"]))

    def test_from_codes(self):
        sc = tm.SubclassedCategorical.from_codes([1, 0, 2], ["a", "b", "c"])
        assert isinstance(sc, tm.SubclassedCategorical)
        exp = Categorical.from_codes([1, 0, 2], ["a", "b", "c"])
        tm.assert_categorical_equal(sc, exp)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 11 Column: 5

                      assert isinstance(sc, tm.SubclassedCategorical)
        tm.assert_categorical_equal(sc, Categorical(["a", "b", "c"]))

    def test_from_codes(self):
        sc = tm.SubclassedCategorical.from_codes([1, 0, 2], ["a", "b", "c"])
        assert isinstance(sc, tm.SubclassedCategorical)
        exp = Categorical.from_codes([1, 0, 2], ["a", "b", "c"])
        tm.assert_categorical_equal(sc, exp)


            

Reported by Pylint.

Variable name "sc" doesn't conform to snake_case naming style
Error

Line: 12 Column: 9

                      tm.assert_categorical_equal(sc, Categorical(["a", "b", "c"]))

    def test_from_codes(self):
        sc = tm.SubclassedCategorical.from_codes([1, 0, 2], ["a", "b", "c"])
        assert isinstance(sc, tm.SubclassedCategorical)
        exp = Categorical.from_codes([1, 0, 2], ["a", "b", "c"])
        tm.assert_categorical_equal(sc, exp)

    def test_map(self):

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 13
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

              
    def test_from_codes(self):
        sc = tm.SubclassedCategorical.from_codes([1, 0, 2], ["a", "b", "c"])
        assert isinstance(sc, tm.SubclassedCategorical)
        exp = Categorical.from_codes([1, 0, 2], ["a", "b", "c"])
        tm.assert_categorical_equal(sc, exp)

    def test_map(self):
        sc = tm.SubclassedCategorical(["a", "b", "c"])

            

Reported by Bandit.

pandas/tests/frame/methods/test_reindex_like.py
13 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

from pandas import DataFrame
import pandas._testing as tm


class TestDataFrameReindexLike:
    def test_reindex_like(self, float_frame):

            

Reported by Pylint.

Unused argument 'expected_values'
Error

Line: 22 Column: 49

                          ("backfill", [0, 1, 2, 2]),
        ],
    )
    def test_reindex_like_methods(self, method, expected_values):
        df = DataFrame({"x": list(range(5))})

        result = df.reindex_like(df, method=method, tolerance=0)
        tm.assert_frame_equal(df, result)
        result = df.reindex_like(df, method=method, tolerance=[0, 0, 0, 0])

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

from pandas import DataFrame
import pandas._testing as tm


class TestDataFrameReindexLike:
    def test_reindex_like(self, float_frame):

            

Reported by Pylint.

Missing class docstring
Error

Line: 8 Column: 1

              import pandas._testing as tm


class TestDataFrameReindexLike:
    def test_reindex_like(self, float_frame):
        other = float_frame.reindex(index=float_frame.index[:10], columns=["C", "B"])

        tm.assert_frame_equal(other, float_frame.reindex_like(other))


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 9 Column: 5

              

class TestDataFrameReindexLike:
    def test_reindex_like(self, float_frame):
        other = float_frame.reindex(index=float_frame.index[:10], columns=["C", "B"])

        tm.assert_frame_equal(other, float_frame.reindex_like(other))

    @pytest.mark.parametrize(

            

Reported by Pylint.

Method could be a function
Error

Line: 9 Column: 5

              

class TestDataFrameReindexLike:
    def test_reindex_like(self, float_frame):
        other = float_frame.reindex(index=float_frame.index[:10], columns=["C", "B"])

        tm.assert_frame_equal(other, float_frame.reindex_like(other))

    @pytest.mark.parametrize(

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 20 Column: 5

                          ("nearest", [0, 1, 1, 2]),
            ("pad", [np.nan, 0, 1, 1]),
            ("backfill", [0, 1, 2, 2]),
        ],
    )
    def test_reindex_like_methods(self, method, expected_values):
        df = DataFrame({"x": list(range(5))})

        result = df.reindex_like(df, method=method, tolerance=0)

            

Reported by Pylint.

Method could be a function
Error

Line: 20 Column: 5

                          ("nearest", [0, 1, 1, 2]),
            ("pad", [np.nan, 0, 1, 1]),
            ("backfill", [0, 1, 2, 2]),
        ],
    )
    def test_reindex_like_methods(self, method, expected_values):
        df = DataFrame({"x": list(range(5))})

        result = df.reindex_like(df, method=method, tolerance=0)

            

Reported by Pylint.

Variable name "df" doesn't conform to snake_case naming style
Error

Line: 23 Column: 9

                      ],
    )
    def test_reindex_like_methods(self, method, expected_values):
        df = DataFrame({"x": list(range(5))})

        result = df.reindex_like(df, method=method, tolerance=0)
        tm.assert_frame_equal(df, result)
        result = df.reindex_like(df, method=method, tolerance=[0, 0, 0, 0])
        tm.assert_frame_equal(df, result)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 30 Column: 5

                      result = df.reindex_like(df, method=method, tolerance=[0, 0, 0, 0])
        tm.assert_frame_equal(df, result)

    def test_reindex_like_subclass(self):
        # https://github.com/pandas-dev/pandas/issues/31925
        class MyDataFrame(DataFrame):
            pass

        expected = DataFrame()

            

Reported by Pylint.

pandas/core/array_algos/replace.py
13 issues
Argument name "a" doesn't conform to snake_case naming style
Error

Line: 44 Column: 1

                  return regex


def compare_or_regex_search(
    a: ArrayLike, b: Scalar | Pattern, regex: bool, mask: np.ndarray
) -> ArrayLike | bool:
    """
    Compare two array-like inputs of the same shape or two scalar values


            

Reported by Pylint.

Argument name "b" doesn't conform to snake_case naming style
Error

Line: 44 Column: 1

                  return regex


def compare_or_regex_search(
    a: ArrayLike, b: Scalar | Pattern, regex: bool, mask: np.ndarray
) -> ArrayLike | bool:
    """
    Compare two array-like inputs of the same shape or two scalar values


            

Reported by Pylint.

Argument name "a" doesn't conform to snake_case naming style
Error

Line: 67 Column: 5

                  if isna(b):
        return ~mask

    def _check_comparison_types(
        result: ArrayLike | bool, a: ArrayLike, b: Scalar | Pattern
    ):
        """
        Raises an error if the two arrays (a,b) cannot be compared.
        Otherwise, returns the comparison result as expected.

            

Reported by Pylint.

Argument name "b" doesn't conform to snake_case naming style
Error

Line: 67 Column: 5

                  if isna(b):
        return ~mask

    def _check_comparison_types(
        result: ArrayLike | bool, a: ArrayLike, b: Scalar | Pattern
    ):
        """
        Raises an error if the two arrays (a,b) cannot be compared.
        Otherwise, returns the comparison result as expected.

            

Reported by Pylint.

Variable name "op" doesn't conform to snake_case naming style
Error

Line: 84 Column: 9

                          )

    if not regex:
        op = lambda x: operator.eq(x, b)
    else:
        op = np.vectorize(
            lambda x: bool(re.search(b, x))
            if isinstance(x, str) and isinstance(b, (str, Pattern))
            else False

            

Reported by Pylint.

Variable name "op" doesn't conform to snake_case naming style
Error

Line: 86 Column: 9

                  if not regex:
        op = lambda x: operator.eq(x, b)
    else:
        op = np.vectorize(
            lambda x: bool(re.search(b, x))
            if isinstance(x, str) and isinstance(b, (str, Pattern))
            else False
        )


            

Reported by Pylint.

Unnecessary "elif" after "return"
Error

Line: 96 Column: 5

                  if isinstance(a, np.ndarray):
        a = a[mask]

    if is_numeric_v_string_like(a, b):
        # GH#29553 avoid deprecation warnings from numpy
        return np.zeros(a.shape, dtype=bool)

    elif is_datetimelike_v_numeric(a, b):
        # GH#29553 avoid deprecation warnings from numpy

            

Reported by Pylint.

Argument name "rx" doesn't conform to snake_case naming style
Error

Line: 118 Column: 1

                  return result


def replace_regex(values: ArrayLike, rx: re.Pattern, value, mask: np.ndarray | None):
    """
    Parameters
    ----------
    values : ArrayLike
        Object dtype.

            

Reported by Pylint.

Argument name "s" doesn't conform to snake_case naming style
Error

Line: 137 Column: 9

                  # whose replacement is not a string (numeric, nan, object)
    if isna(value) or not isinstance(value, str):

        def re_replacer(s):
            if is_re(rx) and isinstance(s, str):
                return value if rx.search(s) is not None else s
            else:
                return s


            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 138 Column: 13

                  if isna(value) or not isinstance(value, str):

        def re_replacer(s):
            if is_re(rx) and isinstance(s, str):
                return value if rx.search(s) is not None else s
            else:
                return s

    else:

            

Reported by Pylint.

pandas/tests/indexes/base_class/test_constructors.py
13 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

from pandas import (
    Index,
    MultiIndex,
)
import pandas._testing as tm


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

from pandas import (
    Index,
    MultiIndex,
)
import pandas._testing as tm


            

Reported by Pylint.

Missing class docstring
Error

Line: 11 Column: 1

              import pandas._testing as tm


class TestIndexConstructor:
    # Tests for the Index constructor, specifically for cases that do
    #  not return a subclass

    @pytest.mark.parametrize("value", [1, np.int64(1)])
    def test_constructor_corner(self, value):

            

Reported by Pylint.

Method could be a function
Error

Line: 16 Column: 5

                  #  not return a subclass

    @pytest.mark.parametrize("value", [1, np.int64(1)])
    def test_constructor_corner(self, value):
        # corner case
        msg = (
            r"Index\(\.\.\.\) must be called with a collection of some "
            f"kind, {value} was passed"
        )

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 16 Column: 5

                  #  not return a subclass

    @pytest.mark.parametrize("value", [1, np.int64(1)])
    def test_constructor_corner(self, value):
        # corner case
        msg = (
            r"Index\(\.\.\.\) must be called with a collection of some "
            f"kind, {value} was passed"
        )

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 26 Column: 5

                          Index(value)

    @pytest.mark.parametrize("index_vals", [[("A", 1), "B"], ["B", ("A", 1)]])
    def test_construction_list_mixed_tuples(self, index_vals):
        # see gh-10697: if we are constructing from a mixed list of tuples,
        # make sure that we are independent of the sorting order.
        index = Index(index_vals)
        assert isinstance(index, Index)
        assert not isinstance(index, MultiIndex)

            

Reported by Pylint.

Method could be a function
Error

Line: 26 Column: 5

                          Index(value)

    @pytest.mark.parametrize("index_vals", [[("A", 1), "B"], ["B", ("A", 1)]])
    def test_construction_list_mixed_tuples(self, index_vals):
        # see gh-10697: if we are constructing from a mixed list of tuples,
        # make sure that we are independent of the sorting order.
        index = Index(index_vals)
        assert isinstance(index, Index)
        assert not isinstance(index, MultiIndex)

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 30
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                      # see gh-10697: if we are constructing from a mixed list of tuples,
        # make sure that we are independent of the sorting order.
        index = Index(index_vals)
        assert isinstance(index, Index)
        assert not isinstance(index, MultiIndex)

    def test_constructor_wrong_kwargs(self):
        # GH #19348
        with pytest.raises(TypeError, match="Unexpected keyword arguments {'foo'}"):

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 31
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                      # make sure that we are independent of the sorting order.
        index = Index(index_vals)
        assert isinstance(index, Index)
        assert not isinstance(index, MultiIndex)

    def test_constructor_wrong_kwargs(self):
        # GH #19348
        with pytest.raises(TypeError, match="Unexpected keyword arguments {'foo'}"):
            with tm.assert_produces_warning(FutureWarning):

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 33 Column: 5

                      assert isinstance(index, Index)
        assert not isinstance(index, MultiIndex)

    def test_constructor_wrong_kwargs(self):
        # GH #19348
        with pytest.raises(TypeError, match="Unexpected keyword arguments {'foo'}"):
            with tm.assert_produces_warning(FutureWarning):
                Index([], foo="bar")


            

Reported by Pylint.

pandas/core/array_algos/take.py
13 issues
No name 'lib' in module 'pandas._libs'
Error

Line: 12 Column: 1

              
import numpy as np

from pandas._libs import (
    algos as libalgos,
    lib,
)
from pandas._typing import ArrayLike


            

Reported by Pylint.

No name 'algos' in module 'pandas._libs'
Error

Line: 12 Column: 1

              
import numpy as np

from pandas._libs import (
    algos as libalgos,
    lib,
)
from pandas._typing import ArrayLike


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from __future__ import annotations

import functools
from typing import (
    TYPE_CHECKING,
    cast,
    overload,
)


            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 217
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                  """
    # This is only called from one place in DataFrame._reindex_multi,
    #  so we know indexer is well-behaved.
    assert indexer is not None
    assert indexer[0] is not None
    assert indexer[1] is not None

    row_idx, col_idx = indexer


            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 218
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                  # This is only called from one place in DataFrame._reindex_multi,
    #  so we know indexer is well-behaved.
    assert indexer is not None
    assert indexer[0] is not None
    assert indexer[1] is not None

    row_idx, col_idx = indexer

    row_idx = ensure_platform_int(row_idx)

            

Reported by Bandit.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 219
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                  #  so we know indexer is well-behaved.
    assert indexer is not None
    assert indexer[0] is not None
    assert indexer[1] is not None

    row_idx, col_idx = indexer

    row_idx = ensure_platform_int(row_idx)
    col_idx = ensure_platform_int(col_idx)

            

Reported by Bandit.

Argument name "f" doesn't conform to snake_case naming style
Error

Line: 324 Column: 1

                  return func


def _view_wrapper(f, arr_dtype=None, out_dtype=None, fill_wrap=None):
    def wrapper(
        arr: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=np.nan
    ):
        if arr_dtype is not None:
            arr = arr.view(arr_dtype)

            

Reported by Pylint.

Argument name "f" doesn't conform to snake_case naming style
Error

Line: 339 Column: 1

                  return wrapper


def _convert_wrapper(f, conv_dtype):
    def wrapper(
        arr: np.ndarray, indexer: np.ndarray, out: np.ndarray, fill_value=np.nan
    ):
        if conv_dtype == object:
            # GH#39755 avoid casting dt64/td64 to integers

            

Reported by Pylint.

Too many arguments (6/5)
Error

Line: 465 Column: 1

              }


def _take_nd_object(
    arr: np.ndarray,
    indexer: np.ndarray,  # np.ndarray[np.intp]
    out: np.ndarray,
    axis: int,
    fill_value,

            

Reported by Pylint.

Consider using enumerate instead of iterating with range and len
Error

Line: 510 Column: 5

                          out[row_mask, :] = fill_value
        if col_needs:
            out[:, col_mask] = fill_value
    for i in range(len(row_idx)):
        u_ = row_idx[i]
        for j in range(len(col_idx)):
            v = col_idx[j]
            out[i, j] = arr[u_, v]


            

Reported by Pylint.