The following issues were found

pandas/tests/series/accessors/test_cat_accessor.py
44 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              import warnings

import numpy as np
import pytest

from pandas import (
    Categorical,
    DataFrame,
    Index,

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 77 Column: 13

              
        invalid = Series([1])
        with pytest.raises(AttributeError, match="only use .cat accessor"):
            invalid.cat
        assert not hasattr(invalid, "cat")

    def test_cat_accessor_no_new_attributes(self):
        # https://github.com/pandas-dev/pandas/issues/10673
        cat = Series(list("aabbcde")).astype("category")

            

Reported by Pylint.

Expression "Series([1, 2, 3]).cat" is assigned to nothing
Error

Line: 102 Column: 13

                      # invalid accessor
        msg = r"Can only use \.cat accessor with a 'category' dtype"
        with pytest.raises(AttributeError, match=msg):
            Series([1, 2, 3]).cat
        with pytest.raises(AttributeError, match=msg):
            Series([1, 2, 3]).cat()
        with pytest.raises(AttributeError, match=msg):
            Series(["a", "b", "c"]).cat
        with pytest.raises(AttributeError, match=msg):

            

Reported by Pylint.

Expression "Series(['a', 'b', 'c']).cat" is assigned to nothing
Error

Line: 106 Column: 13

                      with pytest.raises(AttributeError, match=msg):
            Series([1, 2, 3]).cat()
        with pytest.raises(AttributeError, match=msg):
            Series(["a", "b", "c"]).cat
        with pytest.raises(AttributeError, match=msg):
            Series(np.arange(5.0)).cat
        with pytest.raises(AttributeError, match=msg):
            Series([Timestamp("20130101")]).cat


            

Reported by Pylint.

Expression "Series(np.arange(5.0)).cat" is assigned to nothing
Error

Line: 108 Column: 13

                      with pytest.raises(AttributeError, match=msg):
            Series(["a", "b", "c"]).cat
        with pytest.raises(AttributeError, match=msg):
            Series(np.arange(5.0)).cat
        with pytest.raises(AttributeError, match=msg):
            Series([Timestamp("20130101")]).cat

        # Series should delegate calls to '.categories', '.codes', '.ordered'
        # and the methods '.set_categories()' 'drop_unused_categories()' to the

            

Reported by Pylint.

Expression "Series([Timestamp('20130101')]).cat" is assigned to nothing
Error

Line: 110 Column: 13

                      with pytest.raises(AttributeError, match=msg):
            Series(np.arange(5.0)).cat
        with pytest.raises(AttributeError, match=msg):
            Series([Timestamp("20130101")]).cat

        # Series should delegate calls to '.categories', '.codes', '.ordered'
        # and the methods '.set_categories()' 'drop_unused_categories()' to the
        # categorical
        ser = Series(Categorical(["a", "b", "c", "a"], ordered=True))

            

Reported by Pylint.

Access to a protected member _datetimelike_ops of a client class
Error

Line: 180 Column: 29

              
        # only testing field (like .day)
        # and bool (is_month_start)
        get_ops = lambda x: x._datetimelike_ops

        test_data = [
            ("Datetime", get_ops(DatetimeArray), s_dr, c_dr),
            ("Period", get_ops(PeriodArray), s_pr, c_pr),
            ("Timedelta", get_ops(TimedeltaArray), s_tdr, c_tdr),

            

Reported by Pylint.

FIXME: don't leave commented-out
Error

Line: 197 Column: 3

                          ("floor", ("D",), {}),
            ("ceil", ("D",), {}),
            ("asfreq", ("D",), {}),
            # FIXME: don't leave commented-out
            # ('tz_localize', ("UTC",), {}),
        ]
        _special_func_names = [f[0] for f in special_func_defs]

        # the series is already localized

            

Reported by Pylint.

Unused variable 'name'
Error

Line: 205 Column: 13

                      # the series is already localized
        _ignore_names = ["tz_localize", "components"]

        for name, attr_names, s, c in test_data:
            func_names = [
                f
                for f in dir(s.dt)
                if not (
                    f.startswith("_")

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 250 Column: 13

                      msg = "Can only use .dt accessor with datetimelike"

        with pytest.raises(AttributeError, match=msg):
            invalid.dt
        assert not hasattr(invalid, "str")

            

Reported by Pylint.

pandas/tests/resample/test_time_grouper.py
44 issues
Unable to import 'pytest'
Error

Line: 5 Column: 1

              from operator import methodcaller

import numpy as np
import pytest

import pandas as pd
from pandas import (
    DataFrame,
    Series,

            

Reported by Pylint.

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

Line: 213 Column: 22

                  expected = normal_result.append(pad)
    expected = expected.sort_index()
    dti = date_range(start="2013-01-01", freq="D", periods=5, name="key")
    expected.index = dti._with_freq(None)  # TODO: is this desired?
    tm.assert_frame_equal(expected, dt_result)
    assert dt_result.index.name == "key"


def test_aggregate_with_nat_size():

            

Reported by Pylint.

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

Line: 213 Column: 22

                  expected = normal_result.append(pad)
    expected = expected.sort_index()
    dti = date_range(start="2013-01-01", freq="D", periods=5, name="key")
    expected.index = dti._with_freq(None)  # TODO: is this desired?
    tm.assert_frame_equal(expected, dt_result)
    assert dt_result.index.name == "key"


def test_aggregate_with_nat_size():

            

Reported by Pylint.

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

Line: 243 Column: 22

                  pad = Series([0], index=[3])
    expected = normal_result.append(pad)
    expected = expected.sort_index()
    expected.index = date_range(
        start="2013-01-01", freq="D", periods=5, name="key"
    )._with_freq(None)
    tm.assert_series_equal(expected, dt_result)
    assert dt_result.index.name == "key"


            

Reported by Pylint.

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

Line: 243 Column: 22

                  pad = Series([0], index=[3])
    expected = normal_result.append(pad)
    expected = expected.sort_index()
    expected.index = date_range(
        start="2013-01-01", freq="D", periods=5, name="key"
    )._with_freq(None)
    tm.assert_series_equal(expected, dt_result)
    assert dt_result.index.name == "key"


            

Reported by Pylint.

Access to a protected member _get_grouper of a client class
Error

Line: 67 Column: 21

                  df = DataFrame({"open": 1, "close": 2}, index=ind)
    tg = Grouper(freq="M")

    _, grouper, _ = tg._get_grouper(df)

    # Errors
    grouped = df.groupby(grouper, group_keys=False)

    def f(df):

            

Reported by Pylint.

String statement has no effect
Error

Line: 150 Column: 5

              
    # if TimeGrouper is used included, 'nth' doesn't work yet

    """
    for func in ['nth']:
        expected = getattr(normal_grouped, func)(3)
        expected.index = date_range(start='2013-01-01',
                                    freq='D', periods=5, name='key')
        dt_result = getattr(dt_grouped, func)(3)

            

Reported by Pylint.

Access to a protected member _with_freq of a client class
Error

Line: 213 Column: 22

                  expected = normal_result.append(pad)
    expected = expected.sort_index()
    dti = date_range(start="2013-01-01", freq="D", periods=5, name="key")
    expected.index = dti._with_freq(None)  # TODO: is this desired?
    tm.assert_frame_equal(expected, dt_result)
    assert dt_result.index.name == "key"


def test_aggregate_with_nat_size():

            

Reported by Pylint.

TODO: is this desired?
Error

Line: 213 Column: 3

                  expected = normal_result.append(pad)
    expected = expected.sort_index()
    dti = date_range(start="2013-01-01", freq="D", periods=5, name="key")
    expected.index = dti._with_freq(None)  # TODO: is this desired?
    tm.assert_frame_equal(expected, dt_result)
    assert dt_result.index.name == "key"


def test_aggregate_with_nat_size():

            

Reported by Pylint.

Access to a protected member _with_freq of a client class
Error

Line: 243 Column: 22

                  pad = Series([0], index=[3])
    expected = normal_result.append(pad)
    expected = expected.sort_index()
    expected.index = date_range(
        start="2013-01-01", freq="D", periods=5, name="key"
    )._with_freq(None)
    tm.assert_series_equal(expected, dt_result)
    assert dt_result.index.name == "key"


            

Reported by Pylint.

pandas/core/computation/pytables.py
44 issues
Parameters differ from overridden 'evaluate' method
Error

Line: 285 Column: 5

                      """return the actual filter format"""
        return [self.filter]

    def evaluate(self):

        if not self.is_valid:
            raise ValueError(f"query term is not valid [{self}]")

        rhs = self.conform(self.rhs)

            

Reported by Pylint.

Parameters differ from overridden 'evaluate' method
Error

Line: 349 Column: 5

                      """return the actual ne format"""
        return self.condition

    def evaluate(self):

        if not self.is_valid:
            raise ValueError(f"query term is not valid [{self}]")

        # convert values if we are in the table

            

Reported by Pylint.

Method 'invert' is abstract in class 'ConditionBinOp' but is not overridden
Error

Line: 378 Column: 1

                      return self


class JointConditionBinOp(ConditionBinOp):
    def evaluate(self):
        self.condition = f"({self.lhs.condition} {self.op} {self.rhs.condition})"
        return self



            

Reported by Pylint.

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

Line: 547 Column: 5

                  env: PyTablesScope
    expr: str

    def __init__(
        self,
        where,
        queryables: dict[str, Any] | None = None,
        encoding=None,
        scope_level: int = 0,

            

Reported by Pylint.

Redefining name 'ops' from outer scope (line 19)
Error

Line: 648 Column: 5

                  """loose checking if s is a pytables-acceptable expression"""
    if not isinstance(s, str):
        return False
    ops = PyTablesExprVisitor.binary_ops + PyTablesExprVisitor.unary_ops + ("=",)

    # make sure we have an op at least
    return any(op in s for op in ops)

            

Reported by Pylint.

Missing class docstring
Error

Line: 39 Column: 1

              )


class PyTablesScope(_scope.Scope):
    __slots__ = ("queryables",)

    queryables: dict[str, Any]

    def __init__(

            

Reported by Pylint.

Missing class docstring
Error

Line: 55 Column: 1

                      self.queryables = queryables or {}


class Term(ops.Term):
    env: PyTablesScope

    def __new__(cls, name, env, side=None, encoding=None):
        if isinstance(name, str):
            klass = cls

            

Reported by Pylint.

Missing class docstring
Error

Line: 88 Column: 1

                      return self._value


class Constant(Term):
    def __init__(self, value, env: PyTablesScope, side=None, encoding=None):
        assert isinstance(env, PyTablesScope), type(env)
        super().__init__(value, env, side=side, encoding=encoding)

    def _resolve_name(self):

            

Reported by Pylint.

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

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

              
class Constant(Term):
    def __init__(self, value, env: PyTablesScope, side=None, encoding=None):
        assert isinstance(env, PyTablesScope), type(env)
        super().__init__(value, env, side=side, encoding=encoding)

    def _resolve_name(self):
        return self._name


            

Reported by Bandit.

Missing class docstring
Error

Line: 97 Column: 1

                      return self._name


class BinOp(ops.BinOp):

    _max_selectors = 31

    op: str
    queryables: dict[str, Any]

            

Reported by Pylint.

pandas/tests/indexes/timedeltas/test_scalar_compat.py
43 issues
Unable to import 'pytest'
Error

Line: 6 Column: 1

              """

import numpy as np
import pytest

from pandas._libs.tslibs.offsets import INVALID_FREQ_ERR_MSG

from pandas import (
    Index,

            

Reported by Pylint.

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

Line: 8 Column: 1

              import numpy as np
import pytest

from pandas._libs.tslibs.offsets import INVALID_FREQ_ERR_MSG

from pandas import (
    Index,
    Series,
    Timedelta,

            

Reported by Pylint.

No name 'offsets' in module 'pandas._libs.tslibs'
Error

Line: 8 Column: 1

              import numpy as np
import pytest

from pandas._libs.tslibs.offsets import INVALID_FREQ_ERR_MSG

from pandas import (
    Index,
    Series,
    Timedelta,

            

Reported by Pylint.

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

Line: 29 Column: 32

                          1 * 86400 + 10 * 3600 + 11 * 60 + 12 + 100123456.0 / 1e9,
            1 * 86400 + 10 * 3600 + 11 * 60 + 13 + 100123456.0 / 1e9,
        ]
        tm.assert_almost_equal(rng.total_seconds(), Index(expt))

        # test Series
        ser = Series(rng)
        s_expt = Series(expt, index=[0, 1])
        tm.assert_series_equal(ser.dt.total_seconds(), s_expt)

            

Reported by Pylint.

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

Line: 29 Column: 32

                          1 * 86400 + 10 * 3600 + 11 * 60 + 12 + 100123456.0 / 1e9,
            1 * 86400 + 10 * 3600 + 11 * 60 + 13 + 100123456.0 / 1e9,
        ]
        tm.assert_almost_equal(rng.total_seconds(), Index(expt))

        # test Series
        ser = Series(rng)
        s_expt = Series(expt, index=[0, 1])
        tm.assert_series_equal(ser.dt.total_seconds(), s_expt)

            

Reported by Pylint.

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

Line: 65 Column: 31

                      )
        expected_elt = expected_rng[1]

        tm.assert_index_equal(td.round(freq="H"), expected_rng)
        assert elt.round(freq="H") == expected_elt

        msg = INVALID_FREQ_ERR_MSG
        with pytest.raises(ValueError, match=msg):
            td.round(freq="foo")

            

Reported by Pylint.

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

Line: 65 Column: 31

                      )
        expected_elt = expected_rng[1]

        tm.assert_index_equal(td.round(freq="H"), expected_rng)
        assert elt.round(freq="H") == expected_elt

        msg = INVALID_FREQ_ERR_MSG
        with pytest.raises(ValueError, match=msg):
            td.round(freq="foo")

            

Reported by Pylint.

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

Line: 70 Column: 13

              
        msg = INVALID_FREQ_ERR_MSG
        with pytest.raises(ValueError, match=msg):
            td.round(freq="foo")
        with pytest.raises(ValueError, match=msg):
            elt.round(freq="foo")

        msg = "<MonthEnd> is a non-fixed frequency"
        with pytest.raises(ValueError, match=msg):

            

Reported by Pylint.

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

Line: 70 Column: 13

              
        msg = INVALID_FREQ_ERR_MSG
        with pytest.raises(ValueError, match=msg):
            td.round(freq="foo")
        with pytest.raises(ValueError, match=msg):
            elt.round(freq="foo")

        msg = "<MonthEnd> is a non-fixed frequency"
        with pytest.raises(ValueError, match=msg):

            

Reported by Pylint.

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

Line: 76 Column: 13

              
        msg = "<MonthEnd> is a non-fixed frequency"
        with pytest.raises(ValueError, match=msg):
            td.round(freq="M")
        with pytest.raises(ValueError, match=msg):
            elt.round(freq="M")

    @pytest.mark.parametrize(
        "freq,msg",

            

Reported by Pylint.

pandas/tests/arrays/test_ndarray_backed.py
43 issues
Access to a protected member _empty of a client class
Error

Line: 25 Column: 18

              
        # case with int8 codes
        shape = (4,)
        result = Categorical._empty(shape, dtype=dtype)
        assert isinstance(result, Categorical)
        assert result.shape == shape
        assert result._ndarray.dtype == np.int8

        # case where repr would segfault if we didn't override base implementation

            

Reported by Pylint.

Access to a protected member _ndarray of a client class
Error

Line: 28 Column: 16

                      result = Categorical._empty(shape, dtype=dtype)
        assert isinstance(result, Categorical)
        assert result.shape == shape
        assert result._ndarray.dtype == np.int8

        # case where repr would segfault if we didn't override base implementation
        result = Categorical._empty((4096,), dtype=dtype)
        assert isinstance(result, Categorical)
        assert result.shape == (4096,)

            

Reported by Pylint.

Access to a protected member _empty of a client class
Error

Line: 31 Column: 18

                      assert result._ndarray.dtype == np.int8

        # case where repr would segfault if we didn't override base implementation
        result = Categorical._empty((4096,), dtype=dtype)
        assert isinstance(result, Categorical)
        assert result.shape == (4096,)
        assert result._ndarray.dtype == np.int8
        repr(result)


            

Reported by Pylint.

Access to a protected member _ndarray of a client class
Error

Line: 34 Column: 16

                      result = Categorical._empty((4096,), dtype=dtype)
        assert isinstance(result, Categorical)
        assert result.shape == (4096,)
        assert result._ndarray.dtype == np.int8
        repr(result)

        # case with int16 codes
        ci = CategoricalIndex(list(range(512)) * 4, ordered=False)
        dtype = ci.dtype

            

Reported by Pylint.

Access to a protected member _empty of a client class
Error

Line: 40 Column: 18

                      # case with int16 codes
        ci = CategoricalIndex(list(range(512)) * 4, ordered=False)
        dtype = ci.dtype
        result = Categorical._empty(shape, dtype=dtype)
        assert isinstance(result, Categorical)
        assert result.shape == shape
        assert result._ndarray.dtype == np.int16

    def test_empty_dt64tz(self):

            

Reported by Pylint.

Access to a protected member _ndarray of a client class
Error

Line: 43 Column: 16

                      result = Categorical._empty(shape, dtype=dtype)
        assert isinstance(result, Categorical)
        assert result.shape == shape
        assert result._ndarray.dtype == np.int16

    def test_empty_dt64tz(self):
        dti = date_range("2016-01-01", periods=2, tz="Asia/Tokyo")
        dtype = dti.dtype


            

Reported by Pylint.

Access to a protected member _empty of a client class
Error

Line: 50 Column: 18

                      dtype = dti.dtype

        shape = (0,)
        result = DatetimeArray._empty(shape, dtype=dtype)
        assert result.dtype == dtype
        assert isinstance(result, DatetimeArray)
        assert result.shape == shape

    def test_empty_dt64(self):

            

Reported by Pylint.

Comparing against a callable, did you omit the parenthesis?
Error

Line: 51 Column: 16

              
        shape = (0,)
        result = DatetimeArray._empty(shape, dtype=dtype)
        assert result.dtype == dtype
        assert isinstance(result, DatetimeArray)
        assert result.shape == shape

    def test_empty_dt64(self):
        shape = (3, 9)

            

Reported by Pylint.

Access to a protected member _empty of a client class
Error

Line: 57 Column: 18

              
    def test_empty_dt64(self):
        shape = (3, 9)
        result = DatetimeArray._empty(shape, dtype="datetime64[ns]")
        assert isinstance(result, DatetimeArray)
        assert result.shape == shape

    def test_empty_td64(self):
        shape = (3, 9)

            

Reported by Pylint.

Access to a protected member _empty of a client class
Error

Line: 63 Column: 18

              
    def test_empty_td64(self):
        shape = (3, 9)
        result = TimedeltaArray._empty(shape, dtype="m8[ns]")
        assert isinstance(result, TimedeltaArray)
        assert result.shape == shape

    def test_empty_pandas_array(self):
        arr = PandasArray(np.array([1, 2]))

            

Reported by Pylint.

pandas/tests/indexes/period/methods/test_astype.py
43 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

from pandas import (
    CategoricalIndex,
    DatetimeIndex,
    Index,
    Int64Index,
    NaT,

            

Reported by Pylint.

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

Line: 154 Column: 28

                          # how keyword deprecated GH#37982
            res = pi.astype("datetime64[ns]", how="start")
        tm.assert_index_equal(res, exp)
        assert res.freq == exp.freq

        exp = DatetimeIndex(["2011-01-31", "2011-02-28", "2011-03-31"])
        exp = exp + Timedelta(1, "D") - Timedelta(1, "ns")
        with tm.assert_produces_warning(FutureWarning):
            # how keyword deprecated GH#37982

            

Reported by Pylint.

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

Line: 167 Column: 28

                      exp = DatetimeIndex(["2011-01-01", "2011-02-01", "2011-03-01"], tz="US/Eastern")
        res = pi.astype("datetime64[ns, US/Eastern]")
        tm.assert_index_equal(res, exp)
        assert res.freq == exp.freq

        exp = DatetimeIndex(["2011-01-31", "2011-02-28", "2011-03-31"], tz="US/Eastern")
        exp = exp + Timedelta(1, "D") - Timedelta(1, "ns")
        with tm.assert_produces_warning(FutureWarning):
            # how keyword deprecated GH#37982

            

Reported by Pylint.

Access to a protected member _mpl_repr of a client class
Error

Line: 69 Column: 37

              
        exp = np.array([], dtype=object)
        tm.assert_numpy_array_equal(idx.astype(object).values, exp)
        tm.assert_numpy_array_equal(idx._mpl_repr(), exp)

        idx = PeriodIndex(["2011-01", NaT], freq="M")

        exp = np.array([Period("2011-01", freq="M"), NaT], dtype=object)
        tm.assert_numpy_array_equal(idx.astype(object).values, exp)

            

Reported by Pylint.

Access to a protected member _mpl_repr of a client class
Error

Line: 75 Column: 37

              
        exp = np.array([Period("2011-01", freq="M"), NaT], dtype=object)
        tm.assert_numpy_array_equal(idx.astype(object).values, exp)
        tm.assert_numpy_array_equal(idx._mpl_repr(), exp)

        exp = np.array([Period("2011-01-01", freq="D"), NaT], dtype=object)
        idx = PeriodIndex(["2011-01-01", NaT], freq="D")
        tm.assert_numpy_array_equal(idx.astype(object).values, exp)
        tm.assert_numpy_array_equal(idx._mpl_repr(), exp)

            

Reported by Pylint.

Access to a protected member _mpl_repr of a client class
Error

Line: 80 Column: 37

                      exp = np.array([Period("2011-01-01", freq="D"), NaT], dtype=object)
        idx = PeriodIndex(["2011-01-01", NaT], freq="D")
        tm.assert_numpy_array_equal(idx.astype(object).values, exp)
        tm.assert_numpy_array_equal(idx._mpl_repr(), exp)

    # TODO: de-duplicate this version (from test_ops) with the one above
    # (from test_period)
    def test_astype_object2(self):
        idx = period_range(start="2013-01-01", periods=4, freq="M", name="idx")

            

Reported by Pylint.

TODO: de-duplicate this version (from test_ops) with the one above
Error

Line: 82 Column: 3

                      tm.assert_numpy_array_equal(idx.astype(object).values, exp)
        tm.assert_numpy_array_equal(idx._mpl_repr(), exp)

    # TODO: de-duplicate this version (from test_ops) with the one above
    # (from test_period)
    def test_astype_object2(self):
        idx = period_range(start="2013-01-01", periods=4, freq="M", name="idx")
        expected_list = [
            Period("2013-01-31", freq="M"),

            

Reported by Pylint.

Access to a protected member _data of a client class
Error

Line: 132 Column: 18

                      )
        tm.assert_index_equal(result, expected)

        result = obj._data.astype("category")
        expected = expected.values
        tm.assert_categorical_equal(result, expected)

    def test_astype_array_fallback(self):
        obj = period_range("2000", periods=2, name="idx")

            

Reported by Pylint.

Access to a protected member _data of a client class
Error

Line: 142 Column: 18

                      expected = Index(np.array([True, True]), name="idx")
        tm.assert_index_equal(result, expected)

        result = obj._data.astype(bool)
        expected = np.array([True, True])
        tm.assert_numpy_array_equal(result, expected)

    def test_period_astype_to_timestamp(self):
        pi = PeriodIndex(["2011-01", "2011-02", "2011-03"], freq="M")

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

from pandas import (
    CategoricalIndex,
    DatetimeIndex,
    Index,
    Int64Index,
    NaT,

            

Reported by Pylint.

pandas/tests/generic/test_series.py
43 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              from operator import methodcaller

import numpy as np
import pytest

import pandas as pd
from pandas import (
    MultiIndex,
    Series,

            

Reported by Pylint.

Access to a protected member _set_axis_name of a client class
Error

Line: 39 Column: 13

                      s = Series([1])
        msg = "No axis named 1 for object type Series"
        with pytest.raises(ValueError, match=msg):
            s._set_axis_name(name="a", axis=1)

    def test_get_bool_data_preserve_dtype(self):
        o = Series([True, False, True])
        result = o._get_bool_data()
        self._compare(result, o)

            

Reported by Pylint.

Access to a protected member _get_bool_data of a client class
Error

Line: 43 Column: 18

              
    def test_get_bool_data_preserve_dtype(self):
        o = Series([True, False, True])
        result = o._get_bool_data()
        self._compare(result, o)

    def test_nonzero_single_element(self):

        # allow single item via bool method

            

Reported by Pylint.

Access to a protected member _metadata of a client class
Error

Line: 123 Column: 21

                      result = o.T
        self.check_metadata(o, result)

        _metadata = Series._metadata
        _finalize = Series.__finalize__
        Series._metadata = ["name", "filename"]
        o.filename = "foo"
        o2.filename = "bar"


            

Reported by Pylint.

Access to a protected member _metadata of a client class
Error

Line: 125 Column: 9

              
        _metadata = Series._metadata
        _finalize = Series.__finalize__
        Series._metadata = ["name", "filename"]
        o.filename = "foo"
        o2.filename = "bar"

        def finalize(self, other, method=None, **kwargs):
            for name in self._metadata:

            

Reported by Pylint.

Unused argument 'kwargs'
Error

Line: 129 Column: 1

                      o.filename = "foo"
        o2.filename = "bar"

        def finalize(self, other, method=None, **kwargs):
            for name in self._metadata:
                if method == "concat" and name == "filename":
                    value = "+".join(
                        [getattr(o, name) for o in other.objs if getattr(o, name, None)]
                    )

            

Reported by Pylint.

Access to a protected member _metadata of a client class
Error

Line: 148 Column: 9

                      assert result.name is None

        # reset
        Series._metadata = _metadata
        Series.__finalize__ = _finalize  # FIXME: use monkeypatch

            

Reported by Pylint.

FIXME: use monkeypatch
Error

Line: 149 Column: 3

              
        # reset
        Series._metadata = _metadata
        Series.__finalize__ = _finalize  # FIXME: use monkeypatch

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from operator import methodcaller

import numpy as np
import pytest

import pandas as pd
from pandas import (
    MultiIndex,
    Series,

            

Reported by Pylint.

Missing class docstring
Error

Line: 16 Column: 1

              from pandas.tests.generic.test_generic import Generic


class TestSeries(Generic):
    _typ = Series
    _comparator = lambda self, x, y: tm.assert_series_equal(x, y)

    @pytest.mark.parametrize("func", ["rename_axis", "_set_axis_name"])
    def test_set_axis_name_mi(self, func):

            

Reported by Pylint.

pandas/io/xml.py
43 issues
No name 'etree' in module 'xml'
Error

Line: 206 Column: 9

                      super().__init__(*args, **kwargs)

    def parse_data(self) -> list[dict[str, str | None]]:
        from xml.etree.ElementTree import XML

        if self.stylesheet is not None:
            raise ValueError(
                "To use stylesheet, you need lxml installed and selected as parser."
            )

            

Reported by Pylint.

No name 'etree' in module 'xml'
Error

Line: 351 Column: 9

                              )

    def _parse_doc(self, raw_doc) -> bytes:
        from xml.etree.ElementTree import (
            XMLParser,
            parse,
            tostring,
        )


            

Reported by Pylint.

Unable to import 'lxml.etree'
Error

Line: 389 Column: 9

                      validate xpath, names, optionally parse and run XSLT,
        and parse original or transformed XML and return specific nodes.
        """
        from lxml.etree import XML

        self.xml_doc = XML(self._parse_doc(self.path_or_buffer))

        if self.stylesheet is not None:
            self.xsl_doc = XML(self._parse_doc(self.stylesheet))

            

Reported by Pylint.

Unable to import 'lxml.etree'
Error

Line: 535 Column: 9

                              )

    def _parse_doc(self, raw_doc) -> bytes:
        from lxml.etree import (
            XMLParser,
            fromstring,
            parse,
            tostring,
        )

            

Reported by Pylint.

Unable to import 'lxml.etree'
Error

Line: 569 Column: 9

                      am ideally flatter xml document for easier parsing and migration
        to Data Frame.
        """
        from lxml.etree import XSLT

        transformer = XSLT(self.xsl_doc)
        new_doc = transformer(self.xml_doc)

        return bytes(new_doc)

            

Reported by Pylint.

Useless super delegation in method '__init__'
Error

Line: 202 Column: 5

                  standard library XML module: `xml.etree.ElementTree`.
    """

    def __init__(self, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)

    def parse_data(self) -> list[dict[str, str | None]]:
        from xml.etree.ElementTree import XML


            

Reported by Pylint.

Attribute 'xml_doc' defined outside __init__
Error

Line: 213 Column: 9

                              "To use stylesheet, you need lxml installed and selected as parser."
            )

        self.xml_doc = XML(self._parse_doc(self.path_or_buffer))

        self._validate_path()
        self._validate_names()

        return self._parse_nodes()

            

Reported by Pylint.

Consider explicitly re-raising using the 'from' keyword
Error

Line: 329 Column: 13

                              raise ValueError(msg)

        except (KeyError, SyntaxError):
            raise SyntaxError(
                "You have used an incorrect or unsupported XPath "
                "expression for etree library or you used an "
                "undeclared namespace prefix."
            )


            

Reported by Pylint.

Using xml.etree.ElementTree.XMLParser to parse untrusted XML data is known to be vulnerable to XML attacks. Replace xml.etree.ElementTree.XMLParser with its defusedxml equivalent function or make sure defusedxml.defuse_stdlib() is called
Security blacklist

Line: 365
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b313-b320-xml-bad-elementtree

                      )

        with preprocess_data(handle_data) as xml_data:
            curr_parser = XMLParser(encoding=self.encoding)
            r = parse(xml_data, parser=curr_parser)

        return tostring(r.getroot())



            

Reported by Bandit.

Using xml.etree.ElementTree.parse to parse untrusted XML data is known to be vulnerable to XML attacks. Replace xml.etree.ElementTree.parse with its defusedxml equivalent function or make sure defusedxml.defuse_stdlib() is called
Security blacklist

Line: 366
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b313-b320-xml-bad-elementtree

              
        with preprocess_data(handle_data) as xml_data:
            curr_parser = XMLParser(encoding=self.encoding)
            r = parse(xml_data, parser=curr_parser)

        return tostring(r.getroot())


class _LxmlFrameParser(_XMLFrameParser):

            

Reported by Bandit.

pandas/tests/frame/methods/test_append.py
42 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

import pandas as pd
from pandas import (
    DataFrame,
    Series,
    Timestamp,
    date_range,

            

Reported by Pylint.

TODO(ArrayManager) decide on exact casting rules in concat
Error

Line: 168 Column: 3

                          {"bar": Series([Timestamp("20130101"), np.nan], dtype="M8[ns]")}
        )
        if using_array_manager:
            # TODO(ArrayManager) decide on exact casting rules in concat
            # With ArrayManager, all-NaN float is not ignored
            expected = expected.astype(object)
        tm.assert_frame_equal(result, expected)

        df1 = DataFrame({"bar": Timestamp("20130101")}, index=range(1))

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

import pandas as pd
from pandas import (
    DataFrame,
    Series,
    Timestamp,
    date_range,

            

Reported by Pylint.

Missing class docstring
Error

Line: 15 Column: 1

              import pandas._testing as tm


class TestDataFrameAppend:
    def test_append_multiindex(self, multiindex_dataframe_random_data, frame_or_series):
        obj = multiindex_dataframe_random_data
        if frame_or_series is Series:
            obj = obj["A"]


            

Reported by Pylint.

Method could be a function
Error

Line: 16 Column: 5

              

class TestDataFrameAppend:
    def test_append_multiindex(self, multiindex_dataframe_random_data, frame_or_series):
        obj = multiindex_dataframe_random_data
        if frame_or_series is Series:
            obj = obj["A"]

        a = obj[:5]

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 16 Column: 5

              

class TestDataFrameAppend:
    def test_append_multiindex(self, multiindex_dataframe_random_data, frame_or_series):
        obj = multiindex_dataframe_random_data
        if frame_or_series is Series:
            obj = obj["A"]

        a = obj[:5]

            

Reported by Pylint.

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

Line: 21 Column: 9

                      if frame_or_series is Series:
            obj = obj["A"]

        a = obj[:5]
        b = obj[5:]

        result = a.append(b)
        tm.assert_equal(result, obj)


            

Reported by Pylint.

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

Line: 22 Column: 9

                          obj = obj["A"]

        a = obj[:5]
        b = obj[5:]

        result = a.append(b)
        tm.assert_equal(result, obj)

    def test_append_empty_list(self):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 27 Column: 5

                      result = a.append(b)
        tm.assert_equal(result, obj)

    def test_append_empty_list(self):
        # GH 28769
        df = DataFrame()
        result = df.append([])
        expected = df
        tm.assert_frame_equal(result, expected)

            

Reported by Pylint.

Method could be a function
Error

Line: 27 Column: 5

                      result = a.append(b)
        tm.assert_equal(result, obj)

    def test_append_empty_list(self):
        # GH 28769
        df = DataFrame()
        result = df.append([])
        expected = df
        tm.assert_frame_equal(result, expected)

            

Reported by Pylint.

pandas/tests/extension/test_floating.py
42 issues
Unable to import 'pytest'
Error

Line: 17 Column: 1

              
"""
import numpy as np
import pytest

from pandas.core.dtypes.common import is_extension_array_dtype

import pandas as pd
import pandas._testing as tm

            

Reported by Pylint.

Redefining name 'dtype' from outer scope (line 42)
Error

Line: 47 Column: 10

              

@pytest.fixture
def data(dtype):
    return pd.array(make_data(), dtype=dtype)


@pytest.fixture
def data_for_twos(dtype):

            

Reported by Pylint.

Redefining name 'dtype' from outer scope (line 42)
Error

Line: 52 Column: 19

              

@pytest.fixture
def data_for_twos(dtype):
    return pd.array(np.ones(100) * 2, dtype=dtype)


@pytest.fixture
def data_missing(dtype):

            

Reported by Pylint.

Redefining name 'dtype' from outer scope (line 42)
Error

Line: 57 Column: 18

              

@pytest.fixture
def data_missing(dtype):
    return pd.array([pd.NA, 0.1], dtype=dtype)


@pytest.fixture
def data_for_sorting(dtype):

            

Reported by Pylint.

Redefining name 'dtype' from outer scope (line 42)
Error

Line: 62 Column: 22

              

@pytest.fixture
def data_for_sorting(dtype):
    return pd.array([0.1, 0.2, 0.0], dtype=dtype)


@pytest.fixture
def data_missing_for_sorting(dtype):

            

Reported by Pylint.

Redefining name 'dtype' from outer scope (line 42)
Error

Line: 67 Column: 30

              

@pytest.fixture
def data_missing_for_sorting(dtype):
    return pd.array([0.1, pd.NA, 0.0], dtype=dtype)


@pytest.fixture
def na_cmp():

            

Reported by Pylint.

Redefining name 'dtype' from outer scope (line 42)
Error

Line: 83 Column: 23

              

@pytest.fixture
def data_for_grouping(dtype):
    b = 0.1
    a = 0.0
    c = 0.2
    na = pd.NA
    return pd.array([b, b, na, na, a, a, b, c], dtype=dtype)

            

Reported by Pylint.

Parameters differ from overridden 'test_is_dtype_unboxes_dtype' method
Error

Line: 93 Column: 5

              
class TestDtype(base.BaseDtypeTests):
    @pytest.mark.skip(reason="using multiple dtypes")
    def test_is_dtype_unboxes_dtype(self):
        # we have multiple dtypes, so skip
        pass


class TestArithmeticOps(base.BaseArithmeticOpsTests):

            

Reported by Pylint.

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

Line: 144 Column: 33

                  def check_opname(self, s, op_name, other, exc=None):
        super().check_opname(s, op_name, other, exc=None)

    def _compare_other(self, s, data, op_name, other):
        self.check_opname(s, op_name, other)


class TestInterface(base.BaseInterfaceTests):
    pass

            

Reported by Pylint.

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

Line: 188 Column: 48

                      self.assert_series_equal(result, expected)

    @pytest.mark.skip(reason="uses nullable integer")
    def test_value_counts_with_normalize(self, data):
        pass


class TestCasting(base.BaseCastingTests):
    pass

            

Reported by Pylint.