The following issues were found

pandas/tests/indexes/categorical/test_equals.py
59 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

from pandas import (
    Categorical,
    CategoricalIndex,
    Index,
    MultiIndex,
)

            

Reported by Pylint.

Expression "ci1 == Index(['a', 'b', 'c'])" is assigned to nothing
Error

Line: 35 Column: 13

              
        # invalid comparisons
        with pytest.raises(ValueError, match="Lengths must match"):
            ci1 == Index(["a", "b", "c"])

        msg = "Categoricals can only be compared if 'categories' are the same"
        with pytest.raises(TypeError, match=msg):
            ci1 == ci2
        with pytest.raises(TypeError, match=msg):

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 39 Column: 13

              
        msg = "Categoricals can only be compared if 'categories' are the same"
        with pytest.raises(TypeError, match=msg):
            ci1 == ci2
        with pytest.raises(TypeError, match=msg):
            ci1 == Categorical(ci1.values, ordered=False)
        with pytest.raises(TypeError, match=msg):
            ci1 == Categorical(ci1.values, categories=list("abc"))


            

Reported by Pylint.

Expression "ci1 == Categorical(ci1.values, ordered=False)" is assigned to nothing
Error

Line: 41 Column: 13

                      with pytest.raises(TypeError, match=msg):
            ci1 == ci2
        with pytest.raises(TypeError, match=msg):
            ci1 == Categorical(ci1.values, ordered=False)
        with pytest.raises(TypeError, match=msg):
            ci1 == Categorical(ci1.values, categories=list("abc"))

        # tests
        # make sure that we are testing for category inclusion properly

            

Reported by Pylint.

Expression "ci1 == Categorical(ci1.values, categories=list('abc'))" is assigned to nothing
Error

Line: 43 Column: 13

                      with pytest.raises(TypeError, match=msg):
            ci1 == Categorical(ci1.values, ordered=False)
        with pytest.raises(TypeError, match=msg):
            ci1 == Categorical(ci1.values, categories=list("abc"))

        # tests
        # make sure that we are testing for category inclusion properly
        ci = CategoricalIndex(list("aabca"), categories=["c", "a", "b"])
        assert not ci.equals(list("aabca"))

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

from pandas import (
    Categorical,
    CategoricalIndex,
    Index,
    MultiIndex,
)

            

Reported by Pylint.

Missing class docstring
Error

Line: 12 Column: 1

              )


class TestEquals:
    def test_equals_categorical(self):
        ci1 = CategoricalIndex(["a", "b"], categories=["a", "b"], ordered=True)
        ci2 = CategoricalIndex(["a", "b"], categories=["a", "b", "c"], ordered=True)

        assert ci1.equals(ci1)

            

Reported by Pylint.

Method could be a function
Error

Line: 13 Column: 5

              

class TestEquals:
    def test_equals_categorical(self):
        ci1 = CategoricalIndex(["a", "b"], categories=["a", "b"], ordered=True)
        ci2 = CategoricalIndex(["a", "b"], categories=["a", "b", "c"], ordered=True)

        assert ci1.equals(ci1)
        assert not ci1.equals(ci2)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 5

              

class TestEquals:
    def test_equals_categorical(self):
        ci1 = CategoricalIndex(["a", "b"], categories=["a", "b"], ordered=True)
        ci2 = CategoricalIndex(["a", "b"], categories=["a", "b", "c"], ordered=True)

        assert ci1.equals(ci1)
        assert not ci1.equals(ci2)

            

Reported by Pylint.

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

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

                      ci1 = CategoricalIndex(["a", "b"], categories=["a", "b"], ordered=True)
        ci2 = CategoricalIndex(["a", "b"], categories=["a", "b", "c"], ordered=True)

        assert ci1.equals(ci1)
        assert not ci1.equals(ci2)
        assert ci1.equals(ci1.astype(object))
        assert ci1.astype(object).equals(ci1)

        assert (ci1 == ci1).all()

            

Reported by Bandit.

pandas/tests/series/methods/test_reset_index.py
59 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              from datetime import datetime

import numpy as np
import pytest

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

            

Reported by Pylint.

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

Line: 20 Column: 15

              
class TestResetIndex:
    def test_reset_index_dti_round_trip(self):
        dti = date_range(start="1/1/2001", end="6/1/2001", freq="D")._with_freq(None)
        d1 = DataFrame({"v": np.random.rand(len(dti))}, index=dti)
        d2 = d1.reset_index()
        assert d2.dtypes[0] == np.dtype("M8[ns]")
        d3 = d2.set_index("index")
        tm.assert_frame_equal(d1, d3, check_names=False)

            

Reported by Pylint.

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

