The following issues were found

pandas/tests/tseries/offsets/test_index.py
8 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              """
Tests for offset behavior with indices.
"""
import pytest

from pandas import (
    Series,
    date_range,
)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 43 Column: 1

                      YearEnd,
        BYearBegin,
        BYearEnd,
    ],
)
def test_apply_index(cls, n):
    offset = cls(n=n)
    rng = date_range(start="1/1/2000", periods=100000, freq="T")
    ser = Series(rng)

            

Reported by Pylint.

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

Line: 43 Column: 1

                      YearEnd,
        BYearBegin,
        BYearEnd,
    ],
)
def test_apply_index(cls, n):
    offset = cls(n=n)
    rng = date_range(start="1/1/2000", periods=100000, freq="T")
    ser = Series(rng)

            

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

                  ser = Series(rng)

    res = rng + offset
    assert res.freq is None  # not retained
    assert res[0] == rng[0] + offset
    assert res[-1] == rng[-1] + offset
    res2 = ser + offset
    # apply_index is only for indexes, not series, so no res2_v2
    assert res2.iloc[0] == ser.iloc[0] + offset

            

Reported by Bandit.

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

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

              
    res = rng + offset
    assert res.freq is None  # not retained
    assert res[0] == rng[0] + offset
    assert res[-1] == rng[-1] + offset
    res2 = ser + offset
    # apply_index is only for indexes, not series, so no res2_v2
    assert res2.iloc[0] == ser.iloc[0] + offset
    assert res2.iloc[-1] == ser.iloc[-1] + offset

            

Reported by Bandit.

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

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

                  res = rng + offset
    assert res.freq is None  # not retained
    assert res[0] == rng[0] + offset
    assert res[-1] == rng[-1] + offset
    res2 = ser + offset
    # apply_index is only for indexes, not series, so no res2_v2
    assert res2.iloc[0] == ser.iloc[0] + offset
    assert res2.iloc[-1] == ser.iloc[-1] + offset

            

Reported by Bandit.

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

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

                  assert res[-1] == rng[-1] + offset
    res2 = ser + offset
    # apply_index is only for indexes, not series, so no res2_v2
    assert res2.iloc[0] == ser.iloc[0] + offset
    assert res2.iloc[-1] == ser.iloc[-1] + offset

            

Reported by Bandit.

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

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

                  res2 = ser + offset
    # apply_index is only for indexes, not series, so no res2_v2
    assert res2.iloc[0] == ser.iloc[0] + offset
    assert res2.iloc[-1] == ser.iloc[-1] + offset

            

Reported by Bandit.

pandas/tests/indexes/timedeltas/test_searchsorted.py
8 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

from pandas import (
    Series,
    TimedeltaIndex,
    Timestamp,
    array,
)

            

Reported by Pylint.

Access to a protected member _data of a client class
Error

Line: 21 Column: 18

                      expected = np.arange(len(idx), dtype=result.dtype)
        tm.assert_numpy_array_equal(result, expected)

        result = idx._data.searchsorted(klass(idx))
        tm.assert_numpy_array_equal(result, expected)

    @pytest.mark.parametrize(
        "arg", [[1, 2], ["a", "b"], [Timestamp("2020-01-01", tz="Europe/London")] * 2]
    )

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

from pandas import (
    Series,
    TimedeltaIndex,
    Timestamp,
    array,
)

            

Reported by Pylint.

Missing class docstring
Error

Line: 13 Column: 1

              import pandas._testing as tm


class TestSearchSorted:
    @pytest.mark.parametrize("klass", [list, np.array, array, Series])
    def test_searchsorted_different_argument_classes(self, klass):
        idx = TimedeltaIndex(["1 day", "2 days", "3 days"])
        result = idx.searchsorted(klass(idx))
        expected = np.arange(len(idx), dtype=result.dtype)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 15 Column: 5

              
class TestSearchSorted:
    @pytest.mark.parametrize("klass", [list, np.array, array, Series])
    def test_searchsorted_different_argument_classes(self, klass):
        idx = TimedeltaIndex(["1 day", "2 days", "3 days"])
        result = idx.searchsorted(klass(idx))
        expected = np.arange(len(idx), dtype=result.dtype)
        tm.assert_numpy_array_equal(result, expected)


            

