The following issues were found

pandas/tests/indexes/period/test_period_range.py
17 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

from pandas import (
    NaT,
    Period,
    PeriodIndex,
    date_range,
    period_range,

            

Reported by Pylint.

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

Line: 26 Column: 20

                  @pytest.mark.parametrize("freq", ["D", "W", "M", "Q", "A"])
    def test_construction_from_string(self, freq):
        # non-empty
        expected = date_range(
            start="2017-01-01", periods=5, freq=freq, name="foo"
        ).to_period()
        start, end = str(expected[0]), str(expected[-1])

        result = period_range(start=start, end=end, freq=freq, name="foo")

            

Reported by Pylint.

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

Line: 26 Column: 20

                  @pytest.mark.parametrize("freq", ["D", "W", "M", "Q", "A"])
    def test_construction_from_string(self, freq):
        # non-empty
        expected = date_range(
            start="2017-01-01", periods=5, freq=freq, name="foo"
        ).to_period()
        start, end = str(expected[0]), str(expected[-1])

        result = period_range(start=start, end=end, freq=freq, name="foo")

            

Reported by Pylint.

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

Line: 55 Column: 20

                  def test_construction_from_period(self):
        # upsampling
        start, end = Period("2017Q1", freq="Q"), Period("2018Q1", freq="Q")
        expected = date_range(
            start="2017-03-31", end="2018-03-31", freq="M", name="foo"
        ).to_period()
        result = period_range(start=start, end=end, freq="M", name="foo")
        tm.assert_index_equal(result, expected)


            

Reported by Pylint.

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

Line: 55 Column: 20

                  def test_construction_from_period(self):
        # upsampling
        start, end = Period("2017Q1", freq="Q"), Period("2018Q1", freq="Q")
        expected = date_range(
            start="2017-03-31", end="2018-03-31", freq="M", name="foo"
        ).to_period()
        result = period_range(start=start, end=end, freq="M", name="foo")
        tm.assert_index_equal(result, expected)


            

Reported by Pylint.

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

Line: 63 Column: 20

              
        # downsampling
        start, end = Period("2017-1", freq="M"), Period("2019-12", freq="M")
        expected = date_range(
            start="2017-01-31", end="2019-12-31", freq="Q", name="foo"
        ).to_period()
        result = period_range(start=start, end=end, freq="Q", name="foo")
        tm.assert_index_equal(result, expected)


            

Reported by Pylint.

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

Line: 63 Column: 20

              
        # downsampling
        start, end = Period("2017-1", freq="M"), Period("2019-12", freq="M")
        expected = date_range(
            start="2017-01-31", end="2019-12-31", freq="Q", name="foo"
        ).to_period()
        result = period_range(start=start, end=end, freq="Q", name="foo")
        tm.assert_index_equal(result, expected)


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

from pandas import (
    NaT,
    Period,
    PeriodIndex,
    date_range,
    period_range,

            

Reported by Pylint.

Missing class docstring
Error

Line: 14 Column: 1

              import pandas._testing as tm


class TestPeriodRange:
    def test_required_arguments(self):
        msg = (
            "Of the three parameters: start, end, and periods, exactly two "
            "must be specified"
        )

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 15 Column: 5

              

class TestPeriodRange:
    def test_required_arguments(self):
        msg = (
            "Of the three parameters: start, end, and periods, exactly two "
            "must be specified"
        )
        with pytest.raises(ValueError, match=msg):

            

Reported by Pylint.

pandas/tests/tseries/frequencies/test_freq_code.py
17 issues
Unable to import 'pytest'
Error

Line: 1 Column: 1

              import pytest

from pandas._libs.tslibs import (
    Period,
    Resolution,
    to_offset,
)
from pandas._libs.tslibs.dtypes import _attrname_to_abbrevs


            

Reported by Pylint.

Unable to import 'pandas._libs.tslibs.dtypes'
Error

Line: 8 Column: 1

                  Resolution,
    to_offset,
)
from pandas._libs.tslibs.dtypes import _attrname_to_abbrevs


@pytest.mark.parametrize(
    "freqstr,exp_freqstr",
    [("D", "D"), ("W", "D"), ("M", "D"), ("S", "S"), ("T", "S"), ("H", "S")],

            

Reported by Pylint.

Access to a protected member _from_ordinal of a client class
Error

Line: 17 Column: 11

              )
def test_get_to_timestamp_base(freqstr, exp_freqstr):
    off = to_offset(freqstr)
    per = Period._from_ordinal(1, off)
    exp_code = to_offset(exp_freqstr)._period_dtype_code

    result_code = per._get_to_timestamp_base()
    assert result_code == exp_code


            

Reported by Pylint.

Access to a protected member _period_dtype_code of a client class
Error

Line: 18 Column: 16

              def test_get_to_timestamp_base(freqstr, exp_freqstr):
    off = to_offset(freqstr)
    per = Period._from_ordinal(1, off)
    exp_code = to_offset(exp_freqstr)._period_dtype_code

    result_code = per._get_to_timestamp_base()
    assert result_code == exp_code



            

Reported by Pylint.

Access to a protected member _get_to_timestamp_base of a client class
Error

Line: 20 Column: 19

                  per = Period._from_ordinal(1, off)
    exp_code = to_offset(exp_freqstr)._period_dtype_code

    result_code = per._get_to_timestamp_base()
    assert result_code == exp_code


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

            

Reported by Pylint.

Access to a protected member _prefix of a client class
Error

Line: 65 Column: 12

                  # see gh-14378
    off = to_offset(str(args[0]) + args[1])
    assert off.n == expected[0]
    assert off._prefix == expected[1]


@pytest.mark.parametrize(
    "args",
    [

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import pytest

from pandas._libs.tslibs import (
    Period,
    Resolution,
    to_offset,
)
from pandas._libs.tslibs.dtypes import _attrname_to_abbrevs


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 14 Column: 1

              @pytest.mark.parametrize(
    "freqstr,exp_freqstr",
    [("D", "D"), ("W", "D"), ("M", "D"), ("S", "S"), ("T", "S"), ("H", "S")],
)
def test_get_to_timestamp_base(freqstr, exp_freqstr):
    off = to_offset(freqstr)
    per = Period._from_ordinal(1, off)
    exp_code = to_offset(exp_freqstr)._period_dtype_code


            

Reported by Pylint.

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

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

                  exp_code = to_offset(exp_freqstr)._period_dtype_code

    result_code = per._get_to_timestamp_base()
    assert result_code == exp_code


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

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 37 Column: 1

                      ("L", "millisecond"),
        ("U", "microsecond"),
        ("N", "nanosecond"),
    ],
)
def test_get_attrname_from_abbrev(freqstr, expected):
    assert Resolution.get_reso_from_freq(freqstr).attrname == expected



            

Reported by Pylint.

pandas/tests/indexes/multi/test_join.py
17 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 function or method docstring
Error

Line: 13 Column: 1

              
@pytest.mark.parametrize(
    "other", [Index(["three", "one", "two"]), Index(["one"]), Index(["one", "three"])]
)
def test_join_level(idx, other, join_type):
    join_index, lidx, ridx = other.join(
        idx, how=join_type, level="second", return_indexers=True
    )


            

Reported by Pylint.

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

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

                  )

    exp_level = other.join(idx.levels[1], how=join_type)
    assert join_index.levels[0].equals(idx.levels[0])
    assert join_index.levels[1].equals(exp_level)

    # pare down levels
    mask = np.array([x[1] in exp_level for x in idx], dtype=bool)
    exp_values = idx.values[mask]

            

