The following issues were found

pandas/tests/series/methods/test_rename_axis.py
14 issues
Unable to import 'pytest'
Error

Line: 1 Column: 1

              import pytest

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


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import pytest

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


            

Reported by Pylint.

Missing class docstring
Error

Line: 11 Column: 1

              import pandas._testing as tm


class TestSeriesRenameAxis:
    def test_rename_axis_mapper(self):
        # GH 19978
        mi = MultiIndex.from_product([["a", "b", "c"], [1, 2]], names=["ll", "nn"])
        ser = Series(list(range(len(mi))), index=mi)


            

Reported by Pylint.

Method could be a function
Error

Line: 12 Column: 5

              

class TestSeriesRenameAxis:
    def test_rename_axis_mapper(self):
        # GH 19978
        mi = MultiIndex.from_product([["a", "b", "c"], [1, 2]], names=["ll", "nn"])
        ser = Series(list(range(len(mi))), index=mi)

        result = ser.rename_axis(index={"ll": "foo"})

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 12 Column: 5

              

class TestSeriesRenameAxis:
    def test_rename_axis_mapper(self):
        # GH 19978
        mi = MultiIndex.from_product([["a", "b", "c"], [1, 2]], names=["ll", "nn"])
        ser = Series(list(range(len(mi))), index=mi)

        result = ser.rename_axis(index={"ll": "foo"})

            

Reported by Pylint.

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

Line: 14 Column: 9

              class TestSeriesRenameAxis:
    def test_rename_axis_mapper(self):
        # GH 19978
        mi = MultiIndex.from_product([["a", "b", "c"], [1, 2]], names=["ll", "nn"])
        ser = Series(list(range(len(mi))), index=mi)

        result = ser.rename_axis(index={"ll": "foo"})
        assert result.index.names == ["foo", "nn"]


            

Reported by Pylint.

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

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

                      ser = Series(list(range(len(mi))), index=mi)

        result = ser.rename_axis(index={"ll": "foo"})
        assert result.index.names == ["foo", "nn"]

        result = ser.rename_axis(index=str.upper, axis=0)
        assert result.index.names == ["LL", "NN"]

        result = ser.rename_axis(index=["foo", "goo"])

            

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

                      assert result.index.names == ["foo", "nn"]

        result = ser.rename_axis(index=str.upper, axis=0)
        assert result.index.names == ["LL", "NN"]

        result = ser.rename_axis(index=["foo", "goo"])
        assert result.index.names == ["foo", "goo"]

        with pytest.raises(TypeError, match="unexpected"):

            

Reported by Bandit.

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

                      assert result.index.names == ["LL", "NN"]

        result = ser.rename_axis(index=["foo", "goo"])
        assert result.index.names == ["foo", "goo"]

        with pytest.raises(TypeError, match="unexpected"):
            ser.rename_axis(columns="wrong")

    def test_rename_axis_inplace(self, datetime_series):

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 29 Column: 5

                      with pytest.raises(TypeError, match="unexpected"):
            ser.rename_axis(columns="wrong")

    def test_rename_axis_inplace(self, datetime_series):
        # GH 15704
        expected = datetime_series.rename_axis("foo")
        result = datetime_series
        no_return = result.rename_axis("foo", inplace=True)


            

Reported by Pylint.

pandas/util/_test_decorators.py
14 issues
Unable to import 'pytest'
Error

Line: 34 Column: 1

              import warnings

import numpy as np
import pytest

from pandas._config import get_option

from pandas.compat import (
    IS64,

            

Reported by Pylint.

TODO: return type, _pytest.mark.structures.MarkDecorator is not public
Error

Line: 125 Column: 3

                  )


# TODO: return type, _pytest.mark.structures.MarkDecorator is not public
# https://github.com/pytest-dev/pytest/issues/7469
def skip_if_installed(package: str):
    """
    Skip a test if a package is installed.


            

Reported by Pylint.

TODO: return type, _pytest.mark.structures.MarkDecorator is not public
Error

Line: 141 Column: 3

                  )


# TODO: return type, _pytest.mark.structures.MarkDecorator is not public
# https://github.com/pytest-dev/pytest/issues/7469
def skip_if_no(package: str, min_version: str | None = None):
    """
    Generic function to help skip tests when required packages are not
    present on the testing system.

            

Reported by Pylint.

TODO: return type, _pytest.mark.structures.MarkDecorator is not public
Error

Line: 205 Column: 3

              )


