The following issues were found

pandas/tests/frame/methods/test_rank.py
78 issues
Unable to import 'pytest'
Error

Line: 7 Column: 1

              )

import numpy as np
import pytest

from pandas._libs.algos import (
    Infinity,
    NegInfinity,
)

            

Reported by Pylint.

Unable to import 'pandas._libs.algos'
Error

Line: 9 Column: 1

              import numpy as np
import pytest

from pandas._libs.algos import (
    Infinity,
    NegInfinity,
)
import pandas.util._test_decorators as td


            

Reported by Pylint.

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

Line: 9 Column: 1

              import numpy as np
import pytest

from pandas._libs.algos import (
    Infinity,
    NegInfinity,
)
import pandas.util._test_decorators as td


            

Reported by Pylint.

Unable to import 'scipy.stats'
Error

Line: 43 Column: 9

              
    @td.skip_if_no_scipy
    def test_rank(self, float_frame):
        import scipy.stats  # noqa:F401
        from scipy.stats import rankdata

        float_frame["A"][::2] = np.nan
        float_frame["B"][::3] = np.nan
        float_frame["C"][::4] = np.nan

            

Reported by Pylint.

Unable to import 'scipy.stats'
Error

Line: 44 Column: 9

                  @td.skip_if_no_scipy
    def test_rank(self, float_frame):
        import scipy.stats  # noqa:F401
        from scipy.stats import rankdata

        float_frame["A"][::2] = np.nan
        float_frame["B"][::3] = np.nan
        float_frame["C"][::4] = np.nan
        float_frame["D"][::5] = np.nan

            

Reported by Pylint.

Unable to import 'scipy.stats'
Error

Line: 145 Column: 9

              
    @td.skip_if_no_scipy
    def test_rank_na_option(self, float_frame):
        import scipy.stats  # noqa:F401
        from scipy.stats import rankdata

        float_frame["A"][::2] = np.nan
        float_frame["B"][::3] = np.nan
        float_frame["C"][::4] = np.nan

            

Reported by Pylint.

Unable to import 'scipy.stats'
Error

Line: 146 Column: 9

                  @td.skip_if_no_scipy
    def test_rank_na_option(self, float_frame):
        import scipy.stats  # noqa:F401
        from scipy.stats import rankdata

        float_frame["A"][::2] = np.nan
        float_frame["B"][::3] = np.nan
        float_frame["C"][::4] = np.nan
        float_frame["D"][::5] = np.nan

            

Reported by Pylint.

Unable to import 'scipy.stats'
Error

Line: 229 Column: 9

              
    @td.skip_if_no_scipy
    def test_rank_methods_frame(self):
        import scipy.stats  # noqa:F401
        from scipy.stats import rankdata

        xs = np.random.randint(0, 21, (100, 26))
        xs = (xs - 10.0) / 10.0
        cols = [chr(ord("z") - i) for i in range(xs.shape[1])]

            

Reported by Pylint.

Unable to import 'scipy.stats'
Error

Line: 230 Column: 9

                  @td.skip_if_no_scipy
    def test_rank_methods_frame(self):
        import scipy.stats  # noqa:F401
        from scipy.stats import rankdata

        xs = np.random.randint(0, 21, (100, 26))
        xs = (xs - 10.0) / 10.0
        cols = [chr(ord("z") - i) for i in range(xs.shape[1])]


            

Reported by Pylint.

Unused import scipy.stats
Error

Line: 43 Column: 9

              
    @td.skip_if_no_scipy
    def test_rank(self, float_frame):
        import scipy.stats  # noqa:F401
        from scipy.stats import rankdata

        float_frame["A"][::2] = np.nan
        float_frame["B"][::3] = np.nan
        float_frame["C"][::4] = np.nan

            

Reported by Pylint.

pandas/tests/io/parser/common/test_common_basic.py
77 issues
Unable to import 'pytest'
Error

Line: 13 Column: 1

              import sys

import numpy as np
import pytest

from pandas.errors import (
    EmptyDataError,
    ParserError,
    ParserWarning,

            

Reported by Pylint.

__init__ method from base class 'TextFileReader' is not called
Error

Line: 40 Column: 9

                  # Usecols needs to be sorted in _set_noconvert_columns based
    # on the test_usecols_with_parse_dates test from test_usecols.py
    class MyTextFileReader(TextFileReader):
        def __init__(self):
            self._currow = 0
            self.squeeze = False

    class MyCParserWrapper(CParserWrapper):
        def _set_noconvert_columns(self):

            

Reported by Pylint.

Access to a protected member _engine of a client class
Error

Line: 75 Column: 5

                      "delimiter": ",",
    }
    parser.engine = "c"
    parser._engine = MyCParserWrapper(StringIO(data), **parser.options)

    result = parser.read()
    tm.assert_frame_equal(result, expected)



            

