The following issues were found

pandas/tests/indexes/datetimes/test_pickle.py
20 issues
Unable to import 'pytest'
Error

Line: 1 Column: 1

              import pytest

from pandas import (
    NaT,
    date_range,
    to_datetime,
)
import pandas._testing as tm


            

Reported by Pylint.

Instance of 'ExtensionIndex' has no '_with_freq' member
Error

Line: 29 Column: 15

              
    def test_pickle_after_set_freq(self):
        dti = date_range("20130101", periods=3, tz="US/Eastern", name="foo")
        dti = dti._with_freq(None)

        res = tm.round_trip_pickle(dti)
        tm.assert_index_equal(res, dti)

    def test_roundtrip_pickle_with_tz(self):

            

Reported by Pylint.

Instance of 'Index' has no '_with_freq' member
Error

Line: 29 Column: 15

              
    def test_pickle_after_set_freq(self):
        dti = date_range("20130101", periods=3, tz="US/Eastern", name="foo")
        dti = dti._with_freq(None)

        res = tm.round_trip_pickle(dti)
        tm.assert_index_equal(res, dti)

    def test_roundtrip_pickle_with_tz(self):

            

Reported by Pylint.

Access to a protected member _with_freq of a client class
Error

Line: 29 Column: 15

              
    def test_pickle_after_set_freq(self):
        dti = date_range("20130101", periods=3, tz="US/Eastern", name="foo")
        dti = dti._with_freq(None)

        res = tm.round_trip_pickle(dti)
        tm.assert_index_equal(res, dti)

    def test_roundtrip_pickle_with_tz(self):

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import pytest

from pandas import (
    NaT,
    date_range,
    to_datetime,
)
import pandas._testing as tm


            

Reported by Pylint.

Missing class docstring
Error

Line: 11 Column: 1

              import pandas._testing as tm


class TestPickle:
    def test_pickle(self):
        # GH#4606
        idx = to_datetime(["2013-01-01", NaT, "2014-01-06"])
        idx_p = tm.round_trip_pickle(idx)
        assert idx_p[0] == idx[0]

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 12 Column: 5

              

class TestPickle:
    def test_pickle(self):
        # GH#4606
        idx = to_datetime(["2013-01-01", NaT, "2014-01-06"])
        idx_p = tm.round_trip_pickle(idx)
        assert idx_p[0] == idx[0]
        assert idx_p[1] is NaT

            

Reported by Pylint.

Method could be a function
Error

Line: 12 Column: 5

              

class TestPickle:
    def test_pickle(self):
        # GH#4606
        idx = to_datetime(["2013-01-01", NaT, "2014-01-06"])
        idx_p = tm.round_trip_pickle(idx)
        assert idx_p[0] == idx[0]
        assert idx_p[1] is NaT

            

Reported by Pylint.

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

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

                      # GH#4606
        idx = to_datetime(["2013-01-01", NaT, "2014-01-06"])
        idx_p = tm.round_trip_pickle(idx)
        assert idx_p[0] == idx[0]
        assert idx_p[1] is NaT
        assert idx_p[2] == idx[2]

    def test_pickle_dont_infer_freq(self):
        # GH##11002

            

Reported by Bandit.

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

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

                      idx = to_datetime(["2013-01-01", NaT, "2014-01-06"])
        idx_p = tm.round_trip_pickle(idx)
        assert idx_p[0] == idx[0]
        assert idx_p[1] is NaT
        assert idx_p[2] == idx[2]

    def test_pickle_dont_infer_freq(self):
        # GH##11002
        # don't infer freq

            

Reported by Bandit.

pandas/tests/arrays/boolean/test_reduction.py
20 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

import pandas as pd


