The following issues were found

pandas/tests/frame/methods/test_select_dtypes.py
108 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

from pandas.core.dtypes.dtypes import ExtensionDtype

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

            

Reported by Pylint.

Method '__setitem__' is abstract in class 'ExtensionArray' but is not overridden
Error

Line: 30 Column: 1

                      return self._numeric


class DummyArray(ExtensionArray):
    def __init__(self, data, dtype):
        self.data = data
        self._dtype = dtype

    def __array__(self, dtype):

            

Reported by Pylint.

Unused argument 'dtype'
Error

Line: 35 Column: 25

                      self.data = data
        self._dtype = dtype

    def __array__(self, dtype):
        return self.data

    @property
    def dtype(self):
        return self._dtype

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

from pandas.core.dtypes.dtypes import ExtensionDtype

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

            

Reported by Pylint.

Missing class docstring
Error

Line: 15 Column: 1

              from pandas.core.arrays import ExtensionArray


class DummyDtype(ExtensionDtype):
    type = int

    def __init__(self, numeric):
        self._numeric = numeric


            

Reported by Pylint.

Missing class docstring
Error

Line: 30 Column: 1

                      return self._numeric


class DummyArray(ExtensionArray):
    def __init__(self, data, dtype):
        self.data = data
        self._dtype = dtype

    def __array__(self, dtype):

            

Reported by Pylint.

Missing class docstring
Error

Line: 52 Column: 1

                      return self


class TestSelectDtypes:
    def test_select_dtypes_include_using_list_like(self):
        df = DataFrame(
            {
                "a": list("abc"),
                "b": list(range(1, 4)),

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 53 Column: 5

              

class TestSelectDtypes:
    def test_select_dtypes_include_using_list_like(self):
        df = DataFrame(
            {
                "a": list("abc"),
                "b": list(range(1, 4)),
                "c": np.arange(3, 6).astype("u1"),

            

Reported by Pylint.

Method could be a function
Error

Line: 53 Column: 5

              

class TestSelectDtypes:
    def test_select_dtypes_include_using_list_like(self):
        df = DataFrame(
            {
                "a": list("abc"),
                "b": list(range(1, 4)),
                "c": np.arange(3, 6).astype("u1"),

            

Reported by Pylint.

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

Line: 54 Column: 9

              
class TestSelectDtypes:
    def test_select_dtypes_include_using_list_like(self):
        df = DataFrame(
            {
                "a": list("abc"),
                "b": list(range(1, 4)),
                "c": np.arange(3, 6).astype("u1"),
                "d": np.arange(4.0, 7.0, dtype="float64"),

            

Reported by Pylint.

pandas/tests/reshape/merge/test_multi.py
108 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.

Attribute 'index' defined outside __init__
Error

Line: 82 Column: 9

              
class TestMergeMulti:
    def setup_method(self):
        self.index = MultiIndex(
            levels=[["foo", "bar", "baz", "qux"], ["one", "two", "three"]],
            codes=[[0, 0, 0, 1, 1, 2, 2, 3, 3, 3], [0, 1, 2, 0, 1, 1, 2, 0, 1, 2]],
            names=["first", "second"],
        )
        self.to_join = DataFrame(

            

Reported by Pylint.

Attribute 'to_join' defined outside __init__
Error

Line: 87 Column: 9

                          codes=[[0, 0, 0, 1, 1, 2, 2, 3, 3, 3], [0, 1, 2, 0, 1, 1, 2, 0, 1, 2]],
            names=["first", "second"],
        )
        self.to_join = DataFrame(
            np.random.randn(10, 3),
            index=self.index,
            columns=["j_one", "j_two", "j_three"],
        )


            

Reported by Pylint.

Attribute 'data' defined outside __init__
Error

Line: 109 Column: 9

                      ]

        data = np.random.randn(len(key1))
        self.data = DataFrame({"key1": key1, "key2": key2, "data": data})

    def test_merge_on_multikey(self, left, right, join_type):
        on_cols = ["key1", "key2"]
        result = left.join(right, on=on_cols, how=join_type).reset_index(drop=True)


            

Reported by Pylint.

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

Line: 111 Column: 44

                      data = np.random.randn(len(key1))
        self.data = DataFrame({"key1": key1, "key2": key2, "data": data})

    def test_merge_on_multikey(self, left, right, join_type):
        on_cols = ["key1", "key2"]
        result = left.join(right, on=on_cols, how=join_type).reset_index(drop=True)

        expected = merge(left, right.reset_index(), on=on_cols, how=join_type)


            

Reported by Pylint.

Redefining name 'left' from outer scope (line 18)
Error

Line: 111 Column: 38

                      data = np.random.randn(len(key1))
        self.data = DataFrame({"key1": key1, "key2": key2, "data": data})

    def test_merge_on_multikey(self, left, right, join_type):
        on_cols = ["key1", "key2"]
        result = left.join(right, on=on_cols, how=join_type).reset_index(drop=True)

        expected = merge(left, right.reset_index(), on=on_cols, how=join_type)


            

Reported by Pylint.

Redefining name 'left' from outer scope (line 18)
Error

Line: 130 Column: 42

                      tm.assert_frame_equal(result, expected)

    @pytest.mark.parametrize("sort", [False, True])
    def test_left_join_multi_index(self, left, right, sort):
        icols = ["1st", "2nd", "3rd"]

        def bind_cols(df):
            iord = lambda a: 0 if a != a else ord(a)
            f = lambda ts: ts.map(iord) - ord("a")

            

Reported by Pylint.

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

Line: 130 Column: 48

                      tm.assert_frame_equal(result, expected)

    @pytest.mark.parametrize("sort", [False, True])
    def test_left_join_multi_index(self, left, right, sort):
        icols = ["1st", "2nd", "3rd"]

        def bind_cols(df):
            iord = lambda a: 0 if a != a else ord(a)
            f = lambda ts: ts.map(iord) - ord("a")

            

Reported by Pylint.

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

Line: 138 Column: 31

                          f = lambda ts: ts.map(iord) - ord("a")
            return f(df["1st"]) + f(df["3rd"]) * 1e2 + df["2nd"].fillna(0) * 1e4

        def run_asserts(left, right, sort):
            res = left.join(right, on=icols, how="left", sort=sort)

            assert len(left) < len(res) + 1
            assert not res["4th"].isna().any()
            assert not res["5th"].isna().any()

            

Reported by Pylint.

Redefining name 'left' from outer scope (line 18)
Error

Line: 138 Column: 25

                          f = lambda ts: ts.map(iord) - ord("a")
            return f(df["1st"]) + f(df["3rd"]) * 1e2 + df["2nd"].fillna(0) * 1e4

        def run_asserts(left, right, sort):
            res = left.join(right, on=icols, how="left", sort=sort)

            assert len(left) < len(res) + 1
            assert not res["4th"].isna().any()
            assert not res["5th"].isna().any()

            

Reported by Pylint.

pandas/tests/window/test_timeseries_window.py
108 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

from pandas import (
    DataFrame,
    Index,
    MultiIndex,
    Series,
    Timestamp,

            

Reported by Pylint.

Unused argument 'method'
Error

Line: 23 Column: 28

                  # rolling time-series friendly
    # xref GH13327

    def setup_method(self, method):

        self.regular = DataFrame(
            {"A": date_range("20130101", periods=5, freq="s"), "B": range(5)}
        ).set_index("A")


            

Reported by Pylint.

Attribute 'regular' defined outside __init__
Error

Line: 25 Column: 9

              
    def setup_method(self, method):

        self.regular = DataFrame(
            {"A": date_range("20130101", periods=5, freq="s"), "B": range(5)}
        ).set_index("A")

        self.ragged = DataFrame({"B": range(5)})
        self.ragged.index = [

            

Reported by Pylint.

Attribute 'ragged' defined outside __init__
Error

Line: 29 Column: 9

                          {"A": date_range("20130101", periods=5, freq="s"), "B": range(5)}
        ).set_index("A")

        self.ragged = DataFrame({"B": range(5)})
        self.ragged.index = [
            Timestamp("20130101 09:00:00"),
            Timestamp("20130101 09:00:02"),
            Timestamp("20130101 09:00:03"),
            Timestamp("20130101 09:00:05"),

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 50 Column: 9

                              Timestamp("20130101 09:00:06"),
            ],
        )
        df
        df.rolling("2s").sum()

    def test_invalid_window_non_int(self):

        # not a valid freq

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

from pandas import (
    DataFrame,
    Index,
    MultiIndex,
    Series,
    Timestamp,

            

Reported by Pylint.

Too many public methods (36/20)
Error

Line: 18 Column: 1

              import pandas.tseries.offsets as offsets


class TestRollingTS:

    # rolling time-series friendly
    # xref GH13327

    def setup_method(self, method):

            

Reported by Pylint.

Missing class docstring
Error

Line: 18 Column: 1

              import pandas.tseries.offsets as offsets


class TestRollingTS:

    # rolling time-series friendly
    # xref GH13327

    def setup_method(self, method):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 23 Column: 5

                  # rolling time-series friendly
    # xref GH13327

    def setup_method(self, method):

        self.regular = DataFrame(
            {"A": date_range("20130101", periods=5, freq="s"), "B": range(5)}
        ).set_index("A")


            

Reported by Pylint.

Method could be a function
Error

Line: 38 Column: 5

                          Timestamp("20130101 09:00:06"),
        ]

    def test_doc_string(self):

        df = DataFrame(
            {"B": [0, 1, 2, np.nan, 4]},
            index=[
                Timestamp("20130101 09:00:00"),

            

Reported by Pylint.

pandas/tests/indexing/multiindex/test_setitem.py
108 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

import pandas.util._test_decorators as td

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

            

Reported by Pylint.

TODO(ArrayManager) df.loc["bar"] *= 2 doesn't raise an error but results in
Error

Line: 124 Column: 3

                          expected=copy,
        )

    # TODO(ArrayManager) df.loc["bar"] *= 2 doesn't raise an error but results in
    # all NaNs -> doesn't work in the "split" path (also for BlockManager actually)
    @td.skip_array_manager_not_yet_implemented
    def test_multiindex_setitem(self):

        # GH 3738

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 264 Column: 13

              
        with pytest.raises(KeyError, match="49"):
            # GH#33355 dont fall-back to positional when leading level is int
            s[49]

    def test_frame_getitem_setitem_boolean(self, multiindex_dataframe_random_data):
        frame = multiindex_dataframe_random_data
        df = frame.T.copy()
        values = df.values

            

Reported by Pylint.

TODO: no setitem here?
Error

Line: 352 Column: 3

                      assert sliced_a2.name == ("A", "2")
        assert sliced_b1.name == ("B", "1")

    # TODO: no setitem here?
    def test_getitem_setitem_tuple_plus_columns(
        self, multiindex_year_month_day_dataframe_random_data
    ):
        # GH #1013
        ymd = multiindex_year_month_day_dataframe_random_data

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

import pandas.util._test_decorators as td

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

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 20 Column: 1

              import pandas.core.common as com


def assert_equal(a, b):
    assert a == b


class TestMultiIndexSetItem:
    def check(self, target, indexers, value, compare_fn=assert_equal, expected=None):

            

Reported by Pylint.

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

Line: 20 Column: 1

              import pandas.core.common as com


def assert_equal(a, b):
    assert a == b


class TestMultiIndexSetItem:
    def check(self, target, indexers, value, compare_fn=assert_equal, expected=None):

            

Reported by Pylint.

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

Line: 20 Column: 1

              import pandas.core.common as com


def assert_equal(a, b):
    assert a == b


class TestMultiIndexSetItem:
    def check(self, target, indexers, value, compare_fn=assert_equal, expected=None):

            

Reported by Pylint.

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

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

              

def assert_equal(a, b):
    assert a == b


class TestMultiIndexSetItem:
    def check(self, target, indexers, value, compare_fn=assert_equal, expected=None):
        target.loc[indexers] = value

            

Reported by Bandit.

Missing class docstring
Error

Line: 24 Column: 1

                  assert a == b


class TestMultiIndexSetItem:
    def check(self, target, indexers, value, compare_fn=assert_equal, expected=None):
        target.loc[indexers] = value
        result = target.loc[indexers]
        if expected is None:
            expected = value

            

Reported by Pylint.

pandas/tests/series/indexing/test_where.py
108 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.core.dtypes.common import is_integer

import pandas as pd
from pandas import (

            

Reported by Pylint.

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

Line: 500 Column: 10

                  # GH#37682
    tz = tz_naive_fixture

    dr = date_range("2001-01-01", periods=3, tz=tz)._with_freq(None)
    lvals = pd.DatetimeIndex([dr[0], dr[1], pd.NaT])
    rvals = pd.Categorical([dr[0], pd.NaT, dr[2]])

    mask = np.array([True, True, False])


            

Reported by Pylint.

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

Line: 500 Column: 10

                  # GH#37682
    tz = tz_naive_fixture

    dr = date_range("2001-01-01", periods=3, tz=tz)._with_freq(None)
    lvals = pd.DatetimeIndex([dr[0], dr[1], pd.NaT])
    rvals = pd.Categorical([dr[0], pd.NaT, dr[2]])

    mask = np.array([True, True, False])


            

Reported by Pylint.

TODO(ArrayManager) DataFrame.values not yet correctly returning datetime array
Error

Line: 493 Column: 3

                  tm.assert_equal(exp, res)


# TODO(ArrayManager) DataFrame.values not yet correctly returning datetime array
# for categorical with datetime categories
@td.skip_array_manager_not_yet_implemented
def test_where_datetimelike_categorical(tz_naive_fixture):
    # GH#37682
    tz = tz_naive_fixture

            

Reported by Pylint.

Access to a protected member _with_freq of a client class
Error

Line: 500 Column: 10

                  # GH#37682
    tz = tz_naive_fixture

    dr = date_range("2001-01-01", periods=3, tz=tz)._with_freq(None)
    lvals = pd.DatetimeIndex([dr[0], dr[1], pd.NaT])
    rvals = pd.Categorical([dr[0], pd.NaT, dr[2]])

    mask = np.array([True, True, False])


            

Reported by Pylint.

Access to a protected member _data of a client class
Error

Line: 511 Column: 11

                  tm.assert_index_equal(res, dr)

    # DatetimeArray.where
    res = lvals._data.where(mask, rvals)
    tm.assert_datetime_array_equal(res, dr._data)

    # Series.where
    res = Series(lvals).where(mask, rvals)
    tm.assert_series_equal(res, Series(dr))

            

Reported by Pylint.

Access to a protected member _data of a client class
Error

Line: 512 Column: 41

              
    # DatetimeArray.where
    res = lvals._data.where(mask, rvals)
    tm.assert_datetime_array_equal(res, dr._data)

    # Series.where
    res = Series(lvals).where(mask, rvals)
    tm.assert_series_equal(res, Series(dr))


            

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.core.dtypes.common import is_integer

import pandas as pd
from pandas import (

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 18 Column: 1

              import pandas._testing as tm


def test_where_unsafe_int(any_signed_int_numpy_dtype):
    s = Series(np.arange(10), dtype=any_signed_int_numpy_dtype)
    mask = s < 5

    s[mask] = range(2, 7)
    expected = Series(

            

Reported by Pylint.

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

Line: 19 Column: 5

              

def test_where_unsafe_int(any_signed_int_numpy_dtype):
    s = Series(np.arange(10), dtype=any_signed_int_numpy_dtype)
    mask = s < 5

    s[mask] = range(2, 7)
    expected = Series(
        list(range(2, 7)) + list(range(5, 10)),

            

Reported by Pylint.

pandas/tests/resample/test_resample_api.py
105 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,
    NamedAgg,

            

Reported by Pylint.

Redefining name 'test_frame' from outer scope (line 22)
Error

Line: 97 Column: 15

                  tm.assert_frame_equal(result, expected)


def test_pipe(test_frame):
    # GH17905

    # series
    r = test_series.resample("H")
    expected = r.max() - r.mean()

            

Reported by Pylint.

Redefining name 'test_frame' from outer scope (line 22)
Error

Line: 113 Column: 18

                  tm.assert_frame_equal(result, expected)


def test_getitem(test_frame):

    r = test_frame.resample("H")
    tm.assert_index_equal(r._selected_obj.columns, test_frame.columns)

    r = test_frame.resample("H")["B"]

            

Reported by Pylint.

Access to a protected member _selected_obj of a client class
Error

Line: 116 Column: 27

              def test_getitem(test_frame):

    r = test_frame.resample("H")
    tm.assert_index_equal(r._selected_obj.columns, test_frame.columns)

    r = test_frame.resample("H")["B"]
    assert r._selected_obj.name == test_frame.columns[1]

    # technically this is allowed

            

Reported by Pylint.

Access to a protected member _selected_obj of a client class
Error

Line: 119 Column: 12

                  tm.assert_index_equal(r._selected_obj.columns, test_frame.columns)

    r = test_frame.resample("H")["B"]
    assert r._selected_obj.name == test_frame.columns[1]

    # technically this is allowed
    r = test_frame.resample("H")["A", "B"]
    tm.assert_index_equal(r._selected_obj.columns, test_frame.columns[[0, 1]])


            

Reported by Pylint.

Access to a protected member _selected_obj of a client class
Error

Line: 123 Column: 27

              
    # technically this is allowed
    r = test_frame.resample("H")["A", "B"]
    tm.assert_index_equal(r._selected_obj.columns, test_frame.columns[[0, 1]])

    r = test_frame.resample("H")["A", "B"]
    tm.assert_index_equal(r._selected_obj.columns, test_frame.columns[[0, 1]])



            

Reported by Pylint.

Access to a protected member _selected_obj of a client class
Error

Line: 126 Column: 27

                  tm.assert_index_equal(r._selected_obj.columns, test_frame.columns[[0, 1]])

    r = test_frame.resample("H")["A", "B"]
    tm.assert_index_equal(r._selected_obj.columns, test_frame.columns[[0, 1]])


@pytest.mark.parametrize("key", [["D"], ["A", "D"]])
def test_select_bad_cols(key, test_frame):
    g = test_frame.resample("H")

            

Reported by Pylint.

Redefining name 'test_frame' from outer scope (line 22)
Error

Line: 130 Column: 31

              

@pytest.mark.parametrize("key", [["D"], ["A", "D"]])
def test_select_bad_cols(key, test_frame):
    g = test_frame.resample("H")
    # 'A' should not be referenced as a bad column...
    # will have to rethink regex if you change message!
    msg = r"^\"Columns not found: 'D'\"$"
    with pytest.raises(KeyError, match=msg):

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 136 Column: 9

                  # will have to rethink regex if you change message!
    msg = r"^\"Columns not found: 'D'\"$"
    with pytest.raises(KeyError, match=msg):
        g[key]


def test_attribute_access(test_frame):

    r = test_frame.resample("H")

            

Reported by Pylint.

Redefining name 'test_frame' from outer scope (line 22)
Error

Line: 139 Column: 27

                      g[key]


def test_attribute_access(test_frame):

    r = test_frame.resample("H")
    tm.assert_series_equal(r.A.sum(), r["A"].sum())



            

Reported by Pylint.

pandas/tests/indexes/categorical/test_indexing.py
105 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

from pandas.errors import InvalidIndexError

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

            

Reported by Pylint.

Access to a protected member _data of a client class
Error

Line: 327 Column: 13

                      msg = "Cannot setitem on a Categorical with a new category"
        with pytest.raises(TypeError, match=msg):
            # Test the Categorical method directly
            ci._data.where(mask, 2)


class TestContains:
    def test_contains(self):


            

Reported by Pylint.

Access to a protected member _data of a client class
Error

Line: 357 Column: 19

              
        obj = ci
        if unwrap:
            obj = ci._data

        assert np.nan in obj
        assert None in obj
        assert pd.NaT in obj
        assert np.datetime64("NaT") in obj

            

Reported by Pylint.

Access to a protected member _data of a client class
Error

Line: 367 Column: 20

              
        obj2 = CategoricalIndex(tdi)
        if unwrap:
            obj2 = obj2._data

        assert np.nan in obj2
        assert None in obj2
        assert pd.NaT in obj2
        assert np.datetime64("NaT") not in obj2

            

Reported by Pylint.

Access to a protected member _data of a client class
Error

Line: 377 Column: 20

              
        obj3 = CategoricalIndex(pi)
        if unwrap:
            obj3 = obj3._data

        assert np.nan in obj3
        assert None in obj3
        assert pd.NaT in obj3
        assert np.datetime64("NaT") not in obj3

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 410 Column: 13

                      assert "a" not in idx

        with pytest.raises(TypeError, match="unhashable type"):
            ["a"] in idx

        with pytest.raises(TypeError, match="unhashable type"):
            ["a", "b"] in idx

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 413 Column: 13

                          ["a"] in idx

        with pytest.raises(TypeError, match="unhashable type"):
            ["a", "b"] in idx

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

from pandas.errors import InvalidIndexError

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

            

Reported by Pylint.

Missing class docstring
Error

Line: 16 Column: 1

              import pandas._testing as tm


class TestTake:
    def test_take_fill_value(self):
        # GH 12631

        # numeric category
        idx = CategoricalIndex([1, 2, 3], name="xxx")

            

Reported by Pylint.

Method could be a function
Error

Line: 17 Column: 5

              

class TestTake:
    def test_take_fill_value(self):
        # GH 12631

        # numeric category
        idx = CategoricalIndex([1, 2, 3], name="xxx")
        result = idx.take(np.array([1, 0, -1]))

            

Reported by Pylint.

pandas/tests/reshape/test_get_dummies.py
105 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              import re

import numpy as np
import pytest

from pandas.core.dtypes.common import is_integer_dtype

import pandas as pd
from pandas import (

            

Reported by Pylint.

Lambda may not be necessary
Error

Line: 237 Column: 47

                      expected = expected[["C"] + cols]

        typ = SparseArray if sparse else Series
        expected[cols] = expected[cols].apply(lambda x: typ(x))
        tm.assert_frame_equal(result, expected)

    def test_dataframe_dummies_prefix_str(self, df, sparse):
        # not that you should do this...
        result = get_dummies(df, prefix="bad", sparse=sparse)

            

Reported by Pylint.

Unused argument 'dtype'
Error

Line: 502 Column: 78

                          expected = expected.apply(SparseArray, fill_value=0)
        tm.assert_frame_equal(result, expected)

    def test_dataframe_dummies_drop_first_with_categorical(self, df, sparse, dtype):
        df["cat"] = Categorical(["x", "y", "y"])
        result = get_dummies(df, drop_first=True, sparse=sparse)
        expected = DataFrame(
            {"C": [1, 2, 3], "A_b": [0, 1, 0], "B_c": [0, 0, 1], "cat_y": [0, 1, 1]}
        )

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import re

import numpy as np
import pytest

from pandas.core.dtypes.common import is_integer_dtype

import pandas as pd
from pandas import (

            

Reported by Pylint.

Missing class docstring
Error

Line: 23 Column: 1

              )


class TestGetDummies:
    @pytest.fixture
    def df(self):
        return DataFrame({"A": ["a", "b", "a"], "B": ["b", "b", "c"], "C": [1, 2, 3]})

    @pytest.fixture(params=["uint8", "i8", np.float64, bool, None])

            

Reported by Pylint.

Too many public methods (35/20)
Error

Line: 23 Column: 1

              )


class TestGetDummies:
    @pytest.fixture
    def df(self):
        return DataFrame({"A": ["a", "b", "a"], "B": ["b", "b", "c"], "C": [1, 2, 3]})

    @pytest.fixture(params=["uint8", "i8", np.float64, bool, None])

            

Reported by Pylint.

Method could be a function
Error

Line: 25 Column: 5

              
class TestGetDummies:
    @pytest.fixture
    def df(self):
        return DataFrame({"A": ["a", "b", "a"], "B": ["b", "b", "c"], "C": [1, 2, 3]})

    @pytest.fixture(params=["uint8", "i8", np.float64, bool, None])
    def dtype(self, request):
        return np.dtype(request.param)

            

Reported by Pylint.

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

Line: 25 Column: 5

              
class TestGetDummies:
    @pytest.fixture
    def df(self):
        return DataFrame({"A": ["a", "b", "a"], "B": ["b", "b", "c"], "C": [1, 2, 3]})

    @pytest.fixture(params=["uint8", "i8", np.float64, bool, None])
    def dtype(self, request):
        return np.dtype(request.param)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 25 Column: 5

              
class TestGetDummies:
    @pytest.fixture
    def df(self):
        return DataFrame({"A": ["a", "b", "a"], "B": ["b", "b", "c"], "C": [1, 2, 3]})

    @pytest.fixture(params=["uint8", "i8", np.float64, bool, None])
    def dtype(self, request):
        return np.dtype(request.param)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 29 Column: 5

                      return DataFrame({"A": ["a", "b", "a"], "B": ["b", "b", "c"], "C": [1, 2, 3]})

    @pytest.fixture(params=["uint8", "i8", np.float64, bool, None])
    def dtype(self, request):
        return np.dtype(request.param)

    @pytest.fixture(params=["dense", "sparse"])
    def sparse(self, request):
        # params are strings to simplify reading test results,

            

Reported by Pylint.

pandas/tests/indexes/multi/test_constructors.py
105 issues
Unable to import 'pytest'
Error

Line: 8 Column: 1

              import itertools

import numpy as np
import pytest

from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike

import pandas as pd
from pandas import (

            

Reported by Pylint.

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

Line: 390 Column: 13

              
def test_from_tuples_index_values(idx):
    result = MultiIndex.from_tuples(idx)
    assert (result.values == idx.values).all()


def test_tuples_with_name_string():
    # GH 15110 and GH 14848


            

Reported by Pylint.

Access to a protected member _levels of a client class
Error

Line: 479 Column: 27

                  rng = Index(range(5))
    other = ["a", "b"]
    mi = MultiIndex.from_product([rng, other])
    tm.assert_index_equal(mi._levels[0], rng, exact=True)


@pytest.mark.parametrize("ordered", [False, True])
@pytest.mark.parametrize("f", [lambda x: x, lambda x: Series(x), lambda x: x.values])
def test_from_product_index_series_categorical(ordered, f):

            

Reported by Pylint.

Lambda may not be necessary
Error

Line: 483 Column: 45

              

@pytest.mark.parametrize("ordered", [False, True])
@pytest.mark.parametrize("f", [lambda x: x, lambda x: Series(x), lambda x: x.values])
def test_from_product_index_series_categorical(ordered, f):
    # GH13743
    first = ["foo", "bar"]

    idx = pd.CategoricalIndex(list("abcaab"), categories=list("bac"), ordered=ordered)

            

Reported by Pylint.

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

Line: 817 Column: 12

                  arr = [v, v]

    idx = Index(arr)
    assert idx.dtype == object

    mi = MultiIndex.from_arrays([arr])
    lev = mi.levels[0]
    assert lev.dtype == object


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from datetime import (
    date,
    datetime,
)
import itertools

import numpy as np
import pytest


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 23 Column: 1

              import pandas._testing as tm


def test_constructor_single_level():
    result = MultiIndex(
        levels=[["foo", "bar", "baz", "qux"]], codes=[[0, 1, 2, 3]], names=["first"]
    )
    assert isinstance(result, MultiIndex)
    expected = Index(["foo", "bar", "baz", "qux"], name="first")

            

Reported by Pylint.

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

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

                  result = MultiIndex(
        levels=[["foo", "bar", "baz", "qux"]], codes=[[0, 1, 2, 3]], names=["first"]
    )
    assert isinstance(result, MultiIndex)
    expected = Index(["foo", "bar", "baz", "qux"], name="first")
    tm.assert_index_equal(result.levels[0], expected)
    assert result.names == ["first"]



            

Reported by Bandit.

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

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

                  assert isinstance(result, MultiIndex)
    expected = Index(["foo", "bar", "baz", "qux"], name="first")
    tm.assert_index_equal(result.levels[0], expected)
    assert result.names == ["first"]


def test_constructor_no_levels():
    msg = "non-zero number of levels/codes"
    with pytest.raises(ValueError, match=msg):

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 33 Column: 1

                  assert result.names == ["first"]


def test_constructor_no_levels():
    msg = "non-zero number of levels/codes"
    with pytest.raises(ValueError, match=msg):
        MultiIndex(levels=[], codes=[])

    msg = "Must pass both levels and codes"

            

Reported by Pylint.

pandas/tests/groupby/test_timegrouper.py
105 issues
Unable to import 'pytest'
Error

Line: 7 Column: 1

              from io import StringIO

import numpy as np
import pytest
import pytz

import pandas as pd
from pandas import (
    DataFrame,

            

Reported by Pylint.

Unable to import 'pytz'
Error

Line: 8 Column: 1

              
import numpy as np
import pytest
import pytz

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

            

Reported by Pylint.

XXX
Error

Line: 318 Column: 3

                      expected = (
            df.groupby("user_id")["whole_cost"]
            .resample(freq)
            .sum(min_count=1)  # XXX
            .dropna()
            .reorder_levels(["date", "user_id"])
            .sort_index()
            .astype("int64")
        )

            

Reported by Pylint.

Access to a protected member _with_freq of a client class
Error

Line: 746 Column: 26

                      grouper = Grouper(key="time", freq="h")
        result = test.groupby(grouper)["data"].nunique()
        expected = test[test.time.notnull()].groupby(grouper)["data"].nunique()
        expected.index = expected.index._with_freq(None)
        tm.assert_series_equal(result, expected)

    def test_scalar_call_versus_list_call(self):
        # Issue: 17530
        data_frame = {

            

Reported by Pylint.

Missing class docstring
Error

Line: 26 Column: 1

              from pandas.core.groupby.ops import BinGrouper


class TestGroupBy:
    def test_groupby_with_timegrouper(self):
        # GH 4161
        # TimeGrouper requires a sorted index
        # also verifies that the resultant index has the correct name
        df_original = DataFrame(

            

Reported by Pylint.

Too many public methods (22/20)
Error

Line: 26 Column: 1

              from pandas.core.groupby.ops import BinGrouper


class TestGroupBy:
    def test_groupby_with_timegrouper(self):
        # GH 4161
        # TimeGrouper requires a sorted index
        # also verifies that the resultant index has the correct name
        df_original = DataFrame(

            

Reported by Pylint.

Method could be a function
Error

Line: 27 Column: 5

              

class TestGroupBy:
    def test_groupby_with_timegrouper(self):
        # GH 4161
        # TimeGrouper requires a sorted index
        # also verifies that the resultant index has the correct name
        df_original = DataFrame(
            {

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 27 Column: 5

              

class TestGroupBy:
    def test_groupby_with_timegrouper(self):
        # GH 4161
        # TimeGrouper requires a sorted index
        # also verifies that the resultant index has the correct name
        df_original = DataFrame(
            {

            

Reported by Pylint.

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

Line: 49 Column: 13

                      # GH 6908 change target column's order
        df_reordered = df_original.sort_values(by="Quantity")

        for df in [df_original, df_reordered]:
            df = df.set_index(["Date"])

            expected = DataFrame(
                {"Quantity": 0},
                index=date_range(

            

Reported by Pylint.

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

Line: 50 Column: 13

                      df_reordered = df_original.sort_values(by="Quantity")

        for df in [df_original, df_reordered]:
            df = df.set_index(["Date"])

            expected = DataFrame(
                {"Quantity": 0},
                index=date_range(
                    "20130901", "20131205", freq="5D", name="Date", closed="left"

            

Reported by Pylint.