Reported by Pylint.

Access to a protected member _is_view of a client class
Error

Line: 143 Column: 16

                  # see gh-8217
    #
    # Series should not be a view.
    assert not result._is_view


def test_unnamed_columns(all_parsers):
    data = """A,B,C,,
1,2,3,4,5

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 34 Column: 1

              from pandas.io.parsers.c_parser_wrapper import CParserWrapper


def test_override_set_noconvert_columns():
    # see gh-17351
    #
    # Usecols needs to be sorted in _set_noconvert_columns based
    # on the test_usecols_with_parse_dates test from test_usecols.py
    class MyTextFileReader(TextFileReader):

            

Reported by Pylint.

Missing class docstring
Error

Line: 39 Column: 5

                  #
    # Usecols needs to be sorted in _set_noconvert_columns based
    # on the test_usecols_with_parse_dates test from test_usecols.py
    class MyTextFileReader(TextFileReader):
        def __init__(self):
            self._currow = 0
            self.squeeze = False

    class MyCParserWrapper(CParserWrapper):

            

Reported by Pylint.

Missing class docstring
Error

Line: 44 Column: 5

                          self._currow = 0
            self.squeeze = False

    class MyCParserWrapper(CParserWrapper):
        def _set_noconvert_columns(self):
            if self.usecols_dtype == "integer":
                # self.usecols is a set, which is documented as unordered
                # but in practice, a CPython set of integers is sorted.
                # In other implementations this assumption does not hold.

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 81 Column: 1

                  tm.assert_frame_equal(result, expected)


def test_read_csv_local(all_parsers, csv1):
    prefix = "file:///" if compat.is_platform_windows() else "file://"
    parser = all_parsers

    fname = prefix + str(os.path.abspath(csv1))
    result = parser.read_csv(fname, index_col=0, parse_dates=True)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 115 Column: 1

                  tm.assert_frame_equal(result, expected)


def test_1000_sep(all_parsers):
    parser = all_parsers
    data = """A|B|C
1|2,334|5
10|13|10.
"""

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 127 Column: 1

                  tm.assert_frame_equal(result, expected)


def test_squeeze(all_parsers):
    data = """\