@pytest.fixture
def data():
    return pd.array(

            

Reported by Pylint.

Redefining name 'data' from outer scope (line 8)
Error

Line: 46 Column: 42

              

@pytest.mark.parametrize("dropna", [True, False])
def test_reductions_return_types(dropna, data, all_numeric_reductions):
    op = all_numeric_reductions
    s = pd.Series(data)
    if dropna:
        s = s.dropna()


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

import pandas as pd


@pytest.fixture
def data():
    return pd.array(

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 8 Column: 1

              

@pytest.fixture
def data():
    return pd.array(
        [True, False] * 4 + [np.nan] + [True, False] * 44 + [np.nan] + [True, False],
        dtype="boolean",
    )


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 25 Column: 1

                      # GH-33253: all True / all False values buggy with skipna=False
        ([True, True], True, True, True, True),
        ([False, False], False, False, False, False),
    ],
)
def test_any_all(values, exp_any, exp_all, exp_any_noskip, exp_all_noskip):
    # the methods return numpy scalars
    exp_any = pd.NA if exp_any is pd.NA else np.bool_(exp_any)
    exp_all = pd.NA if exp_all is pd.NA else np.bool_(exp_all)

            

Reported by Pylint.

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

Line: 35 Column: 9

                  exp_all_noskip = pd.NA if exp_all_noskip is pd.NA else np.bool_(exp_all_noskip)

    for con in [pd.array, pd.Series]:
        a = con(values, dtype="boolean")
        assert a.any() is exp_any
        assert a.all() is exp_all
        assert a.any(skipna=False) is exp_any_noskip
        assert a.all(skipna=False) is exp_all_noskip


            

Reported by Pylint.

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

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

              
    for con in [pd.array, pd.Series]:
        a = con(values, dtype="boolean")
        assert a.any() is exp_any
        assert a.all() is exp_all
        assert a.any(skipna=False) is exp_any_noskip
        assert a.all(skipna=False) is exp_all_noskip

        assert np.any(a.any()) is exp_any

            

Reported by Bandit.

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

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

                  for con in [pd.array, pd.Series]:
        a = con(values, dtype="boolean")
        assert a.any() is exp_any
        assert a.all() is exp_all
        assert a.any(skipna=False) is exp_any_noskip
        assert a.all(skipna=False) is exp_all_noskip

        assert np.any(a.any()) is exp_any
        assert np.all(a.all()) is exp_all

            

Reported by Bandit.

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

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

                      a = con(values, dtype="boolean")
        assert a.any() is exp_any
        assert a.all() is exp_all
        assert a.any(skipna=False) is exp_any_noskip
        assert a.all(skipna=False) is exp_all_noskip

        assert np.any(a.any()) is exp_any
        assert np.all(a.all()) is exp_all


            

Reported by Bandit.

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

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

                      assert a.any() is exp_any
        assert a.all() is exp_all
        assert a.any(skipna=False) is exp_any_noskip
        assert a.all(skipna=False) is exp_all_noskip

        assert np.any(a.any()) is exp_any
        assert np.all(a.all()) is exp_all



            

Reported by Bandit.

pandas/tests/groupby/test_missing.py
19 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

import pandas as pd
from pandas import (
    DataFrame,
    Index,
    date_range,
)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

import pandas as pd
from pandas import (
    DataFrame,
    Index,
    date_range,
)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 14 Column: 1

              

@pytest.mark.parametrize("func", ["ffill", "bfill"])
def test_groupby_column_index_name_lost_fill_funcs(func):
    # GH: 29764 groupby loses index sometimes
    df = DataFrame(
        [[1, 1.0, -1.0], [1, np.nan, np.nan], [1, 2.0, -2.0]],
        columns=Index(["type", "a", "b"], name="idx"),
    )

            

Reported by Pylint.

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

Line: 16 Column: 5

              @pytest.mark.parametrize("func", ["ffill", "bfill"])
def test_groupby_column_index_name_lost_fill_funcs(func):
    # GH: 29764 groupby loses index sometimes
    df = DataFrame(
        [[1, 1.0, -1.0], [1, np.nan, np.nan], [1, 2.0, -2.0]],
        columns=Index(["type", "a", "b"], name="idx"),
    )
    df_grouped = df.groupby(["type"])[["a", "b"]]
    result = getattr(df_grouped, func)().columns

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 27 Column: 1

              

