The following issues were found

pandas/tests/reshape/test_cut.py
73 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

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

            

Reported by Pylint.

Unused variable 'bins'
Error

Line: 234 Column: 13

              def test_labels(right, breaks, closed):
    arr = np.tile(np.arange(0, 1.01, 0.1), 4)

    result, bins = cut(arr, 4, retbins=True, right=right)
    ex_levels = IntervalIndex.from_breaks(breaks, closed=closed)
    tm.assert_index_equal(result.categories, ex_levels)


def test_cut_pass_series_name_to_factor():

            

Reported by Pylint.

Access to a protected member _round_frac of a client class
Error

Line: 346 Column: 14

              )
def test_round_frac(val, precision, expected):
    # see gh-1979
    result = tmod._round_frac(val, precision=precision)
    assert result == expected


def test_cut_return_intervals():
    ser = Series([0, 1, 2, 3, 4, 5, 6, 7, 8])

            

Reported by Pylint.

Unused variable 'bins'
Error

Line: 368 Column: 13

              def test_series_ret_bins():
    # see gh-8589
    ser = Series(np.arange(4))
    result, bins = cut(ser, 2, retbins=True)

    expected = Series(
        IntervalIndex.from_breaks([-0.003, 1.5, 3], closed="right").repeat(2)
    ).astype(CDT(ordered=True))
    tm.assert_series_equal(result, expected)

            

Reported by Pylint.

Lambda may not be necessary
Error

Line: 430 Column: 9

              @pytest.mark.parametrize(
    "conv",
    [
        lambda v: Timestamp(v),
        lambda v: to_datetime(v),
        lambda v: np.datetime64(v),
        lambda v: Timestamp(v).to_pydatetime(),
    ],
)

            

Reported by Pylint.

Lambda may not be necessary
Error

Line: 431 Column: 9

                  "conv",
    [
        lambda v: Timestamp(v),
        lambda v: to_datetime(v),
        lambda v: np.datetime64(v),
        lambda v: Timestamp(v).to_pydatetime(),
    ],
)
def test_datetime_bin(conv):

            

Reported by Pylint.

Lambda may not be necessary
Error

Line: 432 Column: 9

                  [
        lambda v: Timestamp(v),
        lambda v: to_datetime(v),
        lambda v: np.datetime64(v),
        lambda v: Timestamp(v).to_pydatetime(),
    ],
)
def test_datetime_bin(conv):
    data = [np.datetime64("2012-12-13"), np.datetime64("2012-12-15")]

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

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

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 27 Column: 1

              import pandas.core.reshape.tile as tmod


def test_simple():
    data = np.ones(5, dtype="int64")
    result = cut(data, 4, labels=False)

    expected = np.array([1, 1, 1, 1, 1])
    tm.assert_numpy_array_equal(result, expected, check_dtype=False)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 36 Column: 1

              

@pytest.mark.parametrize("func", [list, np.array])
def test_bins(func):
    data = func([0.2, 1.4, 2.5, 6.2, 9.7, 2.1])
    result, bins = cut(data, 3, retbins=True)

    intervals = IntervalIndex.from_breaks(bins.round(3))
    intervals = intervals.take([0, 0, 0, 1, 2, 0])

            

Reported by Pylint.

pandas/tests/util/test_hashing.py
73 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

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

            

Reported by Pylint.

Redefining name 'series' from outer scope (line 29)
Error

Line: 87 Column: 21

                  tm.assert_series_equal(result, expected)


def test_hash_array(series):
    arr = series.values
    tm.assert_numpy_array_equal(hash_array(arr), hash_array(arr))


@pytest.mark.parametrize(

            

Reported by Pylint.

Access to a protected member _sort_levels_monotonic of a client class
Error

Line: 143 Column: 14

                      codes=[[0, 1, 0, 2], [2, 0, 0, 1]],
        names=["col1", "col2"],
    )
    recons = mi._sort_levels_monotonic()

    # These are equal.
    assert mi.equals(recons)
    assert Index(mi.values).equals(Index(recons.values))


            

Reported by Pylint.

Redefining name 'index' from outer scope (line 36)
Error

Line: 180 Column: 34

                      MultiIndex.from_product([pd.CategoricalIndex(list("aabc")), range(3)]),
    ],
)
def test_hash_pandas_object(obj, index):
    _check_equal(obj, index=index)
    _check_not_equal_with_index(obj)


def test_hash_pandas_object2(series, index):

            

Reported by Pylint.

Redefining name 'index' from outer scope (line 36)
Error

Line: 185 Column: 38

                  _check_not_equal_with_index(obj)


def test_hash_pandas_object2(series, index):
    _check_equal(series, index=index)
    _check_not_equal_with_index(series)


@pytest.mark.parametrize(

            

Reported by Pylint.

Redefining name 'series' from outer scope (line 29)
Error

Line: 185 Column: 30

                  _check_not_equal_with_index(obj)


def test_hash_pandas_object2(series, index):
    _check_equal(series, index=index)
    _check_not_equal_with_index(series)


@pytest.mark.parametrize(

            

Reported by Pylint.

Redefining name 'index' from outer scope (line 36)
Error

Line: 193 Column: 40

              @pytest.mark.parametrize(
    "obj", [Series([], dtype="float64"), Series([], dtype="object"), Index([])]
)
def test_hash_pandas_empty_object(obj, index):
    # These are by-definition the same with
    # or without the index as the data is empty.
    _check_equal(obj, index=index)



            

Reported by Pylint.

Redefining name 'index' from outer scope (line 36)
Error

Line: 292 Column: 26

                      hash_pandas_object(Series(list("abc")), hash_key="foo")


def test_already_encoded(index):
    # If already encoded, then ok.
    obj = Series(list("abc")).str.encode("utf8")
    _check_equal(obj, index=index)



            

Reported by Pylint.

Redefining name 'index' from outer scope (line 36)
Error

Line: 298 Column: 29

                  _check_equal(obj, index=index)


def test_alternate_encoding(index):
    obj = Series(list("abc"))
    _check_equal(obj, index=index, encoding="ascii")


@pytest.mark.parametrize("l_exp", range(8))

            

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,
    Index,
    MultiIndex,
    Series,

            

Reported by Pylint.

pandas/core/indexes/datetimelike.py
73 issues
No name 'lib' in module 'pandas._libs'
Error

Line: 20 Column: 1

              
import numpy as np

from pandas._libs import (
    NaT,
    Timedelta,
    lib,
)
from pandas._libs.tslibs import (

            

Reported by Pylint.

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

Line: 25 Column: 1

                  Timedelta,
    lib,
)
from pandas._libs.tslibs import (
    BaseOffset,
    NaTType,
    Resolution,
    Tick,
    parsing,

            

Reported by Pylint.

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

Line: 683 Column: 22

                          # With sort being False, we can't infer that result.freq == self.freq
            # TODO: no tests rely on the _with_freq("infer"); needed?
            result = type(self)._simple_new(dates, name=self.name)
            result = result._with_freq("infer")
            return result
        else:
            left, right = other, self

        left_end = left[-1]

            

Reported by Pylint.

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

Line: 683 Column: 22

                          # With sort being False, we can't infer that result.freq == self.freq
            # TODO: no tests rely on the _with_freq("infer"); needed?
            result = type(self)._simple_new(dates, name=self.name)
            result = result._with_freq("infer")
            return result
        else:
            left, right = other, self

        left_end = left[-1]

            

Reported by Pylint.

Access to a protected member _index_doc_kwargs of a client class
Error

Line: 70 Column: 26

              if TYPE_CHECKING:
    from pandas import CategoricalIndex

_index_doc_kwargs = dict(ibase._index_doc_kwargs)

_T = TypeVar("_T", bound="DatetimeIndexOpsMixin")


@inherit_names(

            

Reported by Pylint.

Access to a protected member _hasnans of a client class
Error

Line: 97 Column: 9

              
    # error: "Callable[[Any], Any]" has no attribute "fget"
    hasnans = cache_readonly(
        DatetimeLikeArrayMixin._hasnans.fget  # type: ignore[attr-defined]
    )

    @property
    def _is_all_dates(self) -> bool:
        return True

            

Reported by Pylint.

Method '_is_all_dates' was expected to be 'method', found it instead as 'property'
Error

Line: 101 Column: 5

                  )

    @property
    def _is_all_dates(self) -> bool:
        return True

    # ------------------------------------------------------------------------
    # Abstract data attributes


            

Reported by Pylint.

Access to a protected member _ndarray of a client class
Error

Line: 110 Column: 16

                  @property
    def values(self) -> np.ndarray:
        # Note: PeriodArray overrides this to return an ndarray of objects.
        return self._data._ndarray

    def __array_wrap__(self, result, context=None):
        """
        Gets called after a ufunc and other functions.
        """

            

Reported by Pylint.

Access to a protected member _with_freq of a client class
Error

Line: 118 Column: 19

                      """
        out = super().__array_wrap__(result, context=context)
        if isinstance(out, DatetimeTimedeltaMixin) and self.freq is not None:
            out = out._with_freq("infer")
        return out

    # ------------------------------------------------------------------------

    def equals(self, other: Any) -> bool:

            

Reported by Pylint.

Access to a protected member _infer_matches of a client class
Error

Line: 136 Column: 25

                          return False
        elif not isinstance(other, type(self)):
            should_try = False
            inferable = self._data._infer_matches
            if other.dtype == object:
                should_try = other.inferred_type in inferable
            elif is_categorical_dtype(other.dtype):
                other = cast("CategoricalIndex", other)
                should_try = other.categories.inferred_type in inferable

            

Reported by Pylint.

pandas/tests/frame/methods/test_interpolate.py
73 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.

TODO: assert something?
Error

Line: 210 Column: 3

                          }
        )
        df.interpolate(axis=0)
        # TODO: assert something?

    @pytest.mark.parametrize(
        "check_scipy", [False, pytest.param(True, marks=td.skip_if_no_scipy)]
    )
    def test_interp_leading_nans(self, check_scipy):

            

Reported by Pylint.

Unused argument 'axis'
Error

Line: 306 Column: 45

                      result = df[["B", "D"]].interpolate(downcast=None)
        tm.assert_frame_equal(result, df[["B", "D"]])

    def test_interp_time_inplace_axis(self, axis):
        # GH 9687
        periods = 5
        idx = date_range(start="2014-01-01", periods=periods)
        data = np.random.rand(periods, periods)
        data[data < 0.5] = np.nan

            

Reported by Pylint.

TODO(ArrayManager) support axis=1
Error

Line: 331 Column: 3

                      expected = df.interpolate(method="linear", axis=axis_number)
        tm.assert_frame_equal(result, expected)

    @td.skip_array_manager_not_yet_implemented  # TODO(ArrayManager) support axis=1
    @pytest.mark.parametrize("method", ["ffill", "bfill", "pad"])
    def test_interp_fillna_methods(self, axis, method):
        # GH 12918
        df = DataFrame(
            {

            

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 class docstring
Error

Line: 14 Column: 1

              import pandas._testing as tm


class TestDataFrameInterpolate:
    def test_interp_basic(self):
        df = DataFrame(
            {
                "A": [1, 2, np.nan, 4],
                "B": [1, 4, 9, np.nan],

            

Reported by Pylint.

Method could be a function
Error

Line: 15 Column: 5

              

class TestDataFrameInterpolate:
    def test_interp_basic(self):
        df = DataFrame(
            {
                "A": [1, 2, np.nan, 4],
                "B": [1, 4, 9, np.nan],
                "C": [1, 2, 3, 5],

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 15 Column: 5

              

class TestDataFrameInterpolate:
    def test_interp_basic(self):
        df = DataFrame(
            {
                "A": [1, 2, np.nan, 4],
                "B": [1, 4, 9, np.nan],
                "C": [1, 2, 3, 5],

            

Reported by Pylint.

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

Line: 16 Column: 9

              
class TestDataFrameInterpolate:
    def test_interp_basic(self):
        df = DataFrame(
            {
                "A": [1, 2, np.nan, 4],
                "B": [1, 4, 9, np.nan],
                "C": [1, 2, 3, 5],
                "D": list("abcd"),

            

Reported by Pylint.

Method could be a function
Error

Line: 41 Column: 5

                      expected.loc[5, "B"] = 9
        tm.assert_frame_equal(result, expected)

    def test_interp_empty(self):
        # https://github.com/pandas-dev/pandas/issues/35598
        df = DataFrame()
        result = df.interpolate()
        assert result is not df
        expected = df

            

Reported by Pylint.

pandas/tests/io/test_clipboard.py
73 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              from textwrap import dedent

import numpy as np
import pytest

from pandas import (
    DataFrame,
    get_option,
    read_clipboard,

            

Reported by Pylint.

Redefining name 'mock_clipboard' from outer scope (line 114)
Error

Line: 142 Column: 25

              

@pytest.mark.clipboard
def test_mock_clipboard(mock_clipboard):
    import pandas.io.clipboard

    pandas.io.clipboard.clipboard_set("abc")
    assert "abc" in set(mock_clipboard.values())
    result = pandas.io.clipboard.clipboard_get()

            

Reported by Pylint.

Redefining name 'df' from outer scope (line 40)
Error

Line: 161 Column: 37

                      tm.assert_frame_equal(data, result)

    # Test that default arguments copy as tab delimited
    def test_round_trip_frame(self, df):
        self.check_round_trip_frame(df)

    # Test that explicit delimiters are respected
    @pytest.mark.parametrize("sep", ["\t", ",", "|"])
    def test_round_trip_frame_sep(self, df, sep):

            

Reported by Pylint.

Redefining name 'df' from outer scope (line 40)
Error

Line: 166 Column: 41

              
    # Test that explicit delimiters are respected
    @pytest.mark.parametrize("sep", ["\t", ",", "|"])
    def test_round_trip_frame_sep(self, df, sep):
        self.check_round_trip_frame(df, sep=sep)

    # Test white space separator
    def test_round_trip_frame_string(self, df):
        df.to_clipboard(excel=False, sep=None)

            

Reported by Pylint.

Redefining name 'df' from outer scope (line 40)
Error

Line: 170 Column: 44

                      self.check_round_trip_frame(df, sep=sep)

    # Test white space separator
    def test_round_trip_frame_string(self, df):
        df.to_clipboard(excel=False, sep=None)
        result = read_clipboard()
        assert df.to_string() == result.to_string()
        assert df.shape == result.shape


            

Reported by Pylint.

Redefining name 'df' from outer scope (line 40)
Error

Line: 178 Column: 38

              
    # Two character separator is not supported in to_clipboard
    # Test that multi-character separators are not silently passed
    def test_excel_sep_warning(self, df):
        with tm.assert_produces_warning():
            df.to_clipboard(excel=True, sep=r"\t")

    # Separator is ignored when excel=False and should produce a warning
    def test_copy_delim_warning(self, df):

            

Reported by Pylint.

Redefining name 'df' from outer scope (line 40)
Error

Line: 183 Column: 39

                          df.to_clipboard(excel=True, sep=r"\t")

    # Separator is ignored when excel=False and should produce a warning
    def test_copy_delim_warning(self, df):
        with tm.assert_produces_warning():
            df.to_clipboard(excel=False, sep="\t")

    # Tests that the default behavior of to_clipboard is tab
    # delimited and excel="True"

            

Reported by Pylint.

Redefining name 'df' from outer scope (line 40)
Error

Line: 191 Column: 60

                  # delimited and excel="True"
    @pytest.mark.parametrize("sep", ["\t", None, "default"])
    @pytest.mark.parametrize("excel", [True, None, "default"])
    def test_clipboard_copy_tabs_default(self, sep, excel, df, request, mock_clipboard):
        kwargs = build_kwargs(sep, excel)
        df.to_clipboard(**kwargs)
        assert mock_clipboard[request.node.name] == df.to_csv(sep="\t")

    # Tests reading of white space separated tables

            

Reported by Pylint.

Redefining name 'mock_clipboard' from outer scope (line 114)
Error

Line: 191 Column: 73

                  # delimited and excel="True"
    @pytest.mark.parametrize("sep", ["\t", None, "default"])
    @pytest.mark.parametrize("excel", [True, None, "default"])
    def test_clipboard_copy_tabs_default(self, sep, excel, df, request, mock_clipboard):
        kwargs = build_kwargs(sep, excel)
        df.to_clipboard(**kwargs)
        assert mock_clipboard[request.node.name] == df.to_csv(sep="\t")

    # Tests reading of white space separated tables

            

Reported by Pylint.

Redefining name 'df' from outer scope (line 40)
Error

Line: 199 Column: 55

                  # Tests reading of white space separated tables
    @pytest.mark.parametrize("sep", [None, "default"])
    @pytest.mark.parametrize("excel", [False])
    def test_clipboard_copy_strings(self, sep, excel, df):
        kwargs = build_kwargs(sep, excel)
        df.to_clipboard(**kwargs)
        result = read_clipboard(sep=r"\s+")
        assert result.to_string() == df.to_string()
        assert df.shape == result.shape

            

Reported by Pylint.

pandas/tests/indexes/multi/test_setops.py
73 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

import pandas as pd
from pandas import (
    CategoricalIndex,
    Index,
    IntervalIndex,
    MultiIndex,

            

Reported by Pylint.

TODO decide on True behaviour
Error

Line: 206 Column: 3

              
@pytest.mark.xfail(reason="Not implemented.")
def test_difference_sort_special_true():
    # TODO decide on True behaviour
    idx = MultiIndex.from_product([[1, 0], ["a", "b"]])
    result = idx.difference([], sort=True)
    expected = MultiIndex.from_product([[0, 1], ["a", "b"]])
    tm.assert_index_equal(result, expected)


            

Reported by Pylint.

FIXME: dont leave commented-out
Error

Line: 256 Column: 3

                  the_union = idx.union(idx[:0], sort=sort)
    tm.assert_index_equal(the_union, idx)

    # FIXME: dont leave commented-out
    # won't work in python 3
    # tuples = _index.values
    # result = _index[:4] | tuples[4:]
    # assert result.equals(tuples)


            

Reported by Pylint.

FIXME: dont leave commented-out
Error

Line: 293 Column: 3

                  expected = idx[:0]
    assert empty.equals(expected)

    # FIXME: dont leave commented-out
    # can't do in python 3
    # tuples = _index.values
    # result = _index & tuples
    # assert result.equals(tuples)


            

Reported by Pylint.

TODO decide on True behaviour
Error

Line: 343 Column: 3

              
@pytest.mark.xfail(reason="Not implemented.")
def test_intersect_equal_sort_true():
    # TODO decide on True behaviour
    idx = MultiIndex.from_product([[1, 0], ["a", "b"]])
    sorted_ = MultiIndex.from_product([[0, 1], ["a", "b"]])
    tm.assert_index_equal(idx.intersection(idx, sort=True), sorted_)



            

Reported by Pylint.

Unused argument 'slice_'
Error

Line: 365 Column: 38

              

@pytest.mark.xfail(reason="Not implemented.")
def test_union_sort_other_empty_sort(slice_):
    # TODO decide on True behaviour
    # # sort=True
    idx = MultiIndex.from_product([[1, 0], ["a", "b"]])
    other = idx[:0]
    result = idx.union(other, sort=True)

            

Reported by Pylint.

TODO decide on True behaviour
Error

Line: 366 Column: 3

              
@pytest.mark.xfail(reason="Not implemented.")
def test_union_sort_other_empty_sort(slice_):
    # TODO decide on True behaviour
    # # sort=True
    idx = MultiIndex.from_product([[1, 0], ["a", "b"]])
    other = idx[:0]
    result = idx.union(other, sort=True)
    expected = MultiIndex.from_product([[0, 1], ["a", "b"]])

            

Reported by Pylint.

TODO decide on True behaviour
Error

Line: 391 Column: 3

              
@pytest.mark.xfail(reason="Not implemented.")
def test_union_sort_other_incomparable_sort():
    # TODO decide on True behaviour
    # # sort=True
    idx = MultiIndex.from_product([[1, pd.Timestamp("2000")], ["a", "b"]])
    with pytest.raises(TypeError, match="Cannot compare"):
        idx.union(idx[:1], sort=True)


            

Reported by Pylint.

Access to a protected member _maybe_match_names of a client class
Error

Line: 483 Column: 14

                  # GH#38323
    mi = MultiIndex.from_tuples([], names=["a", "b"])
    mi2 = MultiIndex.from_tuples([data], names=names)
    result = mi._maybe_match_names(mi2)
    assert result == expected


def test_intersection_equal_different_names():
    # GH#30302

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

import pandas as pd
from pandas import (
    CategoricalIndex,
    Index,
    IntervalIndex,
    MultiIndex,

            

Reported by Pylint.

pandas/tests/test_sorting.py
72 issues
Unable to import 'pytest'
Error

Line: 6 Column: 1

              from itertools import product

import numpy as np
import pytest

from pandas import (
    DataFrame,
    MultiIndex,
    Series,

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from collections import defaultdict
from datetime import datetime
from itertools import product

import numpy as np
import pytest

from pandas import (
    DataFrame,

            

Reported by Pylint.

Missing class docstring
Error

Line: 28 Column: 1

              )


class TestSorting:
    @pytest.mark.slow
    def test_int64_overflow(self):

        B = np.concatenate((np.arange(1000), np.arange(1000), np.arange(500)))
        A = np.arange(2500)

            

Reported by Pylint.

Method could be a function
Error

Line: 30 Column: 5

              
class TestSorting:
    @pytest.mark.slow
    def test_int64_overflow(self):

        B = np.concatenate((np.arange(1000), np.arange(1000), np.arange(500)))
        A = np.arange(2500)
        df = DataFrame(
            {

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 30 Column: 5

              
class TestSorting:
    @pytest.mark.slow
    def test_int64_overflow(self):

        B = np.concatenate((np.arange(1000), np.arange(1000), np.arange(500)))
        A = np.arange(2500)
        df = DataFrame(
            {

            

Reported by Pylint.

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

Line: 32 Column: 9

                  @pytest.mark.slow
    def test_int64_overflow(self):

        B = np.concatenate((np.arange(1000), np.arange(1000), np.arange(500)))
        A = np.arange(2500)
        df = DataFrame(
            {
                "A": A,
                "B": B,

            

Reported by Pylint.

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

Line: 33 Column: 9

                  def test_int64_overflow(self):

        B = np.concatenate((np.arange(1000), np.arange(1000), np.arange(500)))
        A = np.arange(2500)
        df = DataFrame(
            {
                "A": A,
                "B": B,
                "C": A,

            

Reported by Pylint.

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

Line: 34 Column: 9

              
        B = np.concatenate((np.arange(1000), np.arange(1000), np.arange(500)))
        A = np.arange(2500)
        df = DataFrame(
            {
                "A": A,
                "B": B,
                "C": A,
                "D": B,

            

Reported by Pylint.

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

Line: 48 Column: 9

                          }
        )

        lg = df.groupby(["A", "B", "C", "D", "E", "F", "G", "H"])
        rg = df.groupby(["H", "G", "F", "E", "D", "C", "B", "A"])

        left = lg.sum()["values"]
        right = rg.sum()["values"]


            

Reported by Pylint.

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

Line: 49 Column: 9

                      )

        lg = df.groupby(["A", "B", "C", "D", "E", "F", "G", "H"])
        rg = df.groupby(["H", "G", "F", "E", "D", "C", "B", "A"])

        left = lg.sum()["values"]
        right = rg.sum()["values"]

        exp_index, _ = left.index.sortlevel()

            

Reported by Pylint.

asv_bench/benchmarks/sparse.py
72 issues
Unable to import 'scipy.sparse'
Error

Line: 2 Column: 1

              import numpy as np
import scipy.sparse

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

            

Reported by Pylint.

Unable to import 'pandas'
Error

Line: 4 Column: 1

              import numpy as np
import scipy.sparse

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

            

Reported by Pylint.

Unable to import 'pandas'
Error

Line: 5 Column: 1

              import scipy.sparse

import pandas as pd
from pandas import (
    MultiIndex,
    Series,
    date_range,
)
from pandas.arrays import SparseArray

            

Reported by Pylint.

Unable to import 'pandas.arrays'
Error

Line: 10 Column: 1

                  Series,
    date_range,
)
from pandas.arrays import SparseArray


def make_array(size, dense_proportion, fill_value, dtype):
    dense_size = int(size * dense_proportion)
    arr = np.full(size, fill_value, dtype)

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 143 Column: 1

                      self.arr1 / self.arr2


from .pandas_vb_common import setup  # noqa: F401 isort:skip

            

Reported by Pylint.

Attribute 'series' defined outside __init__
Error

Line: 26 Column: 9

                      K = 50
        N = 50001
        rng = date_range("1/1/2000", periods=N, freq="T")
        self.series = {}
        for i in range(1, K):
            data = np.random.randn(N)[:-i]
            idx = rng[:-i]
            data[100:] = np.nan
            self.series[i] = Series(SparseArray(data), index=idx)

            

Reported by Pylint.

Attribute 'array' defined outside __init__
Error

Line: 44 Column: 9

              
    def setup(self, dense_proportion, fill_value, dtype):
        N = 10 ** 6
        self.array = make_array(N, dense_proportion, fill_value, dtype)

    def time_sparse_array(self, dense_proportion, fill_value, dtype):
        SparseArray(self.array, fill_value=fill_value, dtype=dtype)



            

Reported by Pylint.

Unused argument 'dense_proportion'
Error

Line: 46 Column: 33

                      N = 10 ** 6
        self.array = make_array(N, dense_proportion, fill_value, dtype)

    def time_sparse_array(self, dense_proportion, fill_value, dtype):
        SparseArray(self.array, fill_value=fill_value, dtype=dtype)


class SparseDataFrameConstructor:
    def setup(self):

            

Reported by Pylint.

Attribute 'sparse' defined outside __init__
Error

Line: 53 Column: 9

              class SparseDataFrameConstructor:
    def setup(self):
        N = 1000
        self.sparse = scipy.sparse.rand(N, N, 0.005)

    def time_from_scipy(self):
        pd.DataFrame.sparse.from_spmatrix(self.sparse)



            

Reported by Pylint.

Attribute 'matrix' defined outside __init__
Error

Line: 61 Column: 9

              
class FromCoo:
    def setup(self):
        self.matrix = scipy.sparse.coo_matrix(
            ([3.0, 1.0, 2.0], ([1, 0, 0], [0, 2, 3])), shape=(100, 100)
        )

    def time_sparse_series_from_coo(self):
        Series.sparse.from_coo(self.matrix)

            

Reported by Pylint.

pandas/tests/io/sas/test_sas7bdat.py
72 issues
Unable to import 'pytest'
Error

Line: 8 Column: 1

              
import dateutil.parser
import numpy as np
import pytest

from pandas.errors import (
    EmptyDataError,
    PerformanceWarning,
)

            

Reported by Pylint.

Unable to import 'py.path'
Error

Line: 90 Column: 9

                  @td.skip_if_no("py.path")
    @pytest.mark.slow
    def test_path_localpath(self):
        from py.path import local as LocalPath

        for j in 0, 1:
            df0 = self.data[j]
            for k in self.test_ix[j]:
                fname = LocalPath(os.path.join(self.dirpath, f"test{k}.sas7bdat"))

            

Reported by Pylint.

Module 'pandas._libs.tslibs' has no 'np_datetime' member
Error

Line: 266 Column: 12

                  # GH 19732: Timestamps imported from sas will incur floating point errors
    try:
        df["dt_as_dt"] = df["dt_as_dt"].dt.round("us")
    except pd._libs.tslibs.np_datetime.OutOfBoundsDatetime:
        df = df.applymap(round_datetime_to_ms)
    except AttributeError:
        df["dt_as_dt"] = df["dt_as_dt"].apply(round_datetime_to_ms)
    # if there are any date/times > pandas.Timestamp.max then ALL in that chunk
    # are returned as datetime.datetime

            

Reported by Pylint.

Module 'pandas._libs.tslibs' has no 'np_datetime' member
Error

Line: 302 Column: 16

                      # GH 19732: Timestamps imported from sas will incur floating point errors
        try:
            df["dt_as_dt"] = df["dt_as_dt"].dt.round("us")
        except pd._libs.tslibs.np_datetime.OutOfBoundsDatetime:
            df = df.applymap(round_datetime_to_ms)
        except AttributeError:
            df["dt_as_dt"] = df["dt_as_dt"].apply(round_datetime_to_ms)
        df.reset_index(inplace=True, drop=True)
        results.append(df)

            

Reported by Pylint.

Attribute 'dirpath' defined outside __init__
Error

Line: 25 Column: 9

              class TestSAS7BDAT:
    @pytest.fixture(autouse=True)
    def setup_method(self, datapath):
        self.dirpath = datapath("io", "sas", "data")
        self.data = []
        self.test_ix = [list(range(1, 16)), [16]]
        for j in 1, 2:
            fname = os.path.join(self.dirpath, f"test_sas7bdat_{j}.csv")
            df = pd.read_csv(fname)

            

Reported by Pylint.

Attribute 'data' defined outside __init__
Error

Line: 26 Column: 9

                  @pytest.fixture(autouse=True)
    def setup_method(self, datapath):
        self.dirpath = datapath("io", "sas", "data")
        self.data = []
        self.test_ix = [list(range(1, 16)), [16]]
        for j in 1, 2:
            fname = os.path.join(self.dirpath, f"test_sas7bdat_{j}.csv")
            df = pd.read_csv(fname)
            epoch = datetime(1960, 1, 1)

            

Reported by Pylint.

Attribute 'test_ix' defined outside __init__
Error

Line: 27 Column: 9

                  def setup_method(self, datapath):
        self.dirpath = datapath("io", "sas", "data")
        self.data = []
        self.test_ix = [list(range(1, 16)), [16]]
        for j in 1, 2:
            fname = os.path.join(self.dirpath, f"test_sas7bdat_{j}.csv")
            df = pd.read_csv(fname)
            epoch = datetime(1960, 1, 1)
            t1 = pd.to_timedelta(df["Column4"], unit="d")

            

Reported by Pylint.

Access to a protected member _libs of a client class
Error

Line: 266 Column: 12

                  # GH 19732: Timestamps imported from sas will incur floating point errors
    try:
        df["dt_as_dt"] = df["dt_as_dt"].dt.round("us")
    except pd._libs.tslibs.np_datetime.OutOfBoundsDatetime:
        df = df.applymap(round_datetime_to_ms)
    except AttributeError:
        df["dt_as_dt"] = df["dt_as_dt"].apply(round_datetime_to_ms)
    # if there are any date/times > pandas.Timestamp.max then ALL in that chunk
    # are returned as datetime.datetime

            

Reported by Pylint.

Access to a protected member _libs of a client class
Error

Line: 302 Column: 16

                      # GH 19732: Timestamps imported from sas will incur floating point errors
        try:
            df["dt_as_dt"] = df["dt_as_dt"].dt.round("us")
        except pd._libs.tslibs.np_datetime.OutOfBoundsDatetime:
            df = df.applymap(round_datetime_to_ms)
        except AttributeError:
            df["dt_as_dt"] = df["dt_as_dt"].apply(round_datetime_to_ms)
        df.reset_index(inplace=True, drop=True)
        results.append(df)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from datetime import datetime
import io
import os
from pathlib import Path

import dateutil.parser
import numpy as np
import pytest


            

Reported by Pylint.

pandas/tests/indexes/multi/test_sorting.py
72 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              import random

import numpy as np
import pytest

from pandas.errors import (
    PerformanceWarning,
    UnsortedIndexError,
)

            

Reported by Pylint.

Module 'numpy.random' has no 'RandomState' member
Error

Line: 238 Column: 11

                  # because tests should be deterministic (and this test in particular
    # checks that levels are removed, which is not the case for every
    # random input):
    rng = np.random.RandomState(4)  # seed is arbitrary value that works

    size = 1 << 16
    df = DataFrame(
        {
            "first": rng.randint(0, 1 << 13, size).astype(first_type),

            

Reported by Pylint.

Expression "df.loc(axis=0)['z', slice('a')]" is assigned to nothing
Error

Line: 122 Column: 9

                      r"slicing on levels \[1\], lexsort depth 0"
    )
    with pytest.raises(UnsortedIndexError, match=msg):
        df.loc(axis=0)["z", slice("a")]
    df.sort_index(inplace=True)
    assert len(df.loc(axis=0)["z", :]) == 2

    with pytest.raises(KeyError, match="'q'"):
        df.loc(axis=0)["q", :]

            

Reported by Pylint.

Expression "df.loc(axis=0)['q', :]" is assigned to nothing
Error

Line: 127 Column: 9

                  assert len(df.loc(axis=0)["z", :]) == 2

    with pytest.raises(KeyError, match="'q'"):
        df.loc(axis=0)["q", :]


def test_unsortedindex_doc_examples():
    # https://pandas.pydata.org/pandas-docs/stable/advanced.html#sorting-a-multiindex
    dfm = DataFrame(

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 138 Column: 9

              
    dfm = dfm.set_index(["jim", "joe"])
    with tm.assert_produces_warning(PerformanceWarning):
        dfm.loc[(1, "z")]

    msg = r"Key length \(2\) was greater than MultiIndex lexsort depth \(1\)"
    with pytest.raises(UnsortedIndexError, match=msg):
        dfm.loc[(0, "y"):(1, "z")]


            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 142 Column: 9

              
    msg = r"Key length \(2\) was greater than MultiIndex lexsort depth \(1\)"
    with pytest.raises(UnsortedIndexError, match=msg):
        dfm.loc[(0, "y"):(1, "z")]

    assert not dfm.index._is_lexsorted()
    assert dfm.index._lexsort_depth == 1

    # sort it

            

Reported by Pylint.

Access to a protected member _is_lexsorted of a client class
Error

Line: 144 Column: 16

                  with pytest.raises(UnsortedIndexError, match=msg):
        dfm.loc[(0, "y"):(1, "z")]

    assert not dfm.index._is_lexsorted()
    assert dfm.index._lexsort_depth == 1

    # sort it
    dfm = dfm.sort_index()
    dfm.loc[(1, "z")]

            

Reported by Pylint.

Access to a protected member _lexsort_depth of a client class
Error

Line: 145 Column: 12

                      dfm.loc[(0, "y"):(1, "z")]

    assert not dfm.index._is_lexsorted()
    assert dfm.index._lexsort_depth == 1

    # sort it
    dfm = dfm.sort_index()
    dfm.loc[(1, "z")]
    dfm.loc[(0, "y"):(1, "z")]

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 149 Column: 5

              
    # sort it
    dfm = dfm.sort_index()
    dfm.loc[(1, "z")]
    dfm.loc[(0, "y"):(1, "z")]

    assert dfm.index._is_lexsorted()
    assert dfm.index._lexsort_depth == 2


            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 150 Column: 5

                  # sort it
    dfm = dfm.sort_index()
    dfm.loc[(1, "z")]
    dfm.loc[(0, "y"):(1, "z")]

    assert dfm.index._is_lexsorted()
    assert dfm.index._lexsort_depth == 2



            

Reported by Pylint.