Line: 20 Column: 15

              
class TestResetIndex:
    def test_reset_index_dti_round_trip(self):
        dti = date_range(start="1/1/2001", end="6/1/2001", freq="D")._with_freq(None)
        d1 = DataFrame({"v": np.random.rand(len(dti))}, index=dti)
        d2 = d1.reset_index()
        assert d2.dtypes[0] == np.dtype("M8[ns]")
        d3 = d2.set_index("index")
        tm.assert_frame_equal(d1, d3, check_names=False)

            

Reported by Pylint.

Access to a protected member _with_freq of a client class
Error

Line: 20 Column: 15

              
class TestResetIndex:
    def test_reset_index_dti_round_trip(self):
        dti = date_range(start="1/1/2001", end="6/1/2001", freq="D")._with_freq(None)
        d1 = DataFrame({"v": np.random.rand(len(dti))}, index=dti)
        d2 = d1.reset_index()
        assert d2.dtypes[0] == np.dtype("M8[ns]")
        d3 = d2.set_index("index")
        tm.assert_frame_equal(d1, d3, check_names=False)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from datetime import datetime

import numpy as np
import pytest

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

            

Reported by Pylint.

Missing class docstring
Error

Line: 18 Column: 1

              import pandas._testing as tm


class TestResetIndex:
    def test_reset_index_dti_round_trip(self):
        dti = date_range(start="1/1/2001", end="6/1/2001", freq="D")._with_freq(None)
        d1 = DataFrame({"v": np.random.rand(len(dti))}, index=dti)
        d2 = d1.reset_index()
        assert d2.dtypes[0] == np.dtype("M8[ns]")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 19 Column: 5

              

class TestResetIndex:
    def test_reset_index_dti_round_trip(self):
        dti = date_range(start="1/1/2001", end="6/1/2001", freq="D")._with_freq(None)
        d1 = DataFrame({"v": np.random.rand(len(dti))}, index=dti)
        d2 = d1.reset_index()
        assert d2.dtypes[0] == np.dtype("M8[ns]")
        d3 = d2.set_index("index")

            

Reported by Pylint.

Method could be a function
Error

Line: 19 Column: 5

              

class TestResetIndex:
    def test_reset_index_dti_round_trip(self):
        dti = date_range(start="1/1/2001", end="6/1/2001", freq="D")._with_freq(None)
        d1 = DataFrame({"v": np.random.rand(len(dti))}, index=dti)
        d2 = d1.reset_index()
        assert d2.dtypes[0] == np.dtype("M8[ns]")
        d3 = d2.set_index("index")

            

Reported by Pylint.

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

Line: 21 Column: 9

              class TestResetIndex:
    def test_reset_index_dti_round_trip(self):
        dti = date_range(start="1/1/2001", end="6/1/2001", freq="D")._with_freq(None)
        d1 = DataFrame({"v": np.random.rand(len(dti))}, index=dti)
        d2 = d1.reset_index()
        assert d2.dtypes[0] == np.dtype("M8[ns]")
        d3 = d2.set_index("index")
        tm.assert_frame_equal(d1, d3, check_names=False)


            

Reported by Pylint.

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

Line: 22 Column: 9

                  def test_reset_index_dti_round_trip(self):
        dti = date_range(start="1/1/2001", end="6/1/2001", freq="D")._with_freq(None)
        d1 = DataFrame({"v": np.random.rand(len(dti))}, index=dti)
        d2 = d1.reset_index()
        assert d2.dtypes[0] == np.dtype("M8[ns]")
        d3 = d2.set_index("index")
        tm.assert_frame_equal(d1, d3, check_names=False)

        # GH#2329

            

Reported by Pylint.

pandas/tests/arrays/integer/test_arithmetic.py
59 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              import operator

import numpy as np
import pytest

from pandas.compat import np_version_under1p20

import pandas as pd
import pandas._testing as tm

            

Reported by Pylint.

bad operand type for unary +: BooleanArray
Error

Line: 297 Column: 48

              def test_unary_int_operators(any_signed_int_ea_dtype, source, neg_target, abs_target):
    dtype = any_signed_int_ea_dtype
    arr = pd.array(source, dtype=dtype)
    neg_result, pos_result, abs_result = -arr, +arr, abs(arr)
    neg_target = pd.array(neg_target, dtype=dtype)
    abs_target = pd.array(abs_target, dtype=dtype)

    tm.assert_extension_array_equal(neg_result, neg_target)
    tm.assert_extension_array_equal(pos_result, arr)

            

Reported by Pylint.

bad operand type for unary -: ArrowStringArray
Error

Line: 297 Column: 42

              def test_unary_int_operators(any_signed_int_ea_dtype, source, neg_target, abs_target):
    dtype = any_signed_int_ea_dtype
    arr = pd.array(source, dtype=dtype)
    neg_result, pos_result, abs_result = -arr, +arr, abs(arr)
    neg_target = pd.array(neg_target, dtype=dtype)
    abs_target = pd.array(abs_target, dtype=dtype)

    tm.assert_extension_array_equal(neg_result, neg_target)
    tm.assert_extension_array_equal(pos_result, arr)

            

Reported by Pylint.

bad operand type for unary -: PeriodArray
Error

Line: 297 Column: 42

              def test_unary_int_operators(any_signed_int_ea_dtype, source, neg_target, abs_target):
    dtype = any_signed_int_ea_dtype
    arr = pd.array(source, dtype=dtype)
    neg_result, pos_result, abs_result = -arr, +arr, abs(arr)
    neg_target = pd.array(neg_target, dtype=dtype)
    abs_target = pd.array(abs_target, dtype=dtype)

    tm.assert_extension_array_equal(neg_result, neg_target)
    tm.assert_extension_array_equal(pos_result, arr)

            

Reported by Pylint.

bad operand type for unary -: BooleanArray
Error

Line: 297 Column: 42

              def test_unary_int_operators(any_signed_int_ea_dtype, source, neg_target, abs_target):
    dtype = any_signed_int_ea_dtype
    arr = pd.array(source, dtype=dtype)
    neg_result, pos_result, abs_result = -arr, +arr, abs(arr)
    neg_target = pd.array(neg_target, dtype=dtype)
    abs_target = pd.array(abs_target, dtype=dtype)

    tm.assert_extension_array_equal(neg_result, neg_target)
    tm.assert_extension_array_equal(pos_result, arr)

            

Reported by Pylint.

bad operand type for unary +: PeriodArray
Error

Line: 297 Column: 48

              def test_unary_int_operators(any_signed_int_ea_dtype, source, neg_target, abs_target):
    dtype = any_signed_int_ea_dtype
    arr = pd.array(source, dtype=dtype)
    neg_result, pos_result, abs_result = -arr, +arr, abs(arr)
    neg_target = pd.array(neg_target, dtype=dtype)
    abs_target = pd.array(abs_target, dtype=dtype)

    tm.assert_extension_array_equal(neg_result, neg_target)
    tm.assert_extension_array_equal(pos_result, arr)

            

Reported by Pylint.

bad operand type for unary +: IntervalArray
Error

Line: 297 Column: 48

              def test_unary_int_operators(any_signed_int_ea_dtype, source, neg_target, abs_target):
    dtype = any_signed_int_ea_dtype
    arr = pd.array(source, dtype=dtype)
    neg_result, pos_result, abs_result = -arr, +arr, abs(arr)
    neg_target = pd.array(neg_target, dtype=dtype)
    abs_target = pd.array(abs_target, dtype=dtype)

    tm.assert_extension_array_equal(neg_result, neg_target)
    tm.assert_extension_array_equal(pos_result, arr)

            

Reported by Pylint.

bad operand type for unary +: ArrowStringArray
Error

Line: 297 Column: 48

              def test_unary_int_operators(any_signed_int_ea_dtype, source, neg_target, abs_target):
    dtype = any_signed_int_ea_dtype
    arr = pd.array(source, dtype=dtype)
    neg_result, pos_result, abs_result = -arr, +arr, abs(arr)
    neg_target = pd.array(neg_target, dtype=dtype)
    abs_target = pd.array(abs_target, dtype=dtype)

    tm.assert_extension_array_equal(neg_result, neg_target)
    tm.assert_extension_array_equal(pos_result, arr)

            

Reported by Pylint.

bad operand type for unary -: IntervalArray
Error

Line: 297 Column: 42

              def test_unary_int_operators(any_signed_int_ea_dtype, source, neg_target, abs_target):
    dtype = any_signed_int_ea_dtype
    arr = pd.array(source, dtype=dtype)
    neg_result, pos_result, abs_result = -arr, +arr, abs(arr)
    neg_target = pd.array(neg_target, dtype=dtype)
    abs_target = pd.array(abs_target, dtype=dtype)

    tm.assert_extension_array_equal(neg_result, neg_target)
    tm.assert_extension_array_equal(pos_result, arr)

            

Reported by Pylint.

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

Line: 166 Column: 5

              
    op = all_arithmetic_operators
    s = pd.Series(data)
    ops = getattr(s, op)

    # invalid scalars
    msg = (
        r"(:?can only perform ops with numeric values)"
        r"|(:?IntegerArray cannot perform the operation mod)"

            

Reported by Pylint.

pandas/tests/window/moments/test_moments_rolling.py
59 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

import pandas.util._test_decorators as td

from pandas import (
    DataFrame,
    Series,
    date_range,

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

import pandas.util._test_decorators as td

from pandas import (
    DataFrame,
    Series,
    date_range,

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 14 Column: 1

              import pandas._testing as tm


def test_centered_axis_validation():

    # ok
    Series(np.ones(10)).rolling(window=3, center=True, axis=0).mean()

    # bad axis

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 35 Column: 1

              

@td.skip_if_no_scipy
def test_cmov_mean():
    # GH 8238
    vals = np.array([6.95, 15.21, 4.72, 9.12, 13.81, 13.49, 16.68, 9.48, 10.63, 14.48])
    result = Series(vals).rolling(5, center=True).mean()
    expected_values = [
        np.nan,

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 56 Column: 1

              

@td.skip_if_no_scipy
def test_cmov_window():
    # GH 8238
    vals = np.array([6.95, 15.21, 4.72, 9.12, 13.81, 13.49, 16.68, 9.48, 10.63, 14.48])
    result = Series(vals).rolling(5, win_type="boxcar", center=True).mean()
    expected_values = [
        np.nan,

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 77 Column: 1

              

@td.skip_if_no_scipy
def test_cmov_window_corner():
    # GH 8238
    # all nan
    vals = Series([np.nan] * 10)
    result = vals.rolling(5, center=True, win_type="boxcar").mean()
    assert np.isnan(result).all()

            

Reported by Pylint.

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

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

                  # all nan
    vals = Series([np.nan] * 10)
    result = vals.rolling(5, center=True, win_type="boxcar").mean()
    assert np.isnan(result).all()

    # empty
    vals = Series([], dtype=object)
    result = vals.rolling(5, center=True, win_type="boxcar").mean()
    assert len(result) == 0

            

Reported by Bandit.

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

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

                  # empty
    vals = Series([], dtype=object)
    result = vals.rolling(5, center=True, win_type="boxcar").mean()
    assert len(result) == 0

    # shorter than window
    vals = Series(np.random.randn(5))
    result = vals.rolling(10, win_type="boxcar").mean()
    assert np.isnan(result).all()

            

Reported by Bandit.

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

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

                  # shorter than window
    vals = Series(np.random.randn(5))
    result = vals.rolling(10, win_type="boxcar").mean()
    assert np.isnan(result).all()
    assert len(result) == 5


@td.skip_if_no_scipy
@pytest.mark.parametrize(

            

Reported by Bandit.

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

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

                  vals = Series(np.random.randn(5))
    result = vals.rolling(10, win_type="boxcar").mean()
    assert np.isnan(result).all()
    assert len(result) == 5


@td.skip_if_no_scipy
@pytest.mark.parametrize(
    "f,xp",

            

Reported by Bandit.

pandas/plotting/_matplotlib/boxplot.py
59 issues
__init__ method from base class 'LinePlot' is not called
Error

Line: 41 Column: 5

                  # namedtuple to hold results
    BP = namedtuple("BP", ["ax", "lines"])

    def __init__(self, data, return_type="axes", **kwargs):
        # Do not call LinePlot.__init__ which may fill nan
        if return_type not in self._valid_return_types:
            raise ValueError("return_type must be {None, 'axes', 'dict', 'both'}")

        self.return_type = return_type

            

Reported by Pylint.

__init__ method from a non direct base class 'MPLPlot' is called
Error

Line: 47 Column: 9

                          raise ValueError("return_type must be {None, 'axes', 'dict', 'both'}")

        self.return_type = return_type
        MPLPlot.__init__(self, data, **kwargs)

    def _args_adjust(self):
        if self.subplots:
            # Disable label ax sharing. Otherwise, all subplots shows last
            # column label

            

Reported by Pylint.

Parameters differ from overridden '_plot' method
Error

Line: 59 Column: 5

                              self.sharey = False

    @classmethod
    def _plot(cls, ax, y, column_num=None, return_type="axes", **kwds):
        if y.ndim == 2:
            y = [remove_na_arraylike(v) for v in y]
            # Boxplot fails with empty arrays, so need to add a NaN
            #   if any cols are empty
            # GH 8181

            

Reported by Pylint.

Attribute '_return_obj' defined outside __init__
Error

Line: 137 Column: 13

              
    def _make_plot(self):
        if self.subplots:
            self._return_obj = pd.Series(dtype=object)

            # Re-create iterated data if `by` is assigned by users
            data = (
                create_iter_data_given_by(self.data, self._kind)
                if self.by is not None

            

Reported by Pylint.

Attribute '_return_obj' defined outside __init__
Error

Line: 179 Column: 13

                              ax, y, column_num=0, return_type=self.return_type, **kwds
            )
            self.maybe_color_bp(bp)
            self._return_obj = ret

            labels = [left for left, _ in self._iter_data()]
            labels = [pprint_thing(left) for left in labels]
            if not self.use_index:
                labels = [pprint_thing(key) for key in range(len(labels))]

            

Reported by Pylint.

Unused argument 'numeric_only'
Error

Line: 219 Column: 5

                  data,
    columns=None,
    by=None,
    numeric_only=True,
    grid=False,
    figsize=None,
    ax=None,
    layout=None,
    return_type=None,

            

Reported by Pylint.

Access to a protected member _get_numeric_data of a client class
Error

Line: 231 Column: 19

                  if columns is None:
        if not isinstance(by, (list, tuple)):
            by = [by]
        columns = data._get_numeric_data().columns.difference(by)
    naxes = len(columns)
    fig, axes = create_subplots(
        naxes=naxes, sharex=True, sharey=True, figsize=figsize, ax=ax, layout=layout
    )


            

Reported by Pylint.

Access to a protected member _valid_return_types of a client class
Error

Line: 281 Column: 27

                  import matplotlib.pyplot as plt

    # validate return_type:
    if return_type not in BoxPlot._valid_return_types:
        raise ValueError("return_type must be {'axes', 'dict', 'both'}")

    if isinstance(data, pd.Series):
        data = data.to_frame("x")
        column = "x"

            

Reported by Pylint.

Access to a protected member _get_numeric_data of a client class
Error

Line: 387 Column: 16

                          rc = {"figure.figsize": figsize} if figsize is not None else {}
            with plt.rc_context(rc):
                ax = plt.gca()
        data = data._get_numeric_data()
        if columns is None:
            columns = data.columns
        else:
            data = data[columns]


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from __future__ import annotations

from collections import namedtuple
from typing import TYPE_CHECKING
import warnings

from matplotlib.artist import setp
import numpy as np


            

Reported by Pylint.

pandas/io/parsers/base_parser.py
59 issues
Unable to import 'pandas._libs.lib'
Error

Line: 21 Column: 1

              
import numpy as np

import pandas._libs.lib as lib
import pandas._libs.ops as libops
import pandas._libs.parsers as parsers
from pandas._libs.parsers import STR_NA_VALUES
from pandas._libs.tslibs import parsing
from pandas._typing import (

            

Reported by Pylint.

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

Line: 21 Column: 1

              
import numpy as np

import pandas._libs.lib as lib
import pandas._libs.ops as libops
import pandas._libs.parsers as parsers
from pandas._libs.parsers import STR_NA_VALUES
from pandas._libs.tslibs import parsing
from pandas._typing import (

            

Reported by Pylint.

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

Line: 22 Column: 1

              import numpy as np

import pandas._libs.lib as lib
import pandas._libs.ops as libops
import pandas._libs.parsers as parsers
from pandas._libs.parsers import STR_NA_VALUES
from pandas._libs.tslibs import parsing
from pandas._typing import (
    ArrayLike,

            

Reported by Pylint.

Unable to import 'pandas._libs.ops'
Error

Line: 22 Column: 1

              import numpy as np

import pandas._libs.lib as lib
import pandas._libs.ops as libops
import pandas._libs.parsers as parsers
from pandas._libs.parsers import STR_NA_VALUES
from pandas._libs.tslibs import parsing
from pandas._typing import (
    ArrayLike,

            

Reported by Pylint.

Unable to import 'pandas._libs.parsers'
Error

Line: 23 Column: 1

              
import pandas._libs.lib as lib
import pandas._libs.ops as libops
import pandas._libs.parsers as parsers
from pandas._libs.parsers import STR_NA_VALUES
from pandas._libs.tslibs import parsing
from pandas._typing import (
    ArrayLike,
    DtypeArg,

            

Reported by Pylint.

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

Line: 23 Column: 1

              
import pandas._libs.lib as lib
import pandas._libs.ops as libops
import pandas._libs.parsers as parsers
from pandas._libs.parsers import STR_NA_VALUES
from pandas._libs.tslibs import parsing
from pandas._typing import (
    ArrayLike,
    DtypeArg,

            

Reported by Pylint.

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

Line: 24 Column: 1

              import pandas._libs.lib as lib
import pandas._libs.ops as libops
import pandas._libs.parsers as parsers
from pandas._libs.parsers import STR_NA_VALUES
from pandas._libs.tslibs import parsing
from pandas._typing import (
    ArrayLike,
    DtypeArg,
    FilePathOrBuffer,

            

Reported by Pylint.

Unable to import 'pandas._libs.parsers'
Error

Line: 24 Column: 1

              import pandas._libs.lib as lib
import pandas._libs.ops as libops
import pandas._libs.parsers as parsers
from pandas._libs.parsers import STR_NA_VALUES
from pandas._libs.tslibs import parsing
from pandas._typing import (
    ArrayLike,
    DtypeArg,
    FilePathOrBuffer,

            

Reported by Pylint.

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

Line: 25 Column: 1

              import pandas._libs.ops as libops
import pandas._libs.parsers as parsers
from pandas._libs.parsers import STR_NA_VALUES
from pandas._libs.tslibs import parsing
from pandas._typing import (
    ArrayLike,
    DtypeArg,
    FilePathOrBuffer,
)

            

Reported by Pylint.

TODO: this is for consistency with
Error

Line: 750 Column: 3

                          )

            if not is_object_dtype(values) and not known_cats:
                # TODO: this is for consistency with
                # c-parser which parses all categories
                # as strings

                values = astype_nansafe(values, np.dtype(str))


            

Reported by Pylint.

pandas/tests/plotting/frame/test_frame_legend.py
58 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

from pandas import (
    DataFrame,
    date_range,
)
from pandas.tests.plotting.common import TestPlotBase


            

Reported by Pylint.

Method 'plt' has no 'subplots' member
Error

Line: 116 Column: 19

                  def test_missing_marker_multi_plots_on_same_ax(self):
        # GH 18222
        df = DataFrame(data=[[1, 1, 1, 1], [2, 2, 4, 8]], columns=["x", "r", "g", "b"])
        fig, ax = self.plt.subplots(nrows=1, ncols=3)
        # Left plot
        df.plot(x="x", y="r", linewidth=0, marker="o", color="r", ax=ax[0])
        df.plot(x="x", y="g", linewidth=1, marker="x", color="g", ax=ax[0])
        df.plot(x="x", y="b", linewidth=1, marker="o", color="b", ax=ax[0])
        self._check_legend_labels(ax[0], labels=["r", "g", "b"])

            

Reported by Pylint.

Method 'plt' has no 'subplots' member
Error

Line: 190 Column: 19

                          }
        )

        fig, ax = self.plt.subplots()
        for kind in "ABC":
            df.plot("X", kind, label=kind, ax=ax, style=".")

        self._check_legend_labels(ax, labels=["A", "B", "C"])
        self._check_legend_marker(ax, expected_markers=[".", ".", "."])

            

Reported by Pylint.

Unused variable 'fig'
Error

Line: 116 Column: 9

                  def test_missing_marker_multi_plots_on_same_ax(self):
        # GH 18222
        df = DataFrame(data=[[1, 1, 1, 1], [2, 2, 4, 8]], columns=["x", "r", "g", "b"])
        fig, ax = self.plt.subplots(nrows=1, ncols=3)
        # Left plot
        df.plot(x="x", y="r", linewidth=0, marker="o", color="r", ax=ax[0])
        df.plot(x="x", y="g", linewidth=1, marker="x", color="g", ax=ax[0])
        df.plot(x="x", y="b", linewidth=1, marker="o", color="b", ax=ax[0])
        self._check_legend_labels(ax[0], labels=["r", "g", "b"])

            

Reported by Pylint.

Unused variable 'fig'
Error

Line: 190 Column: 9

                          }
        )

        fig, ax = self.plt.subplots()
        for kind in "ABC":
            df.plot("X", kind, label=kind, ax=ax, style=".")

        self._check_legend_labels(ax, labels=["A", "B", "C"])
        self._check_legend_marker(ax, expected_markers=[".", ".", "."])

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

from pandas import (
    DataFrame,
    date_range,
)
from pandas.tests.plotting.common import TestPlotBase


            

Reported by Pylint.

Missing class docstring
Error

Line: 13 Column: 1

              pytestmark = pytest.mark.slow


class TestFrameLegend(TestPlotBase):
    @pytest.mark.xfail(
        reason=(
            "Open bug in matplotlib "
            "https://github.com/matplotlib/matplotlib/issues/11357"
        )

            

Reported by Pylint.

Method could be a function
Error

Line: 17 Column: 5

                  @pytest.mark.xfail(
        reason=(
            "Open bug in matplotlib "
            "https://github.com/matplotlib/matplotlib/issues/11357"
        )
    )
    def test_mixed_yerr(self):
        # https://github.com/pandas-dev/pandas/issues/39522
        from matplotlib.collections import LineCollection

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 5

                  @pytest.mark.xfail(
        reason=(
            "Open bug in matplotlib "
            "https://github.com/matplotlib/matplotlib/issues/11357"
        )
    )
    def test_mixed_yerr(self):
        # https://github.com/pandas-dev/pandas/issues/39522
        from matplotlib.collections import LineCollection

            

Reported by Pylint.

Import outside toplevel (matplotlib.collections.LineCollection)
Error

Line: 22 Column: 9

                  )
    def test_mixed_yerr(self):
        # https://github.com/pandas-dev/pandas/issues/39522
        from matplotlib.collections import LineCollection
        from matplotlib.lines import Line2D

        df = DataFrame([{"x": 1, "a": 1, "b": 1}, {"x": 2, "a": 2, "b": 3}])

        ax = df.plot("x", "a", c="orange", yerr=0.1, label="orange")

            

Reported by Pylint.

pandas/tests/indexes/timedeltas/test_setops.py
58 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

import pandas as pd
from pandas import (
    Int64Index,
    TimedeltaIndex,
    timedelta_range,
)

            

Reported by Pylint.

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

Line: 54 Column: 31

              
        result = ordered[:0].union(ordered)
        tm.assert_index_equal(result, ordered)
        assert result.freq == ordered.freq

    def test_union_bug_1730(self):

        rng_a = timedelta_range("1 day", periods=4, freq="3H")
        rng_b = timedelta_range("1 day", periods=4, freq="4H")

            

Reported by Pylint.

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

Line: 115 Column: 31

                          result = index_1 & index_2
        expected = timedelta_range("1 day 01:00:00", periods=3, freq="h")
        tm.assert_index_equal(result, expected)
        assert result.freq == expected.freq

    def test_intersection_equal(self, sort):
        # GH 24471 Test intersection outcome given the sort keyword
        # for equal indices intersection should return the original index
        first = timedelta_range("1 day", periods=4, freq="h")

            

Reported by Pylint.

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

Line: 115 Column: 31

                          result = index_1 & index_2
        expected = timedelta_range("1 day 01:00:00", periods=3, freq="h")
        tm.assert_index_equal(result, expected)
        assert result.freq == expected.freq

    def test_intersection_equal(self, sort):
        # GH 24471 Test intersection outcome given the sort keyword
        # for equal indices intersection should return the original index
        first = timedelta_range("1 day", periods=4, freq="h")

            

Reported by Pylint.

Access to a protected member _can_fast_union of a client class
Error

Line: 36 Column: 16

                      right = tdi[:3]

        # Check that we are testing the desired code path
        assert left._can_fast_union(right)

        result = left.union(right)
        tm.assert_index_equal(result, tdi)

        result = left.union(right, sort=False)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

import pandas as pd
from pandas import (
    Int64Index,
    TimedeltaIndex,
    timedelta_range,
)

            

Reported by Pylint.

Missing class docstring
Error

Line: 15 Column: 1

              from pandas.tseries.offsets import Hour


class TestTimedeltaIndex:
    def test_union(self):

        i1 = timedelta_range("1day", periods=5)
        i2 = timedelta_range("3day", periods=5)
        result = i1.union(i2)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 16 Column: 5

              

class TestTimedeltaIndex:
    def test_union(self):

        i1 = timedelta_range("1day", periods=5)
        i2 = timedelta_range("3day", periods=5)
        result = i1.union(i2)
        expected = timedelta_range("1day", periods=7)

            

Reported by Pylint.

Method could be a function
Error

Line: 16 Column: 5

              

class TestTimedeltaIndex:
    def test_union(self):

        i1 = timedelta_range("1day", periods=5)
        i2 = timedelta_range("3day", periods=5)
        result = i1.union(i2)
        expected = timedelta_range("1day", periods=7)

            

Reported by Pylint.

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

Line: 18 Column: 9

              class TestTimedeltaIndex:
    def test_union(self):

        i1 = timedelta_range("1day", periods=5)
        i2 = timedelta_range("3day", periods=5)
        result = i1.union(i2)
        expected = timedelta_range("1day", periods=7)
        tm.assert_index_equal(result, expected)


            

Reported by Pylint.

pandas/tests/extension/test_datetime.py
58 issues
Unable to import 'pytest'
Error

Line: 17 Column: 1

              
"""
import numpy as np
import pytest

from pandas.core.dtypes.dtypes import DatetimeTZDtype

import pandas as pd
from pandas.core.arrays import DatetimeArray

            

Reported by Pylint.

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

Line: 32 Column: 10

              

@pytest.fixture
def data(dtype):
    data = DatetimeArray(pd.date_range("2000", periods=100, tz=dtype.tz), dtype=dtype)
    return data


@pytest.fixture

            

Reported by Pylint.

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

Line: 33 Column: 5

              
@pytest.fixture
def data(dtype):
    data = DatetimeArray(pd.date_range("2000", periods=100, tz=dtype.tz), dtype=dtype)
    return data


@pytest.fixture
def data_missing(dtype):

            

Reported by Pylint.

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

Line: 38 Column: 18

              

@pytest.fixture
def data_missing(dtype):
    return DatetimeArray(
        np.array(["NaT", "2000-01-01"], dtype="datetime64[ns]"), dtype=dtype
    )



            

Reported by Pylint.

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

Line: 45 Column: 22

              

@pytest.fixture
def data_for_sorting(dtype):
    a = pd.Timestamp("2000-01-01")
    b = pd.Timestamp("2000-01-02")
    c = pd.Timestamp("2000-01-03")
    return DatetimeArray(np.array([b, c, a], dtype="datetime64[ns]"), dtype=dtype)


            

Reported by Pylint.

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

Line: 53 Column: 30

              

@pytest.fixture
def data_missing_for_sorting(dtype):
    a = pd.Timestamp("2000-01-01")
    b = pd.Timestamp("2000-01-02")
    return DatetimeArray(np.array([b, "NaT", a], dtype="datetime64[ns]"), dtype=dtype)



            

Reported by Pylint.

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

Line: 60 Column: 23

              

@pytest.fixture
def data_for_grouping(dtype):
    """
    Expected to be like [B, B, NA, NA, A, A, B, C]

    Where A < B < C and NA is missing
    """

            

Reported by Pylint.

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

Line: 100 Column: 39

              

class TestConstructors(BaseDatetimeTests, base.BaseConstructorsTests):
    def test_series_constructor(self, data):
        # Series construction drops any .freq attr
        data = data._with_freq(None)
        super().test_series_constructor(data)



            

Reported by Pylint.

Access to a protected member _with_freq of a client class
Error

Line: 102 Column: 16

              class TestConstructors(BaseDatetimeTests, base.BaseConstructorsTests):
    def test_series_constructor(self, data):
        # Series construction drops any .freq attr
        data = data._with_freq(None)
        super().test_series_constructor(data)


class TestGetitem(BaseDatetimeTests, base.BaseGetitemTests):
    pass

            

Reported by Pylint.

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

Line: 121 Column: 36

              

class TestInterface(BaseDatetimeTests, base.BaseInterfaceTests):
    def test_array_interface(self, data):
        if data.tz:
            # np.asarray(DTA) is currently always tz-naive.
            pytest.skip("GH-23569")
        else:
            super().test_array_interface(data)

            

Reported by Pylint.

pandas/tests/extension/test_string.py
58 issues
Unable to import 'pytest'
Error

Line: 19 Column: 1

              import string

import numpy as np
import pytest

import pandas as pd
from pandas.core.arrays.string_ import StringDtype
from pandas.tests.extension import base


            

Reported by Pylint.

Unable to import 'pyarrow'
Error

Line: 31 Column: 9

                      pytest.skip("chunked array n/a")

    def _split_array(arr):
        import pyarrow as pa

        arrow_array = arr._data
        split = len(arrow_array) // 2
        arrow_array = pa.chunked_array(
            [*arrow_array[:split].chunks, *arrow_array[split:].chunks]

            

Reported by Pylint.

Access to a protected member _data of a client class
Error

Line: 33 Column: 23

                  def _split_array(arr):
        import pyarrow as pa

        arrow_array = arr._data
        split = len(arrow_array) // 2
        arrow_array = pa.chunked_array(
            [*arrow_array[:split].chunks, *arrow_array[split:].chunks]
        )
        assert arrow_array.num_chunks == 2

            

Reported by Pylint.

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

Line: 55 Column: 10

              

@pytest.fixture
def data(dtype, chunked):
    strings = np.random.choice(list(string.ascii_letters), size=100)
    while strings[0] == strings[1]:
        strings = np.random.choice(list(string.ascii_letters), size=100)

    arr = dtype.construct_array_type()._from_sequence(strings)

            

Reported by Pylint.

Redefining name 'chunked' from outer scope (line 45)
Error

Line: 55 Column: 17

              

@pytest.fixture
def data(dtype, chunked):
    strings = np.random.choice(list(string.ascii_letters), size=100)
    while strings[0] == strings[1]:
        strings = np.random.choice(list(string.ascii_letters), size=100)

    arr = dtype.construct_array_type()._from_sequence(strings)

            

Reported by Pylint.

Access to a protected member _from_sequence of a client class
Error

Line: 60 Column: 11

                  while strings[0] == strings[1]:
        strings = np.random.choice(list(string.ascii_letters), size=100)

    arr = dtype.construct_array_type()._from_sequence(strings)
    return split_array(arr) if chunked else arr


@pytest.fixture
def data_missing(dtype, chunked):

            

Reported by Pylint.

Redefining name 'chunked' from outer scope (line 45)
Error

Line: 65 Column: 25

              

@pytest.fixture
def data_missing(dtype, chunked):
    """Length 2 array with [NA, Valid]"""
    arr = dtype.construct_array_type()._from_sequence([pd.NA, "A"])
    return split_array(arr) if chunked else arr



            

Reported by Pylint.

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

Line: 65 Column: 18

              

@pytest.fixture
def data_missing(dtype, chunked):
    """Length 2 array with [NA, Valid]"""
    arr = dtype.construct_array_type()._from_sequence([pd.NA, "A"])
    return split_array(arr) if chunked else arr



            

Reported by Pylint.

Access to a protected member _from_sequence of a client class
Error

Line: 67 Column: 11

              @pytest.fixture
def data_missing(dtype, chunked):
    """Length 2 array with [NA, Valid]"""
    arr = dtype.construct_array_type()._from_sequence([pd.NA, "A"])
    return split_array(arr) if chunked else arr


@pytest.fixture
def data_for_sorting(dtype, chunked):

            

Reported by Pylint.

Redefining name 'chunked' from outer scope (line 45)
Error

Line: 72 Column: 29

              

@pytest.fixture
def data_for_sorting(dtype, chunked):
    arr = dtype.construct_array_type()._from_sequence(["B", "C", "A"])
    return split_array(arr) if chunked else arr


@pytest.fixture

            

Reported by Pylint.