a,1
b,2
c,3
"""

            

Reported by Pylint.

pandas/core/indexes/interval.py
77 issues
No name 'lib' in module 'pandas._libs'
Error

Line: 16 Column: 1

              
import numpy as np

from pandas._libs import lib
from pandas._libs.interval import (
    Interval,
    IntervalMixin,
    IntervalTree,
)

            

Reported by Pylint.

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

Line: 17 Column: 1

              import numpy as np

from pandas._libs import lib
from pandas._libs.interval import (
    Interval,
    IntervalMixin,
    IntervalTree,
)
from pandas._libs.tslibs import (

            

Reported by Pylint.

Unable to import 'pandas._libs.interval'
Error

Line: 17 Column: 1

              import numpy as np

from pandas._libs import lib
from pandas._libs.interval import (
    Interval,
    IntervalMixin,
    IntervalTree,
)
from pandas._libs.tslibs import (

            

Reported by Pylint.

Method 'right' has no 'memory_usage' member
Error

Line: 371 Column: 52

                  def memory_usage(self, deep: bool = False) -> int:
        # we don't use an explicit engine
        # so return the bytes here
        return self.left.memory_usage(deep=deep) + self.right.memory_usage(deep=deep)

    # IntervalTree doesn't have a is_monotonic_decreasing, so have to override
    #  the Index implementation
    @cache_readonly
    def is_monotonic_decreasing(self) -> bool:

            

Reported by Pylint.

Method 'left' has no 'memory_usage' member
Error

Line: 371 Column: 16

                  def memory_usage(self, deep: bool = False) -> int:
        # we don't use an explicit engine
        # so return the bytes here
        return self.left.memory_usage(deep=deep) + self.right.memory_usage(deep=deep)

    # IntervalTree doesn't have a is_monotonic_decreasing, so have to override
    #  the Index implementation
    @cache_readonly
    def is_monotonic_decreasing(self) -> bool:

            

Reported by Pylint.

Method 'right' has no 'is_unique' member
Error

Line: 394 Column: 30

                      if self.isna().sum() > 1:
            return False

        if left.is_unique or right.is_unique:
            return True

        seen_pairs = set()
        check_idx = np.where(left.duplicated(keep=False))[0]
        for idx in check_idx:

            

Reported by Pylint.

Method 'left' has no 'is_unique' member
Error

Line: 394 Column: 12

                      if self.isna().sum() > 1:
            return False

        if left.is_unique or right.is_unique:
            return True

        seen_pairs = set()
        check_idx = np.where(left.duplicated(keep=False))[0]
        for idx in check_idx:

            

Reported by Pylint.

Method 'left' has no 'duplicated' member
Error

Line: 398 Column: 30

                          return True

        seen_pairs = set()
        check_idx = np.where(left.duplicated(keep=False))[0]
        for idx in check_idx:
            pair = (left[idx], right[idx])
            if pair in seen_pairs:
                return False
            seen_pairs.add(pair)

            

Reported by Pylint.

Method '_engine' has no 'is_overlapping' member
Error

Line: 455 Column: 16

                      False
        """
        # GH 23309
        return self._engine.is_overlapping

    def _needs_i8_conversion(self, key) -> bool:
        """
        Check if a given key needs i8 conversion. Conversion is necessary for
        Timestamp, Timedelta, DatetimeIndex, and TimedeltaIndex keys. An

            

Reported by Pylint.

bad operand type for unary ~: _isnan
Error

Line: 528 Column: 39

                          if key.hasnans:
                # convert NaT from its i8 value to np.nan so it's not viewed
                # as a valid value, maybe causing errors (e.g. is_overlapping)
                key_i8 = key_i8.where(~key._isnan)

        # ensure consistency with IntervalIndex subtype
        subtype = self.dtype.subtype

        if not is_dtype_equal(subtype, key_dtype):

            

Reported by Pylint.

asv_bench/benchmarks/stat_ops.py
77 issues
Unable to import 'pandas'
Error

Line: 3 Column: 1

              import numpy as np

import pandas as pd

ops = ["mean", "sum", "median", "std", "skew", "kurt", "mad", "prod", "sem", "var"]


class FrameOps:


            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 144 Column: 1

                      self.s.cov(self.s2)


from .pandas_vb_common import setup  # noqa: F401 isort:skip

            

Reported by Pylint.

Unused argument 'axis'
Error

Line: 13 Column: 32

                  params = [ops, ["float", "int", "Int64"], [0, 1]]
    param_names = ["op", "dtype", "axis"]

    def setup(self, op, dtype, axis):
        if op == "mad" and dtype == "Int64":
            # GH-33036, GH#33600
            raise NotImplementedError
        values = np.random.randn(100000, 4)
        if dtype == "Int64":

            

Reported by Pylint.

Attribute 'df_func' defined outside __init__
Error

Line: 21 Column: 9

                      if dtype == "Int64":
            values = values.astype(int)
        df = pd.DataFrame(values).astype(dtype)
        self.df_func = getattr(df, op)

    def time_op(self, op, dtype, axis):
        self.df_func(axis=axis)



            

Reported by Pylint.

Unused argument 'op'
Error

Line: 23 Column: 23

                      df = pd.DataFrame(values).astype(dtype)
        self.df_func = getattr(df, op)

    def time_op(self, op, dtype, axis):
        self.df_func(axis=axis)


class FrameMultiIndexOps:


            

Reported by Pylint.

Unused argument 'dtype'
Error

Line: 23 Column: 27

                      df = pd.DataFrame(values).astype(dtype)
        self.df_func = getattr(df, op)

    def time_op(self, op, dtype, axis):
        self.df_func(axis=axis)


class FrameMultiIndexOps:


            

Reported by Pylint.

Unused argument 'level'
Error

Line: 32 Column: 21

                  params = ([0, 1, [0, 1]], ops)
    param_names = ["level", "op"]

    def setup(self, level, op):
        levels = [np.arange(10), np.arange(100), np.arange(100)]
        codes = [
            np.arange(10).repeat(10000),
            np.tile(np.arange(100).repeat(100), 10),
            np.tile(np.tile(np.arange(100), 100), 10),

            

Reported by Pylint.

Attribute 'df_func' defined outside __init__
Error

Line: 41 Column: 9

                      ]
        index = pd.MultiIndex(levels=levels, codes=codes)
        df = pd.DataFrame(np.random.randn(len(index), 4), index=index)
        self.df_func = getattr(df, op)

    def time_op(self, level, op):
        self.df_func(level=level)



            

Reported by Pylint.

Unused argument 'op'
Error

Line: 43 Column: 30

                      df = pd.DataFrame(np.random.randn(len(index), 4), index=index)
        self.df_func = getattr(df, op)

    def time_op(self, level, op):
        self.df_func(level=level)


class SeriesOps:


            

Reported by Pylint.

Attribute 's_func' defined outside __init__
Error

Line: 54 Column: 9

              
    def setup(self, op, dtype):
        s = pd.Series(np.random.randn(100000)).astype(dtype)
        self.s_func = getattr(s, op)

    def time_op(self, op, dtype):
        self.s_func()



            

Reported by Pylint.

pandas/tests/indexes/test_indexing.py
77 issues
Unable to import 'pytest'
Error

Line: 18 Column: 1

              contain tests for the corresponding methods specific to those Index subclasses.
"""
import numpy as np
import pytest