Reported by Bandit.

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

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

              
    exp_level = other.join(idx.levels[1], how=join_type)
    assert join_index.levels[0].equals(idx.levels[0])
    assert join_index.levels[1].equals(exp_level)

    # pare down levels
    mask = np.array([x[1] in exp_level for x in idx], dtype=bool)
    exp_values = idx.values[mask]
    tm.assert_numpy_array_equal(join_index.values, exp_values)

            

Reported by Bandit.

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

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

                          other, how=join_type, level="second", return_indexers=True
        )

        assert join_index.equals(join_index2)
        tm.assert_numpy_array_equal(lidx, lidx2)
        tm.assert_numpy_array_equal(ridx, ridx2)
        tm.assert_numpy_array_equal(join_index2.values, exp_values)



            

Reported by Bandit.

Missing function or method docstring
Error

Line: 39 Column: 1

                      tm.assert_numpy_array_equal(join_index2.values, exp_values)


def test_join_level_corner_case(idx):
    # some corner cases
    index = Index(["three", "one", "two"])
    result = index.join(idx, level="second")
    assert isinstance(result, MultiIndex)


            

Reported by Pylint.

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

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

                  # some corner cases
    index = Index(["three", "one", "two"])
    result = index.join(idx, level="second")
    assert isinstance(result, MultiIndex)

    with pytest.raises(TypeError, match="Join.*MultiIndex.*ambiguous"):
        idx.join(idx, level=1)



            