Reported by Pylint.

Method could be a function
Error

Line: 15 Column: 5

              
class TestSearchSorted:
    @pytest.mark.parametrize("klass", [list, np.array, array, Series])
    def test_searchsorted_different_argument_classes(self, klass):
        idx = TimedeltaIndex(["1 day", "2 days", "3 days"])
        result = idx.searchsorted(klass(idx))
        expected = np.arange(len(idx), dtype=result.dtype)
        tm.assert_numpy_array_equal(result, expected)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 26 Column: 5

              
    @pytest.mark.parametrize(
        "arg", [[1, 2], ["a", "b"], [Timestamp("2020-01-01", tz="Europe/London")] * 2]
    )
    def test_searchsorted_invalid_argument_dtype(self, arg):
        idx = TimedeltaIndex(["1 day", "2 days", "3 days"])
        msg = "value should be a 'Timedelta', 'NaT', or array of those. Got"
        with pytest.raises(TypeError, match=msg):
            idx.searchsorted(arg)

            

Reported by Pylint.

Method could be a function
Error

Line: 26 Column: 5

              
    @pytest.mark.parametrize(
        "arg", [[1, 2], ["a", "b"], [Timestamp("2020-01-01", tz="Europe/London")] * 2]
    )
    def test_searchsorted_invalid_argument_dtype(self, arg):
        idx = TimedeltaIndex(["1 day", "2 days", "3 days"])
        msg = "value should be a 'Timedelta', 'NaT', or array of those. Got"
        with pytest.raises(TypeError, match=msg):
            idx.searchsorted(arg)

            

Reported by Pylint.

pandas/tests/indexing/multiindex/test_datetime.py
8 issues
Missing module docstring
Error

Line: 1 Column: 1

              from datetime import datetime

import numpy as np