from pandas.errors import InvalidIndexError

from pandas import (
    DatetimeIndex,

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 69 Column: 17

                          # GH 10791
            msg = r"'(.*Index)' object has no attribute 'freq'"
            with pytest.raises(AttributeError, match=msg):
                index.freq

    def test_take_minus1_without_fill(self, index):
        # -1 does not get treated as NA unless allow_fill=True is passed
        if len(index) == 0:
            # Test is not applicable

            

Reported by Pylint.

TODO: do we want this to raise?
Error

Line: 149 Column: 3

              
    def test_contains_requires_hashable_raises(self, index):
        if isinstance(index, MultiIndex):
            return  # TODO: do we want this to raise?

        msg = "unhashable type: 'list'"
        with pytest.raises(TypeError, match=msg):
            [] in index


            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 153 Column: 13

              
        msg = "unhashable type: 'list'"
        with pytest.raises(TypeError, match=msg):
            [] in index

        msg = "|".join(
            [
                r"unhashable type: 'dict'",
                r"must be real number, not dict",

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 165 Column: 13

                          ]
        )
        with pytest.raises(TypeError, match=msg):
            {} in index._engine


class TestGetValue:
    @pytest.mark.parametrize(
        "index", ["string", "int", "datetime", "timedelta"], indirect=True

            

Reported by Pylint.

Access to a protected member _engine of a client class
Error

Line: 165 Column: 19

                          ]
        )
        with pytest.raises(TypeError, match=msg):
            {} in index._engine


class TestGetValue:
    @pytest.mark.parametrize(
        "index", ["string", "int", "datetime", "timedelta"], indirect=True

            

Reported by Pylint.

TODO: Remove function? GH#19728
Error

Line: 173 Column: 3

                      "index", ["string", "int", "datetime", "timedelta"], indirect=True
    )
    def test_get_value(self, index):
        # TODO: Remove function? GH#19728
        values = np.random.randn(100)
        value = index[67]

        with pytest.raises(AttributeError, match="has no attribute '_values'"):
            # Index.get_value requires a Series, not an ndarray

            

Reported by Pylint.

TODO: make these more consistent?
Error

Line: 201 Column: 3

                          index,
            (DatetimeIndex, TimedeltaIndex, PeriodIndex, RangeIndex, IntervalIndex),
        ):
            # TODO: make these more consistent?
            exc = InvalidIndexError
        with pytest.raises(exc, match="generator object"):
            # MultiIndex specifically checks for generator; others for scalar
            index.get_loc(x for x in range(5))


            

Reported by Pylint.

Access to a protected member _index_as_unique of a client class
Error

Line: 211 Column: 12

              class TestGetIndexer:
    def test_get_indexer_base(self, index):

        if index._index_as_unique:
            expected = np.arange(index.size, dtype=np.intp)
            actual = index.get_indexer(index)
            tm.assert_numpy_array_equal(expected, actual)
        else:
            msg = "Reindexing only valid with uniquely valued Index objects"

            

Reported by Pylint.

Access to a protected member _index_as_unique of a client class
Error

Line: 226 Column: 12

                  def test_get_indexer_consistency(self, index):
        # See GH#16819

        if index._index_as_unique:
            indexer = index.get_indexer(index[0:2])
            assert isinstance(indexer, np.ndarray)
            assert indexer.dtype == np.intp
        else:
            msg = "Reindexing only valid with uniquely valued Index objects"

            

Reported by Pylint.

pandas/core/groupby/ops.py
77 issues
No name 'lib' in module 'pandas._libs'
Error

Line: 23 Column: 1

              
import numpy as np

from pandas._libs import (
    NaT,
    lib,
)
import pandas._libs.groupby as libgroupby
import pandas._libs.reduction as libreduction

            

Reported by Pylint.

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