@pytest.mark.parametrize("func", ["ffill", "bfill"])
def test_groupby_fill_duplicate_column_names(func):
    # GH: 25610 ValueError with duplicate column names
    df1 = DataFrame({"field1": [1, 3, 4], "field2": [1, 3, 4]})
    df2 = DataFrame({"field1": [1, np.nan, 4]})
    df_grouped = pd.concat([df1, df2], axis=1).groupby(by=["field2"])
    expected = DataFrame(

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 39 Column: 1

                  tm.assert_frame_equal(result, expected)


def test_ffill_missing_arguments():
    # GH 14955
    df = DataFrame({"a": [1, 2], "b": [1, 1]})
    with pytest.raises(ValueError, match="Must specify a fill"):
        df.groupby("b").fillna()


            

Reported by Pylint.

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

Line: 41 Column: 5

              
def test_ffill_missing_arguments():
    # GH 14955
    df = DataFrame({"a": [1, 2], "b": [1, 1]})
    with pytest.raises(ValueError, match="Must specify a fill"):
        df.groupby("b").fillna()


@pytest.mark.parametrize(

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 48 Column: 1

              
@pytest.mark.parametrize(
    "method, expected", [("ffill", [None, "a", "a"]), ("bfill", ["a", "a", None])]
)
def test_fillna_with_string_dtype(method, expected):
    # GH 40250
    df = DataFrame({"a": pd.array([None, "a", None], dtype="string"), "b": [0, 0, 0]})
    grp = df.groupby("b")
    result = grp.fillna(method=method)

            

Reported by Pylint.

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

Line: 51 Column: 5

              )
def test_fillna_with_string_dtype(method, expected):
    # GH 40250
    df = DataFrame({"a": pd.array([None, "a", None], dtype="string"), "b": [0, 0, 0]})
    grp = df.groupby("b")
    result = grp.fillna(method=method)
    expected = DataFrame({"a": pd.array(expected, dtype="string")})
    tm.assert_frame_equal(result, expected)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 58 Column: 1

                  tm.assert_frame_equal(result, expected)


def test_fill_consistency():

    # GH9221
    # pass thru keyword arguments to the generated wrapper
    # are set if the passed kw is None (only)
    df = DataFrame(

            

Reported by Pylint.

pandas/tests/groupby/test_bin_groupby.py
19 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

from pandas._libs import (
    lib,
    reduction as libreduction,
)
import pandas.util._test_decorators as td


            

Reported by Pylint.

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

Line: 4 Column: 1

              import numpy as np
import pytest

from pandas._libs import (
    lib,
    reduction as libreduction,
)
import pandas.util._test_decorators as td


            

Reported by Pylint.

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

Line: 4 Column: 1

              import numpy as np
import pytest

from pandas._libs import (
    lib,
    reduction as libreduction,
)
import pandas.util._test_decorators as td


            

Reported by Pylint.

Access to a protected member _mgr of a client class
Error

Line: 72 Column: 26

              

def assert_block_lengths(x):
    assert len(x) == len(x._mgr.blocks[0].mgr_locs)
    return 0


def cumsum_max(x):
    x.cumsum().max()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

from pandas._libs import (
    lib,
    reduction as libreduction,
)
import pandas.util._test_decorators as td


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 15 Column: 1

              import pandas._testing as tm


def test_series_grouper():
    obj = Series(np.random.randn(10))

    labels = np.array([-1, -1, -1, 0, 0, 0, 1, 1, 1, 1], dtype=np.intp)

    grouper = libreduction.SeriesGrouper(obj, np.mean, labels, 2)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 30 Column: 1

                  tm.assert_almost_equal(counts, exp_counts)


def test_series_grouper_result_length_difference():
    # GH 40014
    obj = Series(np.random.randn(10), dtype="float64")
    obj.index = obj.index.astype("O")
    labels = np.array([-1, -1, -1, 0, 0, 0, 1, 1, 1, 1], dtype=np.intp)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 46 Column: 1

                  tm.assert_equal(counts, exp_counts)


def test_series_grouper_requires_nonempty_raises():
    # GH#29500
    obj = Series(np.random.randn(10))
    dummy = obj.iloc[:0]
    labels = np.array([-1, -1, -1, 0, 0, 0, 1, 1, 1, 1], dtype=np.intp)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 56 Column: 1

                      libreduction.SeriesGrouper(dummy, np.mean, labels, 2)


def test_series_bin_grouper():
    obj = Series(np.random.randn(10))

    bins = np.array([3, 6], dtype=np.int64)

    grouper = libreduction.SeriesBinGrouper(obj, np.mean, bins)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 71 Column: 1

                  tm.assert_almost_equal(counts, exp_counts)


def assert_block_lengths(x):
    assert len(x) == len(x._mgr.blocks[0].mgr_locs)
    return 0


def cumsum_max(x):

            

Reported by Pylint.

doc/make.py
19 issues
Unable to import 'docutils'
Error

Line: 23 Column: 1

              import sys
import webbrowser

import docutils
import docutils.parsers.rst

DOC_PATH = os.path.dirname(os.path.abspath(__file__))
SOURCE_PATH = os.path.join(DOC_PATH, "source")
BUILD_PATH = os.path.join(DOC_PATH, "build")

            

Reported by Pylint.

Unable to import 'docutils.parsers.rst'
Error

Line: 24 Column: 1

              import webbrowser

import docutils
import docutils.parsers.rst

DOC_PATH = os.path.dirname(os.path.abspath(__file__))
SOURCE_PATH = os.path.join(DOC_PATH, "source")
BUILD_PATH = os.path.join(DOC_PATH, "build")
REDIRECTS_FILE = os.path.join(DOC_PATH, "redirects.csv")

            

Reported by Pylint.

Undefined variable 'pandas'
Error

Line: 87 Column: 23

              
        elif single_doc.startswith("pandas."):
            try:
                obj = pandas  # noqa: F821
                for name in single_doc.split("."):
                    obj = getattr(obj, name)
            except AttributeError as err:
                raise ImportError(f"Could not import {single_doc}") from err
            else:

            

Reported by Pylint.

Unused variable 'base_name'
Error

Line: 78 Column: 9

                      return the corresponding file path
        (e.g. reference/api/pandas.DataFrame.head.rst).
        """
        base_name, extension = os.path.splitext(single_doc)
        if extension in (".rst", ".ipynb"):
            if os.path.exists(os.path.join(SOURCE_PATH, single_doc)):
                return single_doc
            else:
                raise FileNotFoundError(f"File {single_doc} not found")

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 206 Column: 24

              
                try:
                    title = self._get_page_title(row[1])
                except Exception:
                    # the file can be an ipynb and not an rst, or docutils
                    # may not be able to read the rst because it has some
                    # sphinx specific stuff
                    title = "this page"


            

Reported by Pylint.

Unused variable 'i'
Error

Line: 256 Column: 21

                          ret_code = self._sphinx_build("latex")
            os.chdir(os.path.join(BUILD_PATH, "latex"))
            if force:
                for i in range(3):
                    self._run_os("pdflatex", "-interaction=nonstopmode", "pandas.tex")
                raise SystemExit(
                    "You should check the file "
                    '"build/latex/pandas.pdf" for problems.'
                )

            

Reported by Pylint.

Consider possible security implications associated with subprocess module.
Security blacklist

Line: 19
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess

              import importlib
import os
import shutil
import subprocess
import sys
import webbrowser

import docutils
import docutils.parsers.rst

            

Reported by Bandit.

Too many arguments (7/5)
Error

Line: 40 Column: 5

                  script.
    """

    def __init__(
        self,
        num_jobs="auto",
        include_api=True,
        whatsnew=False,
        single_doc=None,

            

Reported by Pylint.

Method could be a function
Error

Line: 69 Column: 5

                      elif single_doc:
            self.single_doc_html = f"reference/api/pandas.{single_doc}.html"

    def _process_single_doc(self, single_doc):
        """
        Make sure the provided value for --single is a path to an existing
        .rst/.ipynb file, or a pandas object that can be imported.

        For example, categorial.rst or pandas.DataFrame.head. For the latter,

            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 80 Column: 13

                      """
        base_name, extension = os.path.splitext(single_doc)
        if extension in (".rst", ".ipynb"):
            if os.path.exists(os.path.join(SOURCE_PATH, single_doc)):
                return single_doc
            else:
                raise FileNotFoundError(f"File {single_doc} not found")

        elif single_doc.startswith("pandas."):

            

Reported by Pylint.

pandas/core/internals/base.py
19 issues
Instance of 'SingleDataManager' has no 'arrays' member; maybe 'array'?
Error

Line: 160 Column: 16

                      """
        Quick access to the backing array of the Block or SingleArrayManager.
        """
        return self.arrays[0]  # type: ignore[attr-defined]

    def setitem_inplace(self, indexer, value) -> None:
        """
        Set values with indexer.


            

Reported by Pylint.

TODO share more methods/attributes
Error

Line: 28 Column: 3

              
class DataManager(PandasObject):

    # TODO share more methods/attributes

    axes: list[Index]

    @property
    def items(self) -> Index:

            

Reported by Pylint.

Class name "T" doesn't conform to PascalCase naming style
Error

Line: 23 Column: 1

              from pandas.core.base import PandasObject
from pandas.core.indexes.api import Index

T = TypeVar("T", bound="DataManager")


class DataManager(PandasObject):

    # TODO share more methods/attributes

            

Reported by Pylint.

Missing class docstring
Error

Line: 26 Column: 1

              T = TypeVar("T", bound="DataManager")


class DataManager(PandasObject):

    # TODO share more methods/attributes

    axes: list[Index]


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 33 Column: 5

                  axes: list[Index]

    @property
    def items(self) -> Index:
        raise AbstractMethodError(self)

    @final
    def __len__(self) -> int:
        return len(self.items)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 41 Column: 5

                      return len(self.items)

    @property
    def ndim(self) -> int:
        return len(self.axes)

    @property
    def shape(self) -> Shape:
        return tuple(len(ax) for ax in self.axes)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 45 Column: 5

                      return len(self.axes)

    @property
    def shape(self) -> Shape:
        return tuple(len(ax) for ax in self.axes)

    @final
    def _validate_set_axis(self, axis: int, new_labels: Index) -> None:
        # Caller is responsible for ensuring we have an Index object.

            

Reported by Pylint.

Too many arguments (9/5)
Error

Line: 65 Column: 5

                              f"values have {new_len} elements"
            )

    def reindex_indexer(
        self: T,
        new_axis,
        indexer,
        axis: int,
        fill_value=None,

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 65 Column: 5

                              f"values have {new_len} elements"
            )

    def reindex_indexer(
        self: T,
        new_axis,
        indexer,
        axis: int,
        fill_value=None,

            

Reported by Pylint.

Too many arguments (6/5)
Error

Line: 79 Column: 5

                      raise AbstractMethodError(self)

    @final
    def reindex_axis(
        self: T,
        new_index: Index,
        axis: int,
        fill_value=None,
        consolidate: bool = True,

            

Reported by Pylint.

pandas/tests/frame/methods/test_matmul.py
19 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              import operator

import numpy as np
import pytest

from pandas import (
    DataFrame,
    Index,
    Series,

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 84 Column: 13

              
        msg = r"shapes \(10, 4\) and \(5, 3\) not aligned"
        with pytest.raises(ValueError, match=msg):
            a @ df
        with pytest.raises(ValueError, match=msg):
            a.tolist() @ df

            

Reported by Pylint.

Expression "a.tolist() @ df" is assigned to nothing
Error

Line: 86 Column: 13

                      with pytest.raises(ValueError, match=msg):
            a @ df
        with pytest.raises(ValueError, match=msg):
            a.tolist() @ df

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import operator

import numpy as np
import pytest

from pandas import (
    DataFrame,
    Index,
    Series,

            

Reported by Pylint.

Missing class docstring
Error

Line: 14 Column: 1

              import pandas._testing as tm


class TestMatMul:
    def test_matmul(self):
        # matmul test is for GH#10259
        a = DataFrame(
            np.random.randn(3, 4), index=["a", "b", "c"], columns=["p", "q", "r", "s"]
        )

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 15 Column: 5

              

class TestMatMul:
    def test_matmul(self):
        # matmul test is for GH#10259
        a = DataFrame(
            np.random.randn(3, 4), index=["a", "b", "c"], columns=["p", "q", "r", "s"]
        )
        b = DataFrame(

            

Reported by Pylint.

Method could be a function
Error

Line: 15 Column: 5

              

class TestMatMul:
    def test_matmul(self):
        # matmul test is for GH#10259
        a = DataFrame(
            np.random.randn(3, 4), index=["a", "b", "c"], columns=["p", "q", "r", "s"]
        )
        b = DataFrame(

            

Reported by Pylint.

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

Line: 17 Column: 9

              class TestMatMul:
    def test_matmul(self):
        # matmul test is for GH#10259
        a = DataFrame(
            np.random.randn(3, 4), index=["a", "b", "c"], columns=["p", "q", "r", "s"]
        )
        b = DataFrame(
            np.random.randn(4, 2), index=["p", "q", "r", "s"], columns=["one", "two"]
        )

            

Reported by Pylint.

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

Line: 20 Column: 9

                      a = DataFrame(
            np.random.randn(3, 4), index=["a", "b", "c"], columns=["p", "q", "r", "s"]
        )
        b = DataFrame(
            np.random.randn(4, 2), index=["p", "q", "r", "s"], columns=["one", "two"]
        )

        # DataFrame @ DataFrame
        result = operator.matmul(a, b)

            

Reported by Pylint.

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

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

              
        # np.array @ DataFrame
        result = operator.matmul(a.values, b)
        assert isinstance(result, DataFrame)
        assert result.columns.equals(b.columns)
        assert result.index.equals(Index(range(3)))
        expected = np.dot(a.values, b.values)
        tm.assert_almost_equal(result.values, expected)


            

Reported by Bandit.

pandas/tests/frame/methods/test_assign.py
19 issues
Unable to import 'pytest'
Error

Line: 1 Column: 1

              import pytest

from pandas import DataFrame
import pandas._testing as tm


class TestAssign:
    def test_assign(self):
        df = DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})

            

Reported by Pylint.

Too many positional arguments for method call
Error

Line: 70 Column: 13

                      # non-keyword argument
        msg = r"assign\(\) takes 1 positional argument but 2 were given"
        with pytest.raises(TypeError, match=msg):
            df.assign(lambda x: x.A)
        msg = "'DataFrame' object has no attribute 'C'"
        with pytest.raises(AttributeError, match=msg):
            df.assign(C=df.A, D=df.A + df.C)

    def test_assign_dependent(self):

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import pytest

from pandas import DataFrame
import pandas._testing as tm


class TestAssign:
    def test_assign(self):
        df = DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})

            

Reported by Pylint.

Missing class docstring
Error

Line: 7 Column: 1

              import pandas._testing as tm


class TestAssign:
    def test_assign(self):
        df = DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})
        original = df.copy()
        result = df.assign(C=df.B / df.A)
        expected = df.copy()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 8 Column: 5

              

class TestAssign:
    def test_assign(self):
        df = DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})
        original = df.copy()
        result = df.assign(C=df.B / df.A)
        expected = df.copy()
        expected["C"] = [4, 2.5, 2]

            

Reported by Pylint.

Method could be a function
Error

Line: 8 Column: 5

              

class TestAssign:
    def test_assign(self):
        df = DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})
        original = df.copy()
        result = df.assign(C=df.B / df.A)
        expected = df.copy()
        expected["C"] = [4, 2.5, 2]

            

Reported by Pylint.

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

Line: 9 Column: 9

              
class TestAssign:
    def test_assign(self):
        df = DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})
        original = df.copy()
        result = df.assign(C=df.B / df.A)
        expected = df.copy()
        expected["C"] = [4, 2.5, 2]
        tm.assert_frame_equal(result, expected)

            

Reported by Pylint.

Method could be a function
Error

Line: 43 Column: 5

                      result = df.assign(A=lambda x: x.A + x.B)
        tm.assert_frame_equal(result, expected)

    def test_assign_multiple(self):
        df = DataFrame([[1, 4], [2, 5], [3, 6]], columns=["A", "B"])
        result = df.assign(C=[7, 8, 9], D=df.A, E=lambda x: x.B)
        expected = DataFrame(
            [[1, 4, 7, 1, 4], [2, 5, 8, 2, 5], [3, 6, 9, 3, 6]], columns=list("ABCDE")
        )

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 43 Column: 5

                      result = df.assign(A=lambda x: x.A + x.B)
        tm.assert_frame_equal(result, expected)

    def test_assign_multiple(self):
        df = DataFrame([[1, 4], [2, 5], [3, 6]], columns=["A", "B"])
        result = df.assign(C=[7, 8, 9], D=df.A, E=lambda x: x.B)
        expected = DataFrame(
            [[1, 4, 7, 1, 4], [2, 5, 8, 2, 5], [3, 6, 9, 3, 6]], columns=list("ABCDE")
        )

            

Reported by Pylint.

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

Line: 44 Column: 9

                      tm.assert_frame_equal(result, expected)

    def test_assign_multiple(self):
        df = DataFrame([[1, 4], [2, 5], [3, 6]], columns=["A", "B"])
        result = df.assign(C=[7, 8, 9], D=df.A, E=lambda x: x.B)
        expected = DataFrame(
            [[1, 4, 7, 1, 4], [2, 5, 8, 2, 5], [3, 6, 9, 3, 6]], columns=list("ABCDE")
        )
        tm.assert_frame_equal(result, expected)

            

Reported by Pylint.

pandas/tests/base/test_unique.py
19 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

from pandas._libs import iNaT

from pandas.core.dtypes.common import (
    is_datetime64tz_dtype,
    needs_i8_conversion,
)

            

Reported by Pylint.

Instance of 'Index' has no 'normalize' member
Error

Line: 34 Column: 24

                  elif isinstance(obj, pd.Index):
        expected = pd.Index(unique_values, dtype=obj.dtype)
        if is_datetime64tz_dtype(obj.dtype):
            expected = expected.normalize()
        tm.assert_index_equal(result, expected, exact=True)
    else:
        expected = np.array(unique_values)
        tm.assert_numpy_array_equal(result, expected)


            

Reported by Pylint.

Instance of 'Index' has no 'normalize' member
Error

Line: 76 Column: 24

                      expected = pd.Index(unique_values, dtype=obj.dtype)
        if is_datetime64tz_dtype(obj.dtype):
            result = result.normalize()
            expected = expected.normalize()
        tm.assert_index_equal(result, expected, exact=True)
    else:
        expected = np.array(unique_values, dtype=obj.dtype)
        tm.assert_numpy_array_equal(result, expected)


            

Reported by Pylint.

Access to a protected member _is_backward_compat_public_numeric_index of a client class
Error

Line: 28 Column: 40

                      expected = pd.MultiIndex.from_tuples(unique_values)
        expected.names = obj.names
        tm.assert_index_equal(result, expected, exact=True)
    elif isinstance(obj, pd.Index) and obj._is_backward_compat_public_numeric_index:
        expected = NumericIndex(unique_values, dtype=obj.dtype)
        tm.assert_index_equal(result, expected, exact=True)
    elif isinstance(obj, pd.Index):
        expected = pd.Index(unique_values, dtype=obj.dtype)
        if is_datetime64tz_dtype(obj.dtype):

            

Reported by Pylint.

Access to a protected member _is_backward_compat_public_numeric_index of a client class
Error

Line: 69 Column: 38

                  unique_values_not_null = [val for val in unique_values_raw if not pd.isnull(val)]
    unique_values = [null_obj] + unique_values_not_null

    if isinstance(obj, pd.Index) and obj._is_backward_compat_public_numeric_index:
        expected = NumericIndex(unique_values, dtype=obj.dtype)
        tm.assert_index_equal(result, expected, exact=True)
    elif isinstance(obj, pd.Index):
        expected = pd.Index(unique_values, dtype=obj.dtype)
        if is_datetime64tz_dtype(obj.dtype):

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

from pandas._libs import iNaT

from pandas.core.dtypes.common import (
    is_datetime64tz_dtype,
    needs_i8_conversion,
)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 1

              from pandas.tests.base.common import allow_na_ops


def test_unique(index_or_series_obj):
    obj = index_or_series_obj
    obj = np.repeat(obj, range(1, len(obj) + 1))
    result = obj.unique()

    # dict.fromkeys preserves the order

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 42 Column: 1

              

@pytest.mark.parametrize("null_obj", [np.nan, None])
def test_unique_null(null_obj, index_or_series_obj):
    obj = index_or_series_obj

    if not allow_na_ops(obj):
        pytest.skip("type doesn't allow for NA operations")
    elif len(obj) < 1:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 83 Column: 1

                      tm.assert_numpy_array_equal(result, expected)


def test_nunique(index_or_series_obj):
    obj = index_or_series_obj
    obj = np.repeat(obj, range(1, len(obj) + 1))
    expected = len(obj.unique())
    assert obj.nunique(dropna=False) == expected


            

Reported by Pylint.

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

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

                  obj = index_or_series_obj
    obj = np.repeat(obj, range(1, len(obj) + 1))
    expected = len(obj.unique())
    assert obj.nunique(dropna=False) == expected


@pytest.mark.parametrize("null_obj", [np.nan, None])
def test_nunique_null(null_obj, index_or_series_obj):
    obj = index_or_series_obj

            

Reported by Bandit.

pandas/tests/frame/methods/test_duplicated.py
19 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              import re

import numpy as np
import pytest

from pandas import (
    DataFrame,
    Series,
    date_range,

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import re

import numpy as np
import pytest

from pandas import (
    DataFrame,
    Series,
    date_range,

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 15 Column: 1

              

@pytest.mark.parametrize("subset", ["a", ["a"], ["a", "B"]])
def test_duplicated_with_misspelled_column_name(subset):
    # GH 19730
    df = DataFrame({"A": [0, 0, 1], "B": [0, 0, 1], "C": [0, 0, 1]})
    msg = re.escape("Index(['a'], dtype='object')")

    with pytest.raises(KeyError, match=msg):

            

Reported by Pylint.

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

Line: 17 Column: 5

              @pytest.mark.parametrize("subset", ["a", ["a"], ["a", "B"]])
def test_duplicated_with_misspelled_column_name(subset):
    # GH 19730
    df = DataFrame({"A": [0, 0, 1], "B": [0, 0, 1], "C": [0, 0, 1]})
    msg = re.escape("Index(['a'], dtype='object')")

    with pytest.raises(KeyError, match=msg):
        df.duplicated(subset)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 25 Column: 1

              

@pytest.mark.slow
def test_duplicated_do_not_fail_on_wide_dataframes():
    # gh-21524
    # Given the wide dataframe with a lot of columns
    # with different (important!) values
    data = {f"col_{i:02d}": np.random.randint(0, 1000, 30000) for i in range(100)}
    df = DataFrame(data).T

            

Reported by Pylint.

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

Line: 30 Column: 5

                  # Given the wide dataframe with a lot of columns
    # with different (important!) values
    data = {f"col_{i:02d}": np.random.randint(0, 1000, 30000) for i in range(100)}
    df = DataFrame(data).T
    result = df.duplicated()

    # Then duplicates produce the bool Series as a result and don't fail during
    # calculation. Actual values doesn't matter here, though usually it's all
    # False in this case

            

Reported by Pylint.

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

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

                  # Then duplicates produce the bool Series as a result and don't fail during
    # calculation. Actual values doesn't matter here, though usually it's all
    # False in this case
    assert isinstance(result, Series)
    assert result.dtype == np.bool_


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

            

Reported by Bandit.

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

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

                  # calculation. Actual values doesn't matter here, though usually it's all
    # False in this case
    assert isinstance(result, Series)
    assert result.dtype == np.bool_


@pytest.mark.parametrize(
    "keep, expected",
    [

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 46 Column: 1

                      ("first", Series([False, False, True, False, True])),
        ("last", Series([True, True, False, False, False])),
        (False, Series([True, True, True, False, True])),
    ],
)
def test_duplicated_keep(keep, expected):
    df = DataFrame({"A": [0, 1, 1, 2, 0], "B": ["a", "b", "b", "c", "a"]})

    result = df.duplicated(keep=keep)

            

Reported by Pylint.

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

Line: 49 Column: 5

                  ],
)
def test_duplicated_keep(keep, expected):
    df = DataFrame({"A": [0, 1, 1, 2, 0], "B": ["a", "b", "b", "c", "a"]})

    result = df.duplicated(keep=keep)
    tm.assert_series_equal(result, expected)



            

Reported by Pylint.