Reported by Bandit.

Missing function or method docstring
Error

Line: 49 Column: 1

                      idx.join(idx, level=1)


def test_join_self(idx, join_type):
    joined = idx.join(idx, how=join_type)
    tm.assert_index_equal(joined, idx)


def test_join_multi():

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 54 Column: 1

                  tm.assert_index_equal(joined, idx)


def test_join_multi():
    # GH 10665
    midx = MultiIndex.from_product([np.arange(4), np.arange(4)], names=["a", "b"])
    idx = Index([1, 2, 5], name="b")

    # inner

            

Reported by Pylint.

pandas/tests/indexes/timedeltas/methods/test_shift.py
17 issues
Unable to import 'pytest'
Error

Line: 1 Column: 1

              import pytest

from pandas.errors import NullFrequencyError

import pandas as pd
from pandas import TimedeltaIndex
import pandas._testing as tm



            

Reported by Pylint.

Access to a protected member _with_freq of a client class
Error

Line: 42 Column: 18

                  def test_tdi_shift_int(self):
        # GH#8083
        tdi = pd.to_timedelta(range(5), unit="d")
        trange = tdi._with_freq("infer") + pd.offsets.Hour(1)
        result = trange.shift(1)
        expected = TimedeltaIndex(
            [
                "1 days 01:00:00",
                "2 days 01:00:00",

            

Reported by Pylint.

Access to a protected member _with_freq of a client class
Error

Line: 59 Column: 18

                  def test_tdi_shift_nonstandard_freq(self):
        # GH#8083
        tdi = pd.to_timedelta(range(5), unit="d")
        trange = tdi._with_freq("infer") + pd.offsets.Hour(1)
        result = trange.shift(3, freq="2D 1s")
        expected = TimedeltaIndex(
            [
                "6 days 01:00:03",
                "7 days 01:00:03",

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import pytest

from pandas.errors import NullFrequencyError

import pandas as pd
from pandas import TimedeltaIndex
import pandas._testing as tm



            

Reported by Pylint.

Missing class docstring
Error

Line: 10 Column: 1

              import pandas._testing as tm


class TestTimedeltaIndexShift:

    # -------------------------------------------------------------
    # TimedeltaIndex.shift is used by __add__/__sub__

    def test_tdi_shift_empty(self):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 15 Column: 5

                  # -------------------------------------------------------------
    # TimedeltaIndex.shift is used by __add__/__sub__

    def test_tdi_shift_empty(self):
        # GH#9903
        idx = TimedeltaIndex([], name="xxx")
        tm.assert_index_equal(idx.shift(0, freq="H"), idx)
        tm.assert_index_equal(idx.shift(3, freq="H"), idx)


            

Reported by Pylint.

Method could be a function
Error

Line: 15 Column: 5

                  # -------------------------------------------------------------
    # TimedeltaIndex.shift is used by __add__/__sub__

    def test_tdi_shift_empty(self):
        # GH#9903
        idx = TimedeltaIndex([], name="xxx")
        tm.assert_index_equal(idx.shift(0, freq="H"), idx)
        tm.assert_index_equal(idx.shift(3, freq="H"), idx)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 21 Column: 5

                      tm.assert_index_equal(idx.shift(0, freq="H"), idx)
        tm.assert_index_equal(idx.shift(3, freq="H"), idx)

    def test_tdi_shift_hours(self):
        # GH#9903
        idx = TimedeltaIndex(["5 hours", "6 hours", "9 hours"], name="xxx")
        tm.assert_index_equal(idx.shift(0, freq="H"), idx)
        exp = TimedeltaIndex(["8 hours", "9 hours", "12 hours"], name="xxx")
        tm.assert_index_equal(idx.shift(3, freq="H"), exp)

            

Reported by Pylint.

Method could be a function
Error

Line: 21 Column: 5

                      tm.assert_index_equal(idx.shift(0, freq="H"), idx)
        tm.assert_index_equal(idx.shift(3, freq="H"), idx)

    def test_tdi_shift_hours(self):
        # GH#9903
        idx = TimedeltaIndex(["5 hours", "6 hours", "9 hours"], name="xxx")
        tm.assert_index_equal(idx.shift(0, freq="H"), idx)
        exp = TimedeltaIndex(["8 hours", "9 hours", "12 hours"], name="xxx")
        tm.assert_index_equal(idx.shift(3, freq="H"), exp)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 30 Column: 5

                      exp = TimedeltaIndex(["2 hours", "3 hours", "6 hours"], name="xxx")
        tm.assert_index_equal(idx.shift(-3, freq="H"), exp)

    def test_tdi_shift_minutes(self):
        # GH#9903
        idx = TimedeltaIndex(["5 hours", "6 hours", "9 hours"], name="xxx")
        tm.assert_index_equal(idx.shift(0, freq="T"), idx)
        exp = TimedeltaIndex(["05:03:00", "06:03:00", "9:03:00"], name="xxx")
        tm.assert_index_equal(idx.shift(3, freq="T"), exp)

            

Reported by Pylint.

pandas/tests/indexes/timedeltas/test_delete.py
17 issues
Missing module docstring
Error

Line: 1 Column: 1

              from pandas import (
    TimedeltaIndex,
    timedelta_range,
)
import pandas._testing as tm


class TestTimedeltaIndexDelete:
    def test_delete(self):

            

Reported by Pylint.

Missing class docstring
Error

Line: 8 Column: 1

              import pandas._testing as tm


class TestTimedeltaIndexDelete:
    def test_delete(self):
        idx = timedelta_range(start="1 Days", periods=5, freq="D", name="idx")

        # preserve freq
        expected_0 = timedelta_range(start="2 Days", periods=4, freq="D", name="idx")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 9 Column: 5

              

class TestTimedeltaIndexDelete:
    def test_delete(self):
        idx = timedelta_range(start="1 Days", periods=5, freq="D", name="idx")

        # preserve freq
        expected_0 = timedelta_range(start="2 Days", periods=4, freq="D", name="idx")
        expected_4 = timedelta_range(start="1 Days", periods=4, freq="D", name="idx")

            

Reported by Pylint.

Method could be a function
Error

Line: 9 Column: 5

              

class TestTimedeltaIndexDelete:
    def test_delete(self):
        idx = timedelta_range(start="1 Days", periods=5, freq="D", name="idx")

        # preserve freq
        expected_0 = timedelta_range(start="2 Days", periods=4, freq="D", name="idx")
        expected_4 = timedelta_range(start="1 Days", periods=4, freq="D", name="idx")

            

Reported by Pylint.

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

Line: 28 Column: 13

                          4: expected_4,
            1: expected_1,
        }
        for n, expected in cases.items():
            result = idx.delete(n)
            tm.assert_index_equal(result, expected)
            assert result.name == expected.name
            assert result.freq == expected.freq


            

Reported by Pylint.

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

                      for n, expected in cases.items():
            result = idx.delete(n)
            tm.assert_index_equal(result, expected)
            assert result.name == expected.name
            assert result.freq == expected.freq

        with tm.external_error_raised((IndexError, ValueError)):
            # either depending on numpy version
            idx.delete(5)

            

Reported by Bandit.

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

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

                          result = idx.delete(n)
            tm.assert_index_equal(result, expected)
            assert result.name == expected.name
            assert result.freq == expected.freq

        with tm.external_error_raised((IndexError, ValueError)):
            # either depending on numpy version
            idx.delete(5)


            

Reported by Bandit.

Missing function or method docstring
Error

Line: 38 Column: 5

                          # either depending on numpy version
            idx.delete(5)

    def test_delete_slice(self):
        idx = timedelta_range(start="1 days", periods=10, freq="D", name="idx")

        # preserve freq
        expected_0_2 = timedelta_range(start="4 days", periods=7, freq="D", name="idx")
        expected_7_9 = timedelta_range(start="1 days", periods=7, freq="D", name="idx")

            

Reported by Pylint.

Method could be a function
Error

Line: 38 Column: 5

                          # either depending on numpy version
            idx.delete(5)

    def test_delete_slice(self):
        idx = timedelta_range(start="1 days", periods=10, freq="D", name="idx")

        # preserve freq
        expected_0_2 = timedelta_range(start="4 days", periods=7, freq="D", name="idx")
        expected_7_9 = timedelta_range(start="1 days", periods=7, freq="D", name="idx")

            

Reported by Pylint.

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

Line: 55 Column: 13

                          (7, 8, 9): expected_7_9,
            (3, 4, 5): expected_3_5,
        }
        for n, expected in cases.items():
            result = idx.delete(n)
            tm.assert_index_equal(result, expected)
            assert result.name == expected.name
            assert result.freq == expected.freq


            

Reported by Pylint.

pandas/tests/series/methods/test_argsort.py
17 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

from pandas import (
    Series,
    Timestamp,
    isna,
)
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 (
    Series,
    Timestamp,
    isna,
)
import pandas._testing as tm

            

Reported by Pylint.

Missing class docstring
Error

Line: 12 Column: 1

              import pandas._testing as tm


class TestSeriesArgsort:
    def _check_accum_op(self, name, ser, check_dtype=True):
        func = getattr(np, name)
        tm.assert_numpy_array_equal(
            func(ser).values, func(np.array(ser)), check_dtype=check_dtype
        )

            

Reported by Pylint.

Method could be a function
Error

Line: 13 Column: 5

              

class TestSeriesArgsort:
    def _check_accum_op(self, name, ser, check_dtype=True):
        func = getattr(np, name)
        tm.assert_numpy_array_equal(
            func(ser).values, func(np.array(ser)), check_dtype=check_dtype
        )


            

Reported by Pylint.

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

Line: 20 Column: 9

                      )

        # with missing values
        ts = ser.copy()
        ts[::2] = np.NaN

        result = func(ts)[1::2]
        expected = func(np.array(ts.dropna()))


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 28 Column: 5

              
        tm.assert_numpy_array_equal(result.values, expected, check_dtype=False)

    def test_argsort(self, datetime_series):
        self._check_accum_op("argsort", datetime_series, check_dtype=False)
        argsorted = datetime_series.argsort()
        assert issubclass(argsorted.dtype.type, np.integer)

        # GH#2967 (introduced bug in 0.11-dev I think)

            

Reported by Pylint.

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

                  def test_argsort(self, datetime_series):
        self._check_accum_op("argsort", datetime_series, check_dtype=False)
        argsorted = datetime_series.argsort()
        assert issubclass(argsorted.dtype.type, np.integer)

        # GH#2967 (introduced bug in 0.11-dev I think)
        s = Series([Timestamp(f"201301{i:02d}") for i in range(1, 6)])
        assert s.dtype == "datetime64[ns]"
        shifted = s.shift(-1)

            

Reported by Bandit.

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

Line: 34 Column: 9

                      assert issubclass(argsorted.dtype.type, np.integer)

        # GH#2967 (introduced bug in 0.11-dev I think)
        s = Series([Timestamp(f"201301{i:02d}") for i in range(1, 6)])
        assert s.dtype == "datetime64[ns]"
        shifted = s.shift(-1)
        assert shifted.dtype == "datetime64[ns]"
        assert isna(shifted[4])


            

Reported by Pylint.

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

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

              
        # GH#2967 (introduced bug in 0.11-dev I think)
        s = Series([Timestamp(f"201301{i:02d}") for i in range(1, 6)])
        assert s.dtype == "datetime64[ns]"
        shifted = s.shift(-1)
        assert shifted.dtype == "datetime64[ns]"
        assert isna(shifted[4])

        result = s.argsort()

            

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

                      s = Series([Timestamp(f"201301{i:02d}") for i in range(1, 6)])
        assert s.dtype == "datetime64[ns]"
        shifted = s.shift(-1)
        assert shifted.dtype == "datetime64[ns]"
        assert isna(shifted[4])

        result = s.argsort()
        expected = Series(range(5), dtype="int64")
        tm.assert_series_equal(result, expected)

            

Reported by Bandit.

scripts/validate_docstrings.py
17 issues
Unable to import 'numpydoc.validate'
Error

Line: 31 Column: 1

              import matplotlib
import matplotlib.pyplot as plt
import numpy
from numpydoc.validate import (
    Docstring,
    validate,
)

import pandas

            

Reported by Pylint.

Using subprocess.run without explicitly set `check` is not recommended.
Error

Line: 178 Column: 24

                          file.write(content)
            file.flush()
            cmd = ["python", "-m", "flake8", "--quiet", "--statistics", file.name]
            response = subprocess.run(cmd, capture_output=True, text=True)
            stdout = response.stdout
            stdout = stdout.replace(file.name, "")
            messages = stdout.strip("\n")
            if messages:
                error_messages.append(messages)

            

Reported by Pylint.

Consider possible security implications associated with subprocess module.
Security blacklist

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

              import io
import json
import pathlib
import subprocess
import sys
import tempfile

import matplotlib
import matplotlib.pyplot as plt

            

Reported by Bandit.

Missing class docstring
Error

Line: 136 Column: 1

                      previous_line = line


class PandasDocstring(Docstring):
    @property
    def mentioned_private_classes(self):
        return [klass for klass in PRIVATE_CLASSES if klass in self.raw_doc]

    @property

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 138 Column: 5

              
class PandasDocstring(Docstring):
    @property
    def mentioned_private_classes(self):
        return [klass for klass in PRIVATE_CLASSES if klass in self.raw_doc]

    @property
    def examples_errors(self):
        flags = doctest.NORMALIZE_WHITESPACE | doctest.IGNORE_EXCEPTION_DETAIL

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 142 Column: 5

                      return [klass for klass in PRIVATE_CLASSES if klass in self.raw_doc]

    @property
    def examples_errors(self):
        flags = doctest.NORMALIZE_WHITESPACE | doctest.IGNORE_EXCEPTION_DETAIL
        finder = doctest.DocTestFinder()
        runner = doctest.DocTestRunner(optionflags=flags)
        context = {"np": numpy, "pd": pandas}
        error_msgs = ""

            

Reported by Pylint.

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

Line: 149 Column: 13

                      context = {"np": numpy, "pd": pandas}
        error_msgs = ""
        for test in finder.find(self.raw_doc, self.name, globs=context):
            f = io.StringIO()
            runner.run(test, out=f.write)
            error_msgs += f.getvalue()
        return error_msgs

    @property

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 155 Column: 5

                      return error_msgs

    @property
    def examples_source_code(self):
        lines = doctest.DocTestParser().get_examples(self.raw_doc)
        return [line.source for line in lines]

    def validate_pep8(self):
        if not self.examples:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 159 Column: 5

                      lines = doctest.DocTestParser().get_examples(self.raw_doc)
        return [line.source for line in lines]

    def validate_pep8(self):
        if not self.examples:
            return

        # F401 is needed to not generate flake8 errors in examples
        # that do not user numpy or pandas

            

Reported by Pylint.

subprocess call - check for execution of untrusted input.
Security injection

Line: 178
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html

                          file.write(content)
            file.flush()
            cmd = ["python", "-m", "flake8", "--quiet", "--statistics", file.name]
            response = subprocess.run(cmd, capture_output=True, text=True)
            stdout = response.stdout
            stdout = stdout.replace(file.name, "")
            messages = stdout.strip("\n")
            if messages:
                error_messages.append(messages)

            

Reported by Bandit.

pandas/tests/indexes/timedeltas/methods/test_factorize.py
16 issues
Instance of 'TimedeltaIndex' has no 'freq' member
Error

Line: 21 Column: 28

                      arr, idx = idx1.factorize()
        tm.assert_numpy_array_equal(arr, exp_arr)
        tm.assert_index_equal(idx, exp_idx)
        assert idx.freq == exp_idx.freq

        arr, idx = idx1.factorize(sort=True)
        tm.assert_numpy_array_equal(arr, exp_arr)
        tm.assert_index_equal(idx, exp_idx)
        assert idx.freq == exp_idx.freq

            

Reported by Pylint.

Instance of 'TimedeltaIndex' has no 'freq' member
Error

Line: 26 Column: 28

                      arr, idx = idx1.factorize(sort=True)
        tm.assert_numpy_array_equal(arr, exp_arr)
        tm.assert_index_equal(idx, exp_idx)
        assert idx.freq == exp_idx.freq

    def test_factorize_preserves_freq(self):
        # GH#38120 freq should be preserved
        idx3 = timedelta_range("1 day", periods=4, freq="s")
        exp_arr = np.array([0, 1, 2, 3], dtype=np.intp)

            

Reported by Pylint.

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

Line: 35 Column: 28

                      arr, idx = idx3.factorize()
        tm.assert_numpy_array_equal(arr, exp_arr)
        tm.assert_index_equal(idx, idx3)
        assert idx.freq == idx3.freq

        arr, idx = factorize(idx3)
        tm.assert_numpy_array_equal(arr, exp_arr)
        tm.assert_index_equal(idx, idx3)
        assert idx.freq == idx3.freq

            

Reported by Pylint.

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

Line: 35 Column: 28

                      arr, idx = idx3.factorize()
        tm.assert_numpy_array_equal(arr, exp_arr)
        tm.assert_index_equal(idx, idx3)
        assert idx.freq == idx3.freq

        arr, idx = factorize(idx3)
        tm.assert_numpy_array_equal(arr, exp_arr)
        tm.assert_index_equal(idx, idx3)
        assert idx.freq == idx3.freq

            

Reported by Pylint.

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

Line: 40 Column: 28

                      arr, idx = factorize(idx3)
        tm.assert_numpy_array_equal(arr, exp_arr)
        tm.assert_index_equal(idx, idx3)
        assert idx.freq == idx3.freq

            

Reported by Pylint.

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

Line: 40 Column: 28

                      arr, idx = factorize(idx3)
        tm.assert_numpy_array_equal(arr, exp_arr)
        tm.assert_index_equal(idx, idx3)
        assert idx.freq == idx3.freq

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np

from pandas import (
    TimedeltaIndex,
    factorize,
    timedelta_range,
)
import pandas._testing as tm


            

Reported by Pylint.

Missing class docstring
Error

Line: 11 Column: 1

              import pandas._testing as tm


class TestTimedeltaIndexFactorize:
    def test_factorize(self):
        idx1 = TimedeltaIndex(["1 day", "1 day", "2 day", "2 day", "3 day", "3 day"])

        exp_arr = np.array([0, 0, 1, 1, 2, 2], dtype=np.intp)
        exp_idx = TimedeltaIndex(["1 day", "2 day", "3 day"])

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 12 Column: 5

              

class TestTimedeltaIndexFactorize:
    def test_factorize(self):
        idx1 = TimedeltaIndex(["1 day", "1 day", "2 day", "2 day", "3 day", "3 day"])

        exp_arr = np.array([0, 0, 1, 1, 2, 2], dtype=np.intp)
        exp_idx = TimedeltaIndex(["1 day", "2 day", "3 day"])


            

Reported by Pylint.

Method could be a function
Error

Line: 12 Column: 5

              

class TestTimedeltaIndexFactorize:
    def test_factorize(self):
        idx1 = TimedeltaIndex(["1 day", "1 day", "2 day", "2 day", "3 day", "3 day"])

        exp_arr = np.array([0, 0, 1, 1, 2, 2], dtype=np.intp)
        exp_idx = TimedeltaIndex(["1 day", "2 day", "3 day"])


            

Reported by Pylint.

pandas/tests/util/test_doc.py
16 issues
Unused argument 'whatever'
Error

Line: 7 Column: 12

              

@doc(method="cumsum", operation="sum")
def cumsum(whatever):
    """
    This is the {method} method.

    It computes the cumulative {operation}.
    """

            

Reported by Pylint.

Unused argument 'whatever'
Error

Line: 29 Column: 12

                  method="cumavg",
    operation="average",
)
def cumavg(whatever):
    pass