from pandas import (
    DataFrame,
    Index,
    MultiIndex,
    Period,

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 1

              import pandas._testing as tm


def test_multiindex_period_datetime():
    # GH4861, using datetime in period of multiindex raises exception

    idx1 = Index(["a", "a", "a", "b", "b"])
    idx2 = period_range("2012-01", periods=len(idx1), freq="M")
    s = Series(np.random.randn(len(idx1)), [idx1, idx2])

            

Reported by Pylint.

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

Line: 22 Column: 5

              
    idx1 = Index(["a", "a", "a", "b", "b"])
    idx2 = period_range("2012-01", periods=len(idx1), freq="M")
    s = Series(np.random.randn(len(idx1)), [idx1, idx2])

    # try Period as index
    expected = s.iloc[0]
    result = s.loc["a", Period("2012-01")]
    assert result == expected

            

Reported by Pylint.

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

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

                  # try Period as index
    expected = s.iloc[0]
    result = s.loc["a", Period("2012-01")]
    assert result == expected

    # try datetime as index
    result = s.loc["a", datetime(2012, 1, 1)]
    assert result == expected


            

Reported by Bandit.

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

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

              
    # try datetime as index
    result = s.loc["a", datetime(2012, 1, 1)]
    assert result == expected


def test_multiindex_datetime_columns():
    # GH35015, using datetime as column indices raises exception


            

Reported by Bandit.

Missing function or method docstring
Error

Line: 34 Column: 1

                  assert result == expected


def test_multiindex_datetime_columns():
    # GH35015, using datetime as column indices raises exception

    mi = MultiIndex.from_tuples(
        [(to_datetime("02/29/2020"), to_datetime("03/01/2020"))], names=["a", "b"]
    )

            

Reported by Pylint.

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

Line: 37 Column: 5

              def test_multiindex_datetime_columns():
    # GH35015, using datetime as column indices raises exception

    mi = MultiIndex.from_tuples(
        [(to_datetime("02/29/2020"), to_datetime("03/01/2020"))], names=["a", "b"]
    )

    df = DataFrame([], columns=mi)


            

Reported by Pylint.

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

Line: 41 Column: 5

                      [(to_datetime("02/29/2020"), to_datetime("03/01/2020"))], names=["a", "b"]
    )

    df = DataFrame([], columns=mi)

    expected_df = DataFrame(
        [],
        columns=MultiIndex.from_arrays(
            [[to_datetime("02/29/2020")], [to_datetime("03/01/2020")]], names=["a", "b"]

            

Reported by Pylint.

pandas/tests/util/test_assert_attr_equal.py
8 issues
Unable to import 'pytest'
Error

Line: 3 Column: 1

              from types import SimpleNamespace

import pytest

from pandas.core.dtypes.common import is_float

import pandas._testing as tm



            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from types import SimpleNamespace

import pytest

from pandas.core.dtypes.common import is_float

import pandas._testing as tm



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 1

              import pandas._testing as tm


def test_assert_attr_equal(nulls_fixture):
    obj = SimpleNamespace()
    obj.na_value = nulls_fixture
    assert tm.assert_attr_equal("na_value", obj, obj)



            

Reported by Pylint.

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

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

              def test_assert_attr_equal(nulls_fixture):
    obj = SimpleNamespace()
    obj.na_value = nulls_fixture
    assert tm.assert_attr_equal("na_value", obj, obj)


def test_assert_attr_equal_different_nulls(nulls_fixture, nulls_fixture2):
    obj = SimpleNamespace()
    obj.na_value = nulls_fixture

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 16 Column: 1

                  assert tm.assert_attr_equal("na_value", obj, obj)


def test_assert_attr_equal_different_nulls(nulls_fixture, nulls_fixture2):
    obj = SimpleNamespace()
    obj.na_value = nulls_fixture

    obj2 = SimpleNamespace()
    obj2.na_value = nulls_fixture2

            

Reported by Pylint.

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

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

                  obj2.na_value = nulls_fixture2

    if nulls_fixture is nulls_fixture2:
        assert tm.assert_attr_equal("na_value", obj, obj2)
    elif is_float(nulls_fixture) and is_float(nulls_fixture2):
        # we consider float("nan") and np.float64("nan") to be equivalent
        assert tm.assert_attr_equal("na_value", obj, obj2)
    elif type(nulls_fixture) is type(nulls_fixture2):
        # e.g. Decimal("NaN")

            

Reported by Bandit.

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

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

                      assert tm.assert_attr_equal("na_value", obj, obj2)
    elif is_float(nulls_fixture) and is_float(nulls_fixture2):
        # we consider float("nan") and np.float64("nan") to be equivalent
        assert tm.assert_attr_equal("na_value", obj, obj2)
    elif type(nulls_fixture) is type(nulls_fixture2):
        # e.g. Decimal("NaN")
        assert tm.assert_attr_equal("na_value", obj, obj2)
    else:
        with pytest.raises(AssertionError, match='"na_value" are different'):

            

Reported by Bandit.

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

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

                      assert tm.assert_attr_equal("na_value", obj, obj2)
    elif type(nulls_fixture) is type(nulls_fixture2):
        # e.g. Decimal("NaN")
        assert tm.assert_attr_equal("na_value", obj, obj2)
    else:
        with pytest.raises(AssertionError, match='"na_value" are different'):
            tm.assert_attr_equal("na_value", obj, obj2)

            

Reported by Bandit.

pandas/tests/reshape/merge/test_merge_cross.py
8 issues
Unable to import 'pytest'
Error

Line: 1 Column: 1

              import pytest

from pandas import DataFrame
import pandas._testing as tm
from pandas.core.reshape.merge import (
    MergeError,
    merge,
)


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import pytest

from pandas import DataFrame
import pandas._testing as tm
from pandas.core.reshape.merge import (
    MergeError,
    merge,
)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 1

              
@pytest.mark.parametrize(
    ("input_col", "output_cols"), [("b", ["a", "b"]), ("a", ["a_x", "a_y"])]
)
def test_merge_cross(input_col, output_cols):
    # GH#5401
    left = DataFrame({"a": [1, 3]})
    right = DataFrame({input_col: [3, 4]})
    left_copy = left.copy()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 35 Column: 1

                      {"on": "a"},
        {"left_on": "a"},
        {"right_on": "b"},
    ],
)
def test_merge_cross_error_reporting(kwargs):
    # GH#5401
    left = DataFrame({"a": [1, 3]})
    right = DataFrame({"b": [3, 4]})

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 49 Column: 1

                      merge(left, right, how="cross", **kwargs)


def test_merge_cross_mixed_dtypes():
    # GH#5401
    left = DataFrame(["a", "b", "c"], columns=["A"])
    right = DataFrame(range(2), columns=["B"])
    result = merge(left, right, how="cross")
    expected = DataFrame({"A": ["a", "a", "b", "b", "c", "c"], "B": [0, 1, 0, 1, 0, 1]})

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 58 Column: 1

                  tm.assert_frame_equal(result, expected)


def test_merge_cross_more_than_one_column():
    # GH#5401
    left = DataFrame({"A": list("ab"), "B": [2, 1]})
    right = DataFrame({"C": range(2), "D": range(4, 6)})
    result = merge(left, right, how="cross")
    expected = DataFrame(

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 74 Column: 1

                  tm.assert_frame_equal(result, expected)


def test_merge_cross_null_values(nulls_fixture):
    # GH#5401
    left = DataFrame({"a": [1, nulls_fixture]})
    right = DataFrame({"b": ["a", "b"], "c": [1.0, 2.0]})
    result = merge(left, right, how="cross")
    expected = DataFrame(

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 89 Column: 1

                  tm.assert_frame_equal(result, expected)


def test_join_cross_error_reporting():
    # GH#5401
    left = DataFrame({"a": [1, 3]})
    right = DataFrame({"a": [3, 4]})
    msg = (
        "Can not pass on, right_on, left_on or set right_index=True or "

            

Reported by Pylint.

pandas/tests/util/test_assert_extension_array_equal.py
8 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

from pandas import array
import pandas._testing as tm
from pandas.core.arrays.sparse import SparseArray


@pytest.mark.parametrize(

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

from pandas import array
import pandas._testing as tm
from pandas.core.arrays.sparse import SparseArray


@pytest.mark.parametrize(

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 15 Column: 1

                      {},  # Default is check_exact=False
        {"check_exact": False},
        {"check_exact": True},
    ],
)
def test_assert_extension_array_equal_not_exact(kwargs):
    # see gh-23709
    arr1 = SparseArray([-0.17387645482451206, 0.3414148016424936])
    arr2 = SparseArray([-0.17387645482451206, 0.3414148016424937])

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 37 Column: 1

              

@pytest.mark.parametrize("decimals", range(10))
def test_assert_extension_array_equal_less_precise(decimals):
    rtol = 0.5 * 10 ** -decimals
    arr1 = SparseArray([0.5, 0.123456])
    arr2 = SparseArray([0.5, 0.123457])

    if decimals >= 5:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 56 Column: 1

                      tm.assert_extension_array_equal(arr1, arr2, rtol=rtol)


def test_assert_extension_array_equal_dtype_mismatch(check_dtype):
    end = 5
    kwargs = {"check_dtype": check_dtype}

    arr1 = SparseArray(np.arange(end, dtype="int64"))
    arr2 = SparseArray(np.arange(end, dtype="int32"))

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 77 Column: 1

                      tm.assert_extension_array_equal(arr1, arr2, **kwargs)


def test_assert_extension_array_equal_missing_values():
    arr1 = SparseArray([np.nan, 1, 2, np.nan])
    arr2 = SparseArray([np.nan, 1, 2, 3])

    msg = """\
ExtensionArray NA mask are different

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 93 Column: 1

              

@pytest.mark.parametrize("side", ["left", "right"])
def test_assert_extension_array_equal_non_extension_array(side):
    numpy_array = np.arange(5)
    extension_array = SparseArray(numpy_array)

    msg = f"{side} is not an ExtensionArray"
    args = (

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 109 Column: 1

              

@pytest.mark.parametrize("right_dtype", ["Int32", "int64"])
def test_assert_extension_array_equal_ignore_dtype_mismatch(right_dtype):
    # https://github.com/pandas-dev/pandas/issues/35715
    left = array([1, 2, 3], dtype="Int64")
    right = array([1, 2, 3], dtype=right_dtype)
    tm.assert_extension_array_equal(left, right, check_dtype=False)

            

Reported by Pylint.

pandas/tests/indexing/test_iat.py
8 issues
Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np

from pandas import (
    DataFrame,
    Series,
    period_range,
)



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 1

              )


def test_iat(float_frame):

    for i, row in enumerate(float_frame.index):
        for j, col in enumerate(float_frame.columns):
            result = float_frame.iat[i, j]
            expected = float_frame.at[row, col]

            

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

                      for j, col in enumerate(float_frame.columns):
            result = float_frame.iat[i, j]
            expected = float_frame.at[row, col]
            assert result == expected


def test_iat_duplicate_columns():
    # https://github.com/pandas-dev/pandas/issues/11754
    df = DataFrame([[1, 2]], columns=["x", "x"])

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 19 Column: 1

                          assert result == expected


def test_iat_duplicate_columns():
    # https://github.com/pandas-dev/pandas/issues/11754
    df = DataFrame([[1, 2]], columns=["x", "x"])
    assert df.iat[0, 0] == 1



            

Reported by Pylint.

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

Line: 21 Column: 5

              
def test_iat_duplicate_columns():
    # https://github.com/pandas-dev/pandas/issues/11754
    df = DataFrame([[1, 2]], columns=["x", "x"])
    assert df.iat[0, 0] == 1


def test_iat_getitem_series_with_period_index():
    # GH#4390, iat incorrectly indexing

            

Reported by Pylint.

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

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

              def test_iat_duplicate_columns():
    # https://github.com/pandas-dev/pandas/issues/11754
    df = DataFrame([[1, 2]], columns=["x", "x"])
    assert df.iat[0, 0] == 1


def test_iat_getitem_series_with_period_index():
    # GH#4390, iat incorrectly indexing
    index = period_range("1/1/2001", periods=10)

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 25 Column: 1

                  assert df.iat[0, 0] == 1


def test_iat_getitem_series_with_period_index():
    # GH#4390, iat incorrectly indexing
    index = period_range("1/1/2001", periods=10)
    ser = Series(np.random.randn(10), index=index)
    expected = ser[index[0]]
    result = ser.iat[0]

            

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

                  ser = Series(np.random.randn(10), index=index)
    expected = ser[index[0]]
    result = ser.iat[0]
    assert expected == result

            

Reported by Bandit.

pandas/tests/indexes/multi/test_take.py
8 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

import pandas as pd
import pandas._testing as tm


def test_take(idx):
    indexer = [4, 3, 0, 2]

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 17 Column: 9

                  # GH 10791
    msg = "'MultiIndex' object has no attribute 'freq'"
    with pytest.raises(AttributeError, match=msg):
        idx.freq


def test_take_invalid_kwargs(idx):
    idx = idx
    indices = [1, 2]

            

Reported by Pylint.

Assigning the same variable 'idx' to itself
Error

Line: 21 Column: 5

              

def test_take_invalid_kwargs(idx):
    idx = idx
    indices = [1, 2]

    msg = r"take\(\) got an unexpected keyword argument 'foo'"
    with pytest.raises(TypeError, match=msg):
        idx.take(indices, foo=2)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

import pandas as pd
import pandas._testing as tm


def test_take(idx):
    indexer = [4, 3, 0, 2]

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 8 Column: 1

              import pandas._testing as tm


def test_take(idx):
    indexer = [4, 3, 0, 2]
    result = idx.take(indexer)
    expected = idx[indexer]
    assert result.equals(expected)


            

Reported by Pylint.

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

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

                  indexer = [4, 3, 0, 2]
    result = idx.take(indexer)
    expected = idx[indexer]
    assert result.equals(expected)

    # GH 10791
    msg = "'MultiIndex' object has no attribute 'freq'"
    with pytest.raises(AttributeError, match=msg):
        idx.freq

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 20 Column: 1

                      idx.freq


def test_take_invalid_kwargs(idx):
    idx = idx
    indices = [1, 2]

    msg = r"take\(\) got an unexpected keyword argument 'foo'"
    with pytest.raises(TypeError, match=msg):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 37 Column: 1

                      idx.take(indices, mode="clip")


def test_take_fill_value():
    # GH 12631
    vals = [["A", "B"], [pd.Timestamp("2011-01-01"), pd.Timestamp("2011-01-02")]]
    idx = pd.MultiIndex.from_product(vals, names=["str", "dt"])

    result = idx.take(np.array([1, 0, -1]))

            

Reported by Pylint.

pandas/tests/io/sas/test_sas.py
8 issues
Unable to import 'pytest'
Error

Line: 3 Column: 1

              from io import StringIO

import pytest

from pandas import read_sas
import pandas._testing as tm


class TestSas:

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from io import StringIO

import pytest

from pandas import read_sas
import pandas._testing as tm


class TestSas:

            

Reported by Pylint.

Missing class docstring
Error

Line: 9 Column: 1

              import pandas._testing as tm


class TestSas:
    def test_sas_buffer_format(self):
        # see gh-14947
        b = StringIO("")

        msg = (

            

Reported by Pylint.

Method could be a function
Error

Line: 10 Column: 5

              

class TestSas:
    def test_sas_buffer_format(self):
        # see gh-14947
        b = StringIO("")

        msg = (
            "If this is a buffer object rather than a string "

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 5

              

class TestSas:
    def test_sas_buffer_format(self):
        # see gh-14947
        b = StringIO("")

        msg = (
            "If this is a buffer object rather than a string "

            

Reported by Pylint.

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

Line: 12 Column: 9

              class TestSas:
    def test_sas_buffer_format(self):
        # see gh-14947
        b = StringIO("")

        msg = (
            "If this is a buffer object rather than a string "
            "name, you must specify a format string"
        )

            

Reported by Pylint.

Method could be a function
Error

Line: 21 Column: 5

                      with pytest.raises(ValueError, match=msg):
            read_sas(b)

    def test_sas_read_no_format_or_extension(self):
        # see gh-24548
        msg = "unable to infer format of SAS file"
        with tm.ensure_clean("test_file_no_extension") as path:
            with pytest.raises(ValueError, match=msg):
                read_sas(path)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 21 Column: 5

                      with pytest.raises(ValueError, match=msg):
            read_sas(b)

    def test_sas_read_no_format_or_extension(self):
        # see gh-24548
        msg = "unable to infer format of SAS file"
        with tm.ensure_clean("test_file_no_extension") as path:
            with pytest.raises(ValueError, match=msg):
                read_sas(path)

            

Reported by Pylint.

pandas/tests/scalar/timedelta/test_formats.py
8 issues
Unable to import 'pytest'
Error

Line: 1 Column: 1

              import pytest

from pandas import Timedelta


@pytest.mark.parametrize(
    "td, expected_repr",
    [
        (Timedelta(10, unit="d"), "Timedelta('10 days 00:00:00')"),

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import pytest

from pandas import Timedelta


@pytest.mark.parametrize(
    "td, expected_repr",
    [
        (Timedelta(10, unit="d"), "Timedelta('10 days 00:00:00')"),

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 1

                      (Timedelta(10, unit="s"), "Timedelta('0 days 00:00:10')"),
        (Timedelta(10, unit="ms"), "Timedelta('0 days 00:00:00.010000')"),
        (Timedelta(-10, unit="ms"), "Timedelta('-1 days +23:59:59.990000')"),
    ],
)
def test_repr(td, expected_repr):
    assert repr(td) == expected_repr



            

Reported by Pylint.

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

Line: 13 Column: 1

                      (Timedelta(10, unit="s"), "Timedelta('0 days 00:00:10')"),
        (Timedelta(10, unit="ms"), "Timedelta('0 days 00:00:00.010000')"),
        (Timedelta(-10, unit="ms"), "Timedelta('-1 days +23:59:59.990000')"),
    ],
)
def test_repr(td, expected_repr):
    assert repr(td) == expected_repr



            

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

                  ],
)
def test_repr(td, expected_repr):
    assert repr(td) == expected_repr


@pytest.mark.parametrize(
    "td, expected_iso",
    [

            

Reported by Bandit.

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

Line: 41 Column: 1

                      (Timedelta(milliseconds=1), "P0DT0H0M0.001S"),
        # don't strip every 0
        (Timedelta(minutes=1), "P0DT0H1M0S"),
    ],
)
def test_isoformat(td, expected_iso):
    assert td.isoformat() == expected_iso

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 41 Column: 1

                      (Timedelta(milliseconds=1), "P0DT0H0M0.001S"),
        # don't strip every 0
        (Timedelta(minutes=1), "P0DT0H1M0S"),
    ],
)
def test_isoformat(td, expected_iso):
    assert td.isoformat() == expected_iso

            

Reported by Pylint.

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

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

                  ],
)
def test_isoformat(td, expected_iso):
    assert td.isoformat() == expected_iso

            

Reported by Bandit.