# TODO: return type, _pytest.mark.structures.MarkDecorator is not public
# https://github.com/pytest-dev/pytest/issues/7469
def skip_if_np_lt(ver_str: str, *args, reason: str | None = None):
    if reason is None:
        reason = f"NumPy {ver_str} or greater required"
    return pytest.mark.skipif(

            

Reported by Pylint.

Redefining name 'async_mark' from outer scope (line 278)
Error

Line: 281 Column: 9

              def async_mark():
    try:
        import_optional_dependency("pytest_asyncio")
        async_mark = pytest.mark.asyncio
    except ImportError:
        async_mark = pytest.mark.skip(reason="Missing dependency pytest-asyncio")

    return async_mark


            

Reported by Pylint.

Unnecessary "else" after "return"
Error

Line: 80 Column: 5

                      except ImportError:
            return False

    if not min_version:
        return mod
    else:
        import sys

        try:

            

Reported by Pylint.

Import outside toplevel (sys)
Error

Line: 83 Column: 9

                  if not min_version:
        return mod
    else:
        import sys

        try:
            version = getattr(sys.modules[mod_name], "__version__")
        except AttributeError:
            # xlrd uses a capitalized attribute name

            

Reported by Pylint.

Either all return statements in a function should return an expression, or none of them should.
Error

Line: 96 Column: 1

                  return False


def _skip_if_no_mpl():
    mod = safe_import("matplotlib")
    if mod:
        mod.use("Agg")
    else:
        return True

            

Reported by Pylint.

Either all return statements in a function should return an expression, or none of them should.
Error

Line: 104 Column: 1

                      return True


def _skip_if_has_locale():
    lang, _ = locale.getlocale()
    if lang is not None:
        return True



            

Reported by Pylint.

Either all return statements in a function should return an expression, or none of them should.
Error

Line: 110 Column: 1

                      return True


def _skip_if_not_us_locale():
    lang, _ = locale.getlocale()
    if lang != "en_US":
        return True



            

Reported by Pylint.

pandas/tests/reshape/concat/test_sort.py
14 issues
Missing module docstring
Error

Line: 1 Column: 1

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


class TestConcatSort:
    def test_concat_sorts_columns(self, sort):
        # GH-4588
        df1 = DataFrame({"a": [1, 2], "b": [1, 2]}, columns=["b", "a"])

            

Reported by Pylint.

Missing class docstring
Error

Line: 6 Column: 1

              import pandas._testing as tm


class TestConcatSort:
    def test_concat_sorts_columns(self, sort):
        # GH-4588
        df1 = DataFrame({"a": [1, 2], "b": [1, 2]}, columns=["b", "a"])
        df2 = DataFrame({"a": [3, 4], "c": [5, 6]})


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 7 Column: 5

              

class TestConcatSort:
    def test_concat_sorts_columns(self, sort):
        # GH-4588
        df1 = DataFrame({"a": [1, 2], "b": [1, 2]}, columns=["b", "a"])
        df2 = DataFrame({"a": [3, 4], "c": [5, 6]})

        # for sort=True/None

            

Reported by Pylint.

Method could be a function
Error

Line: 7 Column: 5

              

class TestConcatSort:
    def test_concat_sorts_columns(self, sort):
        # GH-4588
        df1 = DataFrame({"a": [1, 2], "b": [1, 2]}, columns=["b", "a"])
        df2 = DataFrame({"a": [3, 4], "c": [5, 6]})

        # for sort=True/None

            

Reported by Pylint.

Method could be a function
Error

Line: 26 Column: 5

                          result = pd.concat([df1, df2], ignore_index=True, sort=sort)
        tm.assert_frame_equal(result, expected)

    def test_concat_sorts_index(self, sort):
        df1 = DataFrame({"a": [1, 2, 3]}, index=["c", "a", "b"])
        df2 = DataFrame({"b": [1, 2]}, index=["a", "b"])

        # For True/None
        expected = DataFrame(

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 26 Column: 5

                          result = pd.concat([df1, df2], ignore_index=True, sort=sort)
        tm.assert_frame_equal(result, expected)

    def test_concat_sorts_index(self, sort):
        df1 = DataFrame({"a": [1, 2, 3]}, index=["c", "a", "b"])
        df2 = DataFrame({"b": [1, 2]}, index=["a", "b"])

        # For True/None
        expected = DataFrame(

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 44 Column: 5

                          result = pd.concat([df1, df2], axis=1, sort=sort)
        tm.assert_frame_equal(result, expected)

    def test_concat_inner_sort(self, sort):
        # https://github.com/pandas-dev/pandas/pull/20613
        df1 = DataFrame(
            {"a": [1, 2], "b": [1, 2], "c": [1, 2]}, columns=["b", "a", "c"]
        )
        df2 = DataFrame({"a": [1, 2], "b": [3, 4]}, index=[3, 4])

            

Reported by Pylint.

Method could be a function
Error

Line: 44 Column: 5

                          result = pd.concat([df1, df2], axis=1, sort=sort)
        tm.assert_frame_equal(result, expected)

    def test_concat_inner_sort(self, sort):
        # https://github.com/pandas-dev/pandas/pull/20613
        df1 = DataFrame(
            {"a": [1, 2], "b": [1, 2], "c": [1, 2]}, columns=["b", "a", "c"]
        )
        df2 = DataFrame({"a": [1, 2], "b": [3, 4]}, index=[3, 4])

            

Reported by Pylint.

Method could be a function
Error

Line: 61 Column: 5

                          expected = expected[["a", "b"]]
        tm.assert_frame_equal(result, expected)

    def test_concat_aligned_sort(self):
        # GH-4588
        df = DataFrame({"c": [1, 2], "b": [3, 4], "a": [5, 6]}, columns=["c", "b", "a"])
        result = pd.concat([df, df], sort=True, ignore_index=True)
        expected = DataFrame(
            {"a": [5, 6, 5, 6], "b": [3, 4, 3, 4], "c": [1, 2, 1, 2]},

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 61 Column: 5

                          expected = expected[["a", "b"]]
        tm.assert_frame_equal(result, expected)

    def test_concat_aligned_sort(self):
        # GH-4588
        df = DataFrame({"c": [1, 2], "b": [3, 4], "a": [5, 6]}, columns=["c", "b", "a"])
        result = pd.concat([df, df], sort=True, ignore_index=True)
        expected = DataFrame(
            {"a": [5, 6, 5, 6], "b": [3, 4, 3, 4], "c": [1, 2, 1, 2]},

            

Reported by Pylint.

pandas/tests/indexes/period/test_scalar_compat.py
14 issues
Instance of 'PeriodIndex' has no 'start_time' member
Error

Line: 16 Column: 31

                      # GH#17157
        index = period_range(freq="M", start="2016-01-01", end="2016-05-31")
        expected_index = date_range("2016-01-01", end="2016-05-31", freq="MS")
        tm.assert_index_equal(index.start_time, expected_index)

    def test_end_time(self):
        # GH#17157
        index = period_range(freq="M", start="2016-01-01", end="2016-05-31")
        expected_index = date_range("2016-01-01", end="2016-05-31", freq="M")

            

Reported by Pylint.

Instance of 'PeriodIndex' has no 'end_time' member
Error

Line: 23 Column: 31

                      index = period_range(freq="M", start="2016-01-01", end="2016-05-31")
        expected_index = date_range("2016-01-01", end="2016-05-31", freq="M")
        expected_index += Timedelta(1, "D") - Timedelta(1, "ns")
        tm.assert_index_equal(index.end_time, expected_index)

    def test_end_time_business_friday(self):
        # GH#34449
        pi = period_range("1990-01-05", freq="B", periods=1)
        result = pi.end_time

            

Reported by Pylint.

Instance of 'PeriodIndex' has no 'end_time' member
Error

Line: 28 Column: 18

                  def test_end_time_business_friday(self):
        # GH#34449
        pi = period_range("1990-01-05", freq="B", periods=1)
        result = pi.end_time

        dti = date_range("1990-01-05", freq="D", periods=1)._with_freq(None)
        expected = dti + Timedelta(days=1, nanoseconds=-1)
        tm.assert_index_equal(result, expected)

            

Reported by Pylint.

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

Line: 30 Column: 15

                      pi = period_range("1990-01-05", freq="B", periods=1)
        result = pi.end_time

        dti = date_range("1990-01-05", freq="D", periods=1)._with_freq(None)
        expected = dti + Timedelta(days=1, nanoseconds=-1)
        tm.assert_index_equal(result, expected)

            

Reported by Pylint.

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

Line: 30 Column: 15

                      pi = period_range("1990-01-05", freq="B", periods=1)
        result = pi.end_time

        dti = date_range("1990-01-05", freq="D", periods=1)._with_freq(None)
        expected = dti + Timedelta(days=1, nanoseconds=-1)
        tm.assert_index_equal(result, expected)

            

Reported by Pylint.

Access to a protected member _with_freq of a client class
Error

Line: 30 Column: 15

                      pi = period_range("1990-01-05", freq="B", periods=1)
        result = pi.end_time

        dti = date_range("1990-01-05", freq="D", periods=1)._with_freq(None)
        expected = dti + Timedelta(days=1, nanoseconds=-1)
        tm.assert_index_equal(result, expected)

            

Reported by Pylint.

Missing class docstring
Error

Line: 11 Column: 1

              import pandas._testing as tm


class TestPeriodIndexOps:
    def test_start_time(self):
        # GH#17157
        index = period_range(freq="M", start="2016-01-01", end="2016-05-31")
        expected_index = date_range("2016-01-01", end="2016-05-31", freq="MS")
        tm.assert_index_equal(index.start_time, expected_index)

            

Reported by Pylint.

Method could be a function
Error

Line: 12 Column: 5

              

class TestPeriodIndexOps:
    def test_start_time(self):
        # GH#17157
        index = period_range(freq="M", start="2016-01-01", end="2016-05-31")
        expected_index = date_range("2016-01-01", end="2016-05-31", freq="MS")
        tm.assert_index_equal(index.start_time, expected_index)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 12 Column: 5

              

class TestPeriodIndexOps:
    def test_start_time(self):
        # GH#17157
        index = period_range(freq="M", start="2016-01-01", end="2016-05-31")
        expected_index = date_range("2016-01-01", end="2016-05-31", freq="MS")
        tm.assert_index_equal(index.start_time, expected_index)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 18 Column: 5

                      expected_index = date_range("2016-01-01", end="2016-05-31", freq="MS")
        tm.assert_index_equal(index.start_time, expected_index)

    def test_end_time(self):
        # GH#17157
        index = period_range(freq="M", start="2016-01-01", end="2016-05-31")
        expected_index = date_range("2016-01-01", end="2016-05-31", freq="M")
        expected_index += Timedelta(1, "D") - Timedelta(1, "ns")
        tm.assert_index_equal(index.end_time, expected_index)

            

Reported by Pylint.

pandas/util/_validators.py
14 issues
TODO: Change to keyword-only args and remove all this
Error

Line: 288 Column: 3

                  ...                              'mapper', 'rename')
    {'columns': <function id>, 'index': <method 'upper' of 'str' objects>}
    """
    # TODO: Change to keyword-only args and remove all this

    out = {}
    # Goal: fill 'out' with index/columns-style arguments
    # like out = {'index': foo, 'columns': bar}


            

Reported by Pylint.

Access to a protected member _AXIS_TO_AXIS_NUMBER of a client class
Error

Line: 295 Column: 54

                  # like out = {'index': foo, 'columns': bar}

    # Start by validating for consistency
    if "axis" in kwargs and any(x in kwargs for x in data._AXIS_TO_AXIS_NUMBER):
        msg = "Cannot specify both 'axis' and any of 'index' or 'columns'."
        raise TypeError(msg)

    # First fill with explicit values provided by the user...
    if arg_name in kwargs:

            

Reported by Pylint.

Access to a protected member _get_axis_name of a client class
Error

Line: 305 Column: 16

                          msg = f"{method_name} got multiple values for argument '{arg_name}'"
            raise TypeError(msg)

        axis = data._get_axis_name(kwargs.get("axis", 0))
        out[axis] = kwargs[arg_name]

    # More user-provided arguments, now from kwargs
    for k, v in kwargs.items():
        try:

            

Reported by Pylint.

Access to a protected member _get_axis_name of a client class
Error

Line: 311 Column: 18

                  # More user-provided arguments, now from kwargs
    for k, v in kwargs.items():
        try:
            ax = data._get_axis_name(k)
        except ValueError:
            pass
        else:
            out[ax] = v


            

Reported by Pylint.

Access to a protected member _get_axis_name of a client class
Error

Line: 324 Column: 16

                  if len(args) == 0:
        pass  # It's up to the function to decide if this is valid
    elif len(args) == 1:
        axis = data._get_axis_name(kwargs.get("axis", 0))
        out[axis] = args[0]
    elif len(args) == 2:
        if "axis" in kwargs:
            # Unambiguously wrong
            msg = "Cannot specify both 'axis' and any of 'index' or 'columns'"

            

Reported by Pylint.

Access to a protected member _get_axis_name of a client class
Error

Line: 340 Column: 13

                          "a 'TypeError'."
        )
        warnings.warn(msg, FutureWarning, stacklevel=4)
        out[data._get_axis_name(0)] = args[0]
        out[data._get_axis_name(1)] = args[1]
    else:
        msg = f"Cannot specify all of '{arg_name}', 'index', 'columns'."
        raise TypeError(msg)
    return out

            

Reported by Pylint.

Access to a protected member _get_axis_name of a client class
Error

Line: 341 Column: 13

                      )
        warnings.warn(msg, FutureWarning, stacklevel=4)
        out[data._get_axis_name(0)] = args[0]
        out[data._get_axis_name(1)] = args[1]
    else:
        msg = f"Cannot specify all of '{arg_name}', 'index', 'columns'."
        raise TypeError(msg)
    return out


            

Reported by Pylint.

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

Line: 51 Column: 13

                      # as comparison may have been overridden for the left
        # hand object
        try:
            v1 = arg_val_dict[key]
            v2 = compat_args[key]

            # check for None-ness otherwise we could end up
            # comparing a numpy array vs None
            if (v1 is not None and v2 is None) or (v1 is None and v2 is not None):

            

Reported by Pylint.

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

Line: 52 Column: 13

                      # hand object
        try:
            v1 = arg_val_dict[key]
            v2 = compat_args[key]

            # check for None-ness otherwise we could end up
            # comparing a numpy array vs None
            if (v1 is not None and v2 is None) or (v1 is None and v2 is not None):
                match = False

            

Reported by Pylint.

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

Line: 309 Column: 12

                      out[axis] = kwargs[arg_name]

    # More user-provided arguments, now from kwargs
    for k, v in kwargs.items():
        try:
            ax = data._get_axis_name(k)
        except ValueError:
            pass
        else:

            

Reported by Pylint.

asv_bench/benchmarks/tslibs/normalize.py
14 issues
Unable to import 'pandas'
Error

Line: 12 Column: 1

                      is_date_array_normalized,
    )

import pandas as pd

from .tslib import (
    _sizes,
    _tzs,
    tzlocal_obj,

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 14 Column: 1

              
import pandas as pd

from .tslib import (
    _sizes,
    _tzs,
    tzlocal_obj,
)


            

Reported by Pylint.

Attribute 'i8data' defined outside __init__
Error

Line: 32 Column: 9

                      # use an array that will have is_date_array_normalized give True,
        #  so we do not short-circuit early.
        dti = pd.date_range("2016-01-01", periods=10, tz=tz).repeat(size // 10)
        self.i8data = dti.asi8

        if size == 10 ** 6 and tz is tzlocal_obj:
            # tzlocal is cumbersomely slow, so skip to keep runtime in check
            raise NotImplementedError


            

Reported by Pylint.

Unused argument 'size'
Error

Line: 38 Column: 44

                          # tzlocal is cumbersomely slow, so skip to keep runtime in check
            raise NotImplementedError

    def time_normalize_i8_timestamps(self, size, tz):
        normalize_i8_timestamps(self.i8data, tz)

    def time_is_date_array_normalized(self, size, tz):
        # TODO: cases with different levels of short-circuiting
        is_date_array_normalized(self.i8data, tz)

            

Reported by Pylint.

Unused argument 'size'
Error

Line: 41 Column: 45

                  def time_normalize_i8_timestamps(self, size, tz):
        normalize_i8_timestamps(self.i8data, tz)

    def time_is_date_array_normalized(self, size, tz):
        # TODO: cases with different levels of short-circuiting
        is_date_array_normalized(self.i8data, tz)

            

Reported by Pylint.

TODO: cases with different levels of short-circuiting
Error

Line: 42 Column: 3

                      normalize_i8_timestamps(self.i8data, tz)

    def time_is_date_array_normalized(self, size, tz):
        # TODO: cases with different levels of short-circuiting
        is_date_array_normalized(self.i8data, tz)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              try:
    from pandas._libs.tslibs import (
        is_date_array_normalized,
        normalize_i8_timestamps,
    )
except ImportError:
    from pandas._libs.tslibs.conversion import (
        normalize_i8_timestamps,
        is_date_array_normalized,

            

Reported by Pylint.

Missing class docstring
Error

Line: 21 Column: 1

              )


class Normalize:
    params = [
        _sizes,
        _tzs,
    ]
    param_names = ["size", "tz"]

            

Reported by Pylint.

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

Line: 28 Column: 5

                  ]
    param_names = ["size", "tz"]

    def setup(self, size, tz):
        # use an array that will have is_date_array_normalized give True,
        #  so we do not short-circuit early.
        dti = pd.date_range("2016-01-01", periods=10, tz=tz).repeat(size // 10)
        self.i8data = dti.asi8


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 28 Column: 5

                  ]
    param_names = ["size", "tz"]

    def setup(self, size, tz):
        # use an array that will have is_date_array_normalized give True,
        #  so we do not short-circuit early.
        dti = pd.date_range("2016-01-01", periods=10, tz=tz).repeat(size // 10)
        self.i8data = dti.asi8


            

Reported by Pylint.

pandas/tests/indexes/datetimes/test_map.py
14 issues
Unable to import 'pytest'
Error

Line: 1 Column: 1

              import pytest

from pandas import (
    DatetimeIndex,
    Index,
    MultiIndex,
    Period,
    date_range,
)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import pytest

from pandas import (
    DatetimeIndex,
    Index,
    MultiIndex,
    Period,
    date_range,
)

            

Reported by Pylint.

Missing class docstring
Error

Line: 13 Column: 1

              import pandas._testing as tm


class TestMap:
    def test_map(self):
        rng = date_range("1/1/2000", periods=10)

        f = lambda x: x.strftime("%Y%m%d")
        result = rng.map(f)

            

Reported by Pylint.

Method could be a function
Error

Line: 14 Column: 5

              

class TestMap:
    def test_map(self):
        rng = date_range("1/1/2000", periods=10)

        f = lambda x: x.strftime("%Y%m%d")
        result = rng.map(f)
        exp = Index([f(x) for x in rng], dtype="<U8")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 14 Column: 5

              

class TestMap:
    def test_map(self):
        rng = date_range("1/1/2000", periods=10)

        f = lambda x: x.strftime("%Y%m%d")
        result = rng.map(f)
        exp = Index([f(x) for x in rng], dtype="<U8")

            

Reported by Pylint.

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

Line: 17 Column: 9

                  def test_map(self):
        rng = date_range("1/1/2000", periods=10)

        f = lambda x: x.strftime("%Y%m%d")
        result = rng.map(f)
        exp = Index([f(x) for x in rng], dtype="<U8")
        tm.assert_index_equal(result, exp)

    def test_map_fallthrough(self, capsys):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 22 Column: 5

                      exp = Index([f(x) for x in rng], dtype="<U8")
        tm.assert_index_equal(result, exp)

    def test_map_fallthrough(self, capsys):
        # GH#22067, check we don't get warnings about silently ignored errors
        dti = date_range("2017-01-01", "2018-01-01", freq="B")

        dti.map(lambda x: Period(year=x.year, month=x.month, freq="M"))


            

Reported by Pylint.

Method could be a function
Error

Line: 22 Column: 5

                      exp = Index([f(x) for x in rng], dtype="<U8")
        tm.assert_index_equal(result, exp)

    def test_map_fallthrough(self, capsys):
        # GH#22067, check we don't get warnings about silently ignored errors
        dti = date_range("2017-01-01", "2018-01-01", freq="B")

        dti.map(lambda x: Period(year=x.year, month=x.month, freq="M"))


            

Reported by Pylint.

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

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

                      dti.map(lambda x: Period(year=x.year, month=x.month, freq="M"))

        captured = capsys.readouterr()
        assert captured.err == ""

    def test_map_bug_1677(self):
        index = DatetimeIndex(["2012-04-25 09:30:00.393000"])
        f = index.asof


            

Reported by Bandit.

Missing function or method docstring
Error

Line: 31 Column: 5

                      captured = capsys.readouterr()
        assert captured.err == ""

    def test_map_bug_1677(self):
        index = DatetimeIndex(["2012-04-25 09:30:00.393000"])
        f = index.asof

        result = index.map(f)
        expected = Index([f(index[0])])

            

Reported by Pylint.

pandas/tests/indexes/datetimes/methods/test_to_series.py
14 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

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


            

Reported by Pylint.

Missing class docstring
Error

Line: 11 Column: 1

              import pandas._testing as tm


class TestToSeries:
    @pytest.fixture
    def idx_expected(self):
        naive = DatetimeIndex(["2013-1-1 13:00", "2013-1-2 14:00"], name="B")
        idx = naive.tz_localize("US/Pacific")


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 5

              
class TestToSeries:
    @pytest.fixture
    def idx_expected(self):
        naive = DatetimeIndex(["2013-1-1 13:00", "2013-1-2 14:00"], name="B")
        idx = naive.tz_localize("US/Pacific")

        expected = Series(np.array(idx.tolist(), dtype="object"), name="B")


            

Reported by Pylint.

Method could be a function
Error

Line: 13 Column: 5

              
class TestToSeries:
    @pytest.fixture
    def idx_expected(self):
        naive = DatetimeIndex(["2013-1-1 13:00", "2013-1-2 14:00"], name="B")
        idx = naive.tz_localize("US/Pacific")

        expected = Series(np.array(idx.tolist(), dtype="object"), name="B")


            

Reported by Pylint.

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

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

              
        expected = Series(np.array(idx.tolist(), dtype="object"), name="B")

        assert expected.dtype == idx.dtype
        return idx, expected

    def test_to_series_keep_tz_deprecated_true(self, idx_expected):
        # convert to series while keeping the timezone
        idx, expected = idx_expected

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 22 Column: 5

                      assert expected.dtype == idx.dtype
        return idx, expected

    def test_to_series_keep_tz_deprecated_true(self, idx_expected):
        # convert to series while keeping the timezone
        idx, expected = idx_expected

        msg = "stop passing 'keep_tz'"
        with tm.assert_produces_warning(FutureWarning) as m:

            

Reported by Pylint.

Method could be a function
Error

Line: 22 Column: 5

                      assert expected.dtype == idx.dtype
        return idx, expected

    def test_to_series_keep_tz_deprecated_true(self, idx_expected):
        # convert to series while keeping the timezone
        idx, expected = idx_expected

        msg = "stop passing 'keep_tz'"
        with tm.assert_produces_warning(FutureWarning) as m:

            

Reported by Pylint.

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

Line: 27 Column: 59

                      idx, expected = idx_expected

        msg = "stop passing 'keep_tz'"
        with tm.assert_produces_warning(FutureWarning) as m:
            result = idx.to_series(keep_tz=True, index=[0, 1])
        assert msg in str(m[0].message)

        tm.assert_series_equal(result, expected)


            

Reported by Pylint.

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

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

                      msg = "stop passing 'keep_tz'"
        with tm.assert_produces_warning(FutureWarning) as m:
            result = idx.to_series(keep_tz=True, index=[0, 1])
        assert msg in str(m[0].message)

        tm.assert_series_equal(result, expected)

    def test_to_series_keep_tz_deprecated_false(self, idx_expected):
        idx, expected = idx_expected

            

Reported by Bandit.

pandas/tests/indexes/datetimelike_/test_value_counts.py
14 issues
Access to a protected member _values of a client class
Error

Line: 35 Column: 23

                  def _check_value_counts_with_repeats(self, orig):
        # create repeated values, 'n'th element is repeated by n+1 times
        idx = type(orig)(
            np.repeat(orig._values, range(1, len(orig) + 1)), dtype=orig.dtype
        )

        exp_idx = orig[::-1]
        if not isinstance(exp_idx, PeriodIndex):
            exp_idx = exp_idx._with_freq(None)

            

Reported by Pylint.

Access to a protected member _with_freq of a client class
Error

Line: 40 Column: 23

              
        exp_idx = orig[::-1]
        if not isinstance(exp_idx, PeriodIndex):
            exp_idx = exp_idx._with_freq(None)
        expected = Series(range(10, 0, -1), index=exp_idx, dtype="int64")

        for obj in [idx, Series(idx)]:
            tm.assert_series_equal(obj.value_counts(), expected)


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np

from pandas import (
    DatetimeIndex,
    NaT,
    PeriodIndex,
    Series,
    TimedeltaIndex,
    date_range,

            

Reported by Pylint.

Missing class docstring
Error

Line: 16 Column: 1

              import pandas._testing as tm


class TestValueCounts:
    # GH#7735

    def test_value_counts_unique_datetimeindex(self, tz_naive_fixture):
        tz = tz_naive_fixture
        orig = date_range("2011-01-01 09:00", freq="H", periods=10, tz=tz)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 19 Column: 5

              class TestValueCounts:
    # GH#7735

    def test_value_counts_unique_datetimeindex(self, tz_naive_fixture):
        tz = tz_naive_fixture
        orig = date_range("2011-01-01 09:00", freq="H", periods=10, tz=tz)
        self._check_value_counts_with_repeats(orig)

    def test_value_counts_unique_timedeltaindex(self):

            

Reported by Pylint.

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

Line: 20 Column: 9

                  # GH#7735

    def test_value_counts_unique_datetimeindex(self, tz_naive_fixture):
        tz = tz_naive_fixture
        orig = date_range("2011-01-01 09:00", freq="H", periods=10, tz=tz)
        self._check_value_counts_with_repeats(orig)

    def test_value_counts_unique_timedeltaindex(self):
        orig = timedelta_range("1 days 09:00:00", freq="H", periods=10)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 24 Column: 5

                      orig = date_range("2011-01-01 09:00", freq="H", periods=10, tz=tz)
        self._check_value_counts_with_repeats(orig)

    def test_value_counts_unique_timedeltaindex(self):
        orig = timedelta_range("1 days 09:00:00", freq="H", periods=10)
        self._check_value_counts_with_repeats(orig)

    def test_value_counts_unique_periodindex(self):
        orig = period_range("2011-01-01 09:00", freq="H", periods=10)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 28 Column: 5

                      orig = timedelta_range("1 days 09:00:00", freq="H", periods=10)
        self._check_value_counts_with_repeats(orig)

    def test_value_counts_unique_periodindex(self):
        orig = period_range("2011-01-01 09:00", freq="H", periods=10)
        self._check_value_counts_with_repeats(orig)

    def _check_value_counts_with_repeats(self, orig):
        # create repeated values, 'n'th element is repeated by n+1 times

            

Reported by Pylint.

Method could be a function
Error

Line: 32 Column: 5

                      orig = period_range("2011-01-01 09:00", freq="H", periods=10)
        self._check_value_counts_with_repeats(orig)

    def _check_value_counts_with_repeats(self, orig):
        # create repeated values, 'n'th element is repeated by n+1 times
        idx = type(orig)(
            np.repeat(orig._values, range(1, len(orig) + 1)), dtype=orig.dtype
        )


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 48 Column: 5

              
        tm.assert_index_equal(idx.unique(), orig)

    def test_value_counts_unique_datetimeindex2(self, tz_naive_fixture):
        tz = tz_naive_fixture
        idx = DatetimeIndex(
            [
                "2013-01-01 09:00",
                "2013-01-01 09:00",

            

Reported by Pylint.

pandas/io/excel/_xlwt.py
14 issues
No name 'json' in module 'pandas._libs'
Error

Line: 8 Column: 1

                  Any,
)

import pandas._libs.json as json
from pandas._typing import StorageOptions

from pandas.io.excel._base import ExcelWriter
from pandas.io.excel._util import (
    combine_kwargs,

            

Reported by Pylint.

Unable to import 'pandas._libs.json'
Error

Line: 8 Column: 1

                  Any,
)

import pandas._libs.json as json
from pandas._typing import StorageOptions

from pandas.io.excel._base import ExcelWriter
from pandas.io.excel._util import (
    combine_kwargs,

            

Reported by Pylint.

Unable to import 'xlwt'
Error

Line: 18 Column: 5

              )

if TYPE_CHECKING:
    from xlwt import XFStyle


class XlwtWriter(ExcelWriter):
    engine = "xlwt"
    supported_extensions = (".xls",)

            

Reported by Pylint.

Unable to import 'xlwt'
Error

Line: 39 Column: 9

                      **kwargs,
    ):
        # Use the xlwt module as the Excel writer.
        import xlwt

        engine_kwargs = combine_kwargs(engine_kwargs, kwargs)

        if mode == "a":
            raise ValueError("Append mode is not supported with xlwt!")

            

Reported by Pylint.

Unable to import 'xlwt'
Error

Line: 162 Column: 9

                      style_dict : style dictionary to convert
        num_format_str : optional number format string
        """
        import xlwt

        if style_dict:
            xlwt_stylestr = cls._style_to_xlwt(style_dict)
            style = xlwt.easyxf(xlwt_stylestr, field_sep=",", line_sep=";")
        else:

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from __future__ import annotations

from typing import (
    TYPE_CHECKING,
    Any,
)

import pandas._libs.json as json
from pandas._typing import StorageOptions

            

Reported by Pylint.

Missing class docstring
Error

Line: 21 Column: 1

                  from xlwt import XFStyle


class XlwtWriter(ExcelWriter):
    engine = "xlwt"
    supported_extensions = (".xls",)

    def __init__(
        self,

            

Reported by Pylint.

Too many arguments (10/5)
Error

Line: 25 Column: 5

                  engine = "xlwt"
    supported_extensions = (".xls",)

    def __init__(
        self,
        path,
        engine=None,
        date_format=None,
        datetime_format=None,

            

Reported by Pylint.

Import outside toplevel (xlwt)
Error

Line: 39 Column: 9

                      **kwargs,
    ):
        # Use the xlwt module as the Excel writer.
        import xlwt

        engine_kwargs = combine_kwargs(engine_kwargs, kwargs)

        if mode == "a":
            raise ValueError("Append mode is not supported with xlwt!")

            

Reported by Pylint.

Too many arguments (6/5)
Error

Line: 68 Column: 5

                          # fails when the ExcelWriter is just opened and then closed
            self.book.save(self.handles.handle)

    def write_cells(
        self, cells, sheet_name=None, startrow=0, startcol=0, freeze_panes=None
    ):

        sheet_name = self._get_sheet_name(sheet_name)


            

Reported by Pylint.