@doc(cumsum, method="cummax", operation="maximum")
def cummax(whatever):

            

Reported by Pylint.

Unused argument 'whatever'
Error

Line: 34 Column: 12

              

@doc(cumsum, method="cummax", operation="maximum")
def cummax(whatever):
    pass


@doc(cummax, method="cummin", operation="minimum")
def cummin(whatever):

            

Reported by Pylint.

Unused argument 'whatever'
Error

Line: 39 Column: 12

              

@doc(cummax, method="cummin", operation="minimum")
def cummin(whatever):
    pass


def test_docstring_formatting():
    docstr = dedent(

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from textwrap import dedent

from pandas.util._decorators import doc


@doc(method="cumsum", operation="sum")
def cumsum(whatever):
    """
    This is the {method} method.

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 28 Column: 1

                  ),
    method="cumavg",
    operation="average",
)
def cumavg(whatever):
    pass


@doc(cumsum, method="cummax", operation="maximum")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 34 Column: 1

              

@doc(cumsum, method="cummax", operation="maximum")
def cummax(whatever):
    pass


@doc(cummax, method="cummin", operation="minimum")
def cummin(whatever):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 39 Column: 1

              

@doc(cummax, method="cummin", operation="minimum")
def cummin(whatever):
    pass


def test_docstring_formatting():
    docstr = dedent(

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 43 Column: 1

                  pass


def test_docstring_formatting():
    docstr = dedent(
        """
        This is the cumsum method.

        It computes the cumulative sum.

            

Reported by Pylint.

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

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

                      It computes the cumulative sum.
        """
    )
    assert cumsum.__doc__ == docstr


def test_docstring_appending():
    docstr = dedent(
        """

            

Reported by Bandit.

pandas/tests/series/methods/test_between.py
16 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

from pandas import (
    Series,
    bdate_range,
    date_range,
    period_range,
)

            

Reported by Pylint.

TODO: redundant with test_between_datetime_values?
Error

Line: 15 Column: 3

              
class TestBetween:

    # TODO: redundant with test_between_datetime_values?
    def test_between(self):
        series = Series(date_range("1/1/2000", periods=10))
        left, right = series[[2, 7]]

        result = series.between(left, right)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

from pandas import (
    Series,
    bdate_range,
    date_range,
    period_range,
)

            

Reported by Pylint.

Missing class docstring
Error

Line: 13 Column: 1

              import pandas._testing as tm


class TestBetween:

    # TODO: redundant with test_between_datetime_values?
    def test_between(self):
        series = Series(date_range("1/1/2000", periods=10))
        left, right = series[[2, 7]]

            

Reported by Pylint.

Method could be a function
Error

Line: 16 Column: 5

              class TestBetween:

    # TODO: redundant with test_between_datetime_values?
    def test_between(self):
        series = Series(date_range("1/1/2000", periods=10))
        left, right = series[[2, 7]]

        result = series.between(left, right)
        expected = (series >= left) & (series <= right)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 16 Column: 5

              class TestBetween:

    # TODO: redundant with test_between_datetime_values?
    def test_between(self):
        series = Series(date_range("1/1/2000", periods=10))
        left, right = series[[2, 7]]

        result = series.between(left, right)
        expected = (series >= left) & (series <= right)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 24 Column: 5

                      expected = (series >= left) & (series <= right)
        tm.assert_series_equal(result, expected)

    def test_between_datetime_values(self):
        ser = Series(bdate_range("1/1/2000", periods=20).astype(object))
        ser[::2] = np.nan

        result = ser[ser.between(ser[3], ser[17])]
        expected = ser[3:18].dropna()

            

Reported by Pylint.

Method could be a function
Error

Line: 24 Column: 5

                      expected = (series >= left) & (series <= right)
        tm.assert_series_equal(result, expected)

    def test_between_datetime_values(self):
        ser = Series(bdate_range("1/1/2000", periods=20).astype(object))
        ser[::2] = np.nan

        result = ser[ser.between(ser[3], ser[17])]
        expected = ser[3:18].dropna()

            

Reported by Pylint.

Method could be a function
Error

Line: 36 Column: 5

                      expected = ser[5:16].dropna()
        tm.assert_series_equal(result, expected)

    def test_between_period_values(self):
        ser = Series(period_range("2000-01-01", periods=10, freq="D"))
        left, right = ser[[2, 7]]
        result = ser.between(left, right)
        expected = (ser >= left) & (ser <= right)
        tm.assert_series_equal(result, expected)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 36 Column: 5

                      expected = ser[5:16].dropna()
        tm.assert_series_equal(result, expected)

    def test_between_period_values(self):
        ser = Series(period_range("2000-01-01", periods=10, freq="D"))
        left, right = ser[[2, 7]]
        result = ser.between(left, right)
        expected = (ser >= left) & (ser <= right)
        tm.assert_series_equal(result, expected)

            

Reported by Pylint.