Line: 27 Column: 1

                  NaT,
    lib,
)
import pandas._libs.groupby as libgroupby
import pandas._libs.reduction as libreduction
from pandas._typing import (
    ArrayLike,
    DtypeObj,
    F,

            

Reported by Pylint.

Unable to import 'pandas._libs.groupby'
Error

Line: 27 Column: 1

                  NaT,
    lib,
)
import pandas._libs.groupby as libgroupby
import pandas._libs.reduction as libreduction
from pandas._typing import (
    ArrayLike,
    DtypeObj,
    F,

            

Reported by Pylint.

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

Line: 28 Column: 1

                  lib,
)
import pandas._libs.groupby as libgroupby
import pandas._libs.reduction as libreduction
from pandas._typing import (
    ArrayLike,
    DtypeObj,
    F,
    FrameOrSeries,

            

Reported by Pylint.

Unable to import 'pandas._libs.reduction'
Error

Line: 28 Column: 1

                  lib,
)
import pandas._libs.groupby as libgroupby
import pandas._libs.reduction as libreduction
from pandas._typing import (
    ArrayLike,
    DtypeObj,
    F,
    FrameOrSeries,

            

Reported by Pylint.

Module 'numpy.typing' has no 'NDArray' member
Error

Line: 637 Column: 18

                      sort: bool = True,
        group_keys: bool = True,
        mutated: bool = False,
        indexer: npt.NDArray[np.intp] | None = None,
        dropna: bool = True,
    ):
        assert isinstance(axis, Index), axis

        self.axis = axis

            

Reported by Pylint.

Method 'result_index' has no '_values' member
Error

Line: 835 Column: 16

                          return self.groupings[0].group_arraylike

        # result_index is MultiIndex
        return self.result_index._values

    @cache_readonly
    def result_index(self) -> Index:
        if len(self.groupings) == 1:
            return self.groupings[0].result_index.rename(self.names[0])

            

Reported by Pylint.

Module 'numpy.typing' has no 'NDArray' member
Error

Line: 1182 Column: 17

                  def __init__(
        self,
        data: FrameOrSeries,
        labels: npt.NDArray[np.intp],
        ngroups: int,
        axis: int = 0,
    ):
        self.data = data
        self.labels = ensure_platform_int(labels)  # _should_ already be np.intp

            

Reported by Pylint.

TODO: general case implementation overridable by EAs.
Error

Line: 332 Column: 3

                      If we have an ExtensionArray, unwrap, call _cython_operation, and
        re-wrap if appropriate.
        """
        # TODO: general case implementation overridable by EAs.
        if isinstance(values, BaseMaskedArray) and self.uses_mask():
            return self._masked_ea_wrap_cython_operation(
                values,
                min_count=min_count,
                ngroups=ngroups,

            

Reported by Pylint.

Access to a protected member _ndarray of a client class
Error

Line: 345 Column: 24

                      if isinstance(values, (DatetimeArray, PeriodArray, TimedeltaArray)):
            # All of the functions implemented here are ordinal, so we can
            #  operate on the tz-naive equivalents
            npvalues = values._ndarray.view("M8[ns]")
        elif isinstance(values.dtype, (BooleanDtype, _IntegerDtype)):
            # IntegerArray or BooleanArray
            npvalues = values.to_numpy("float64", na_value=np.nan)
        elif isinstance(values.dtype, FloatingDtype):
            # FloatingArray

            

Reported by Pylint.

asv_bench/benchmarks/reindex.py
77 issues
Unable to import 'pandas'
Error

Line: 3 Column: 1

              import numpy as np

from pandas import (
    DataFrame,
    Index,
    MultiIndex,
    Series,
    date_range,
    period_range,

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 12 Column: 1

                  period_range,
)

from .pandas_vb_common import tm


class Reindex:
    def setup(self):
        rng = date_range(start="1/1/1970", periods=10000, freq="1min")

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 155 Column: 1

                      self.x + self.y


from .pandas_vb_common import setup  # noqa: F401 isort:skip

            

Reported by Pylint.

Attribute 'df' defined outside __init__
Error

Line: 18 Column: 9

              class Reindex:
    def setup(self):
        rng = date_range(start="1/1/1970", periods=10000, freq="1min")
        self.df = DataFrame(np.random.rand(10000, 10), index=rng, columns=range(10))
        self.df["foo"] = "bar"
        self.rng_subset = Index(rng[::2])
        self.df2 = DataFrame(
            index=range(10000), data=np.random.rand(10000, 30), columns=range(30)
        )

            

Reported by Pylint.

Attribute 'rng_subset' defined outside __init__
Error

Line: 20 Column: 9

                      rng = date_range(start="1/1/1970", periods=10000, freq="1min")
        self.df = DataFrame(np.random.rand(10000, 10), index=rng, columns=range(10))
        self.df["foo"] = "bar"
        self.rng_subset = Index(rng[::2])
        self.df2 = DataFrame(
            index=range(10000), data=np.random.rand(10000, 30), columns=range(30)
        )
        N = 5000
        K = 200

            

Reported by Pylint.

Attribute 'df2' defined outside __init__
Error

Line: 21 Column: 9

                      self.df = DataFrame(np.random.rand(10000, 10), index=rng, columns=range(10))
        self.df["foo"] = "bar"
        self.rng_subset = Index(rng[::2])
        self.df2 = DataFrame(
            index=range(10000), data=np.random.rand(10000, 30), columns=range(30)
        )
        N = 5000
        K = 200
        level1 = tm.makeStringIndex(N).values.repeat(K)

            

Reported by Pylint.

Attribute 's' defined outside __init__
Error

Line: 29 Column: 9

                      level1 = tm.makeStringIndex(N).values.repeat(K)
        level2 = np.tile(tm.makeStringIndex(K).values, N)
        index = MultiIndex.from_arrays([level1, level2])
        self.s = Series(np.random.randn(N * K), index=index)
        self.s_subset = self.s[::2]

    def time_reindex_dates(self):
        self.df.reindex(self.rng_subset)


            

Reported by Pylint.

Attribute 's_subset' defined outside __init__
Error

Line: 30 Column: 9

                      level2 = np.tile(tm.makeStringIndex(K).values, N)
        index = MultiIndex.from_arrays([level1, level2])
        self.s = Series(np.random.randn(N * K), index=index)
        self.s_subset = self.s[::2]

    def time_reindex_dates(self):
        self.df.reindex(self.rng_subset)

    def time_reindex_columns(self):

            

Reported by Pylint.

Unused argument 'method'
Error

Line: 47 Column: 21

                  params = [["pad", "backfill"], [date_range, period_range]]
    param_names = ["method", "constructor"]

    def setup(self, method, constructor):
        N = 100000
        self.idx = constructor("1/1/2000", periods=N, freq="1min")
        self.ts = Series(np.random.randn(N), index=self.idx)[::2]

    def time_reindex_method(self, method, constructor):

            

Reported by Pylint.

Attribute 'idx' defined outside __init__
Error

Line: 49 Column: 9

              
    def setup(self, method, constructor):
        N = 100000
        self.idx = constructor("1/1/2000", periods=N, freq="1min")
        self.ts = Series(np.random.randn(N), index=self.idx)[::2]

    def time_reindex_method(self, method, constructor):
        self.ts.reindex(self.idx, method=method)


            

Reported by Pylint.

pandas/plotting/_matplotlib/misc.py
77 issues
Unable to import 'scipy.stats'
Error

Line: 84 Column: 21

                                  ax.hist(values, **hist_kwds)

                elif diagonal in ("kde", "density"):
                    from scipy.stats import gaussian_kde

                    y = values
                    gkde = gaussian_kde(y)
                    ind = np.linspace(y.min(), y.max(), 1000)
                    ax.plot(ind, gkde.evaluate(ind), **density_kwds)

            

Reported by Pylint.

Unused argument 'grid'
Error

Line: 39 Column: 5

                  alpha=0.5,
    figsize=None,
    ax=None,
    grid=False,
    diagonal="hist",
    marker=".",
    density_kwds=None,
    hist_kwds=None,
    range_padding=0.05,

            

Reported by Pylint.

Access to a protected member _get_numeric_data of a client class
Error

Line: 47 Column: 10

                  range_padding=0.05,
    **kwds,
):
    df = frame._get_numeric_data()
    n = df.columns.size
    naxes = n * n
    fig, axes = create_subplots(naxes=naxes, figsize=figsize, ax=ax, squeeze=False)

    # no gaps between subplots

            

Reported by Pylint.

TODO: is the failure mentioned below still relevant?
Error

Line: 302 Column: 3

              
    import matplotlib.pyplot as plt

    # TODO: is the failure mentioned below still relevant?
    # random.sample(ndarray, int) fails on python 3.3, sigh
    data = list(series.values)
    samplings = [random.sample(data, size) for _ in range(samples)]

    means = np.array([np.mean(sampling) for sampling in samplings])

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from __future__ import annotations

import random
from typing import (
    TYPE_CHECKING,
    Hashable,
)

import matplotlib.lines as mlines

            

Reported by Pylint.

Imports from package pandas are not grouped
Error

Line: 28 Column: 5

                  from matplotlib.axes import Axes
    from matplotlib.figure import Figure

    from pandas import (
        DataFrame,
        Series,
    )



            

Reported by Pylint.

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

Line: 34 Column: 1

                  )


def scatter_matrix(
    frame: DataFrame,
    alpha=0.5,
    figsize=None,
    ax=None,
    grid=False,

            

Reported by Pylint.

Too many statements (51/50)
Error

Line: 34 Column: 1

                  )


def scatter_matrix(
    frame: DataFrame,
    alpha=0.5,
    figsize=None,
    ax=None,
    grid=False,

            

Reported by Pylint.

Too many local variables (35/15)
Error

Line: 34 Column: 1

                  )


def scatter_matrix(
    frame: DataFrame,
    alpha=0.5,
    figsize=None,
    ax=None,
    grid=False,

            

Reported by Pylint.

Too many arguments (10/5)
Error

Line: 34 Column: 1

                  )


def scatter_matrix(
    frame: DataFrame,
    alpha=0.5,
    figsize=None,
    ax=None,
    grid=False,

            

Reported by Pylint.

pandas/tests/plotting/frame/test_hist_box_by.py
77 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              import re

import numpy as np
import pytest

import pandas.util._test_decorators as td

from pandas import DataFrame
import pandas._testing as tm

            

Reported by Pylint.

Attribute 'hist_df' defined outside __init__
Error

Line: 31 Column: 9

                      import matplotlib as mpl

        mpl.rcdefaults()
        self.hist_df = _create_hist_box_with_by_df()

    @pytest.mark.parametrize(
        "by, column, titles, legends",
        [
            ("C", "A", ["a", "b", "c"], [["A"]] * 3),

            

Reported by Pylint.

Access to a protected member _shared_x_axes of a client class
Error

Line: 198 Column: 16

                      ax1, ax2, ax3 = self.hist_df.plot.hist(column="A", by="C", sharex=True)

        # share x
        assert ax1._shared_x_axes.joined(ax1, ax2)
        assert ax2._shared_x_axes.joined(ax1, ax2)
        assert ax3._shared_x_axes.joined(ax1, ax3)
        assert ax3._shared_x_axes.joined(ax2, ax3)

        # don't share y

            

Reported by Pylint.

Access to a protected member _shared_x_axes of a client class
Error

Line: 199 Column: 16

              
        # share x
        assert ax1._shared_x_axes.joined(ax1, ax2)
        assert ax2._shared_x_axes.joined(ax1, ax2)
        assert ax3._shared_x_axes.joined(ax1, ax3)
        assert ax3._shared_x_axes.joined(ax2, ax3)

        # don't share y
        assert not ax1._shared_y_axes.joined(ax1, ax2)

            

Reported by Pylint.

Access to a protected member _shared_x_axes of a client class
Error

Line: 200 Column: 16

                      # share x
        assert ax1._shared_x_axes.joined(ax1, ax2)
        assert ax2._shared_x_axes.joined(ax1, ax2)
        assert ax3._shared_x_axes.joined(ax1, ax3)
        assert ax3._shared_x_axes.joined(ax2, ax3)

        # don't share y
        assert not ax1._shared_y_axes.joined(ax1, ax2)
        assert not ax2._shared_y_axes.joined(ax1, ax2)

            

Reported by Pylint.

Access to a protected member _shared_x_axes of a client class
Error

Line: 201 Column: 16

                      assert ax1._shared_x_axes.joined(ax1, ax2)
        assert ax2._shared_x_axes.joined(ax1, ax2)
        assert ax3._shared_x_axes.joined(ax1, ax3)
        assert ax3._shared_x_axes.joined(ax2, ax3)

        # don't share y
        assert not ax1._shared_y_axes.joined(ax1, ax2)
        assert not ax2._shared_y_axes.joined(ax1, ax2)
        assert not ax3._shared_y_axes.joined(ax1, ax3)

            

Reported by Pylint.

Access to a protected member _shared_y_axes of a client class
Error

Line: 204 Column: 20

                      assert ax3._shared_x_axes.joined(ax2, ax3)

        # don't share y
        assert not ax1._shared_y_axes.joined(ax1, ax2)
        assert not ax2._shared_y_axes.joined(ax1, ax2)
        assert not ax3._shared_y_axes.joined(ax1, ax3)
        assert not ax3._shared_y_axes.joined(ax2, ax3)

    @pytest.mark.slow

            

Reported by Pylint.

Access to a protected member _shared_y_axes of a client class
Error

Line: 205 Column: 20

              
        # don't share y
        assert not ax1._shared_y_axes.joined(ax1, ax2)
        assert not ax2._shared_y_axes.joined(ax1, ax2)
        assert not ax3._shared_y_axes.joined(ax1, ax3)
        assert not ax3._shared_y_axes.joined(ax2, ax3)

    @pytest.mark.slow
    def test_axis_share_y_with_by(self):

            

Reported by Pylint.

Access to a protected member _shared_y_axes of a client class
Error

Line: 206 Column: 20

                      # don't share y
        assert not ax1._shared_y_axes.joined(ax1, ax2)
        assert not ax2._shared_y_axes.joined(ax1, ax2)
        assert not ax3._shared_y_axes.joined(ax1, ax3)
        assert not ax3._shared_y_axes.joined(ax2, ax3)

    @pytest.mark.slow
    def test_axis_share_y_with_by(self):
        # GH 15079

            

Reported by Pylint.

Access to a protected member _shared_y_axes of a client class
Error

Line: 207 Column: 20

                      assert not ax1._shared_y_axes.joined(ax1, ax2)
        assert not ax2._shared_y_axes.joined(ax1, ax2)
        assert not ax3._shared_y_axes.joined(ax1, ax3)
        assert not ax3._shared_y_axes.joined(ax2, ax3)

    @pytest.mark.slow
    def test_axis_share_y_with_by(self):
        # GH 15079
        ax1, ax2, ax3 = self.hist_df.plot.hist(column="A", by="C", sharey=True)

            

Reported by Pylint.

pandas/io/formats/style.py
77 issues
By default, jinja2 sets autoescape to False. Consider using autoescape=True or use the select_autoescape function to mitigate XSS vulnerabilities.
Security XSS

Line: 2960
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b701_jinja2_autoescape_false.html

                      # error: Variable "cls" is not valid as a type
        # error: Invalid base class "cls"
        class MyStyler(cls):  # type:ignore[valid-type,misc]
            env = jinja2.Environment(loader=loader)
            if html_table:
                template_html_table = env.get_template(html_table)
            if html_style:
                template_html_style = env.get_template(html_style)


            

Reported by Bandit.

Access to a protected member _shared_docs of a client class
Error

Line: 384 Column: 25

                  @doc(
        NDFrame.to_excel,
        klass="Styler",
        storage_options=generic._shared_docs["storage_options"],
    )
    def to_excel(
        self,
        excel_writer,
        sheet_name: str = "Sheet1",

            

Reported by Pylint.

Unused argument 'encoding'
Error

Line: 400 Column: 9

                      startcol: int = 0,
        engine: str | None = None,
        merge_cells: bool = True,
        encoding: str | None = None,
        inf_rep: str = "inf",
        verbose: bool = True,
        freeze_panes: tuple[int, int] | None = None,
    ) -> None:


            

Reported by Pylint.

Unused argument 'verbose'
Error

Line: 402 Column: 9

                      merge_cells: bool = True,
        encoding: str | None = None,
        inf_rep: str = "inf",
        verbose: bool = True,
        freeze_panes: tuple[int, int] | None = None,
    ) -> None:

        from pandas.io.formats.excel import ExcelFormatter


            

Reported by Pylint.

Access to a protected member _get_numeric_data of a client class
Error

Line: 761 Column: 28

                          # create a default: set float, complex, int cols to 'r' ('S'), index to 'l'
            _original_columns = self.data.columns
            self.data.columns = RangeIndex(stop=len(self.data.columns))
            numeric_cols = self.data._get_numeric_data().columns.to_list()
            self.data.columns = _original_columns
            column_format = ""
            for level in range(self.index.nlevels):
                column_format += "" if self.hide_index_[level] else "l"
            for ci, _ in enumerate(self.data.columns):

            

Reported by Pylint.

Access to a protected member _render_latex of a client class
Error

Line: 822 Column: 17

                      if sparse_columns is None:
            sparse_columns = get_option("styler.sparse.columns")

        latex = obj._render_latex(
            sparse_index=sparse_index,
            sparse_columns=sparse_columns,
            multirow_align=multirow_align,
            multicol_align=multicol_align,
            environment=environment,

            

Reported by Pylint.

Access to a protected member _render_html of a client class
Error

Line: 917 Column: 16

                          sparse_columns = get_option("styler.sparse.columns")

        # Build HTML string..
        html = obj._render_html(
            sparse_index=sparse_index,
            sparse_columns=sparse_columns,
            exclude_styles=exclude_styles,
            encoding=encoding if encoding else "utf-8",
            doctype_html=doctype_html,

            

Reported by Pylint.

Access to a protected member _get_axis_number of a client class
Error

Line: 1299 Column: 16

                      method: str = "apply",
        **kwargs,
    ) -> Styler:
        axis = self.data._get_axis_number(axis)
        obj = self.index if axis == 0 else self.columns

        levels_ = _refactor_levels(level, obj)
        data = DataFrame(obj.to_list()).loc[:, levels_]


            

Reported by Pylint.

Access to a protected member _get_axis_number of a client class
Error

Line: 1749 Column: 16

              
        may produce strange behaviour due to CSS controls with missing elements.
        """
        axis = self.data._get_axis_number(axis)
        obj = self.data.index if axis == 0 else self.data.columns
        pixel_size = (75 if axis == 0 else 25) if not pixel_size else pixel_size

        props = "position:sticky; background-color:white;"
        if not isinstance(obj, pd.MultiIndex):

            

Reported by Pylint.

Using possibly undefined loop variable 'i'
Error

Line: 1816 Column: 41

                                          "selector": f"thead tr:nth-child({obj.nlevels+1}) th",
                            "props": props
                            + (
                                f"top:{(i+1) * pixel_size}px; height:{pixel_size}px; "
                                "z-index:2;"
                            ),
                        }
                    )


            

Reported by Pylint.