The following issues were found

pandas/tests/groupby/test_allowlist.py
82 issues
Unable to import 'pytest'
Error

Line: 9 Column: 1

              from string import ascii_lowercase

import numpy as np
import pytest

import pandas.util._test_decorators as td

from pandas import (
    DataFrame,

            

Reported by Pylint.

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

Line: 121 Column: 5

                  letters = np.array(list(ascii_lowercase))
    N = 10
    random_letters = letters.take(np.random.randint(0, 26, N))
    df = DataFrame(
        {
            "floats": N / 10 * Series(np.random.random(N)),
            "letters": Series(random_letters),
        }
    )

            

Reported by Pylint.

Redefining name 'df_letters' from outer scope (line 117)
Error

Line: 131 Column: 28

              

@pytest.mark.parametrize("allowlist", [df_allowlist, s_allowlist])
def test_groupby_allowlist(df_letters, allowlist):
    df = df_letters
    if allowlist == df_allowlist:
        # dataframe
        obj = df_letters
    else:

            

Reported by Pylint.

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

Line: 132 Column: 5

              
@pytest.mark.parametrize("allowlist", [df_allowlist, s_allowlist])
def test_groupby_allowlist(df_letters, allowlist):
    df = df_letters
    if allowlist == df_allowlist:
        # dataframe
        obj = df_letters
    else:
        obj = df_letters["floats"]

            

Reported by Pylint.

Access to a protected member _apply_allowlist of a client class
Error

Line: 141 Column: 34

              
    gb = obj.groupby(df.letters)

    assert set(allowlist) == set(gb._apply_allowlist)


def check_allowlist(obj, df, m):
    # check the obj for a particular allowlist m


            

Reported by Pylint.

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

Line: 144 Column: 26

                  assert set(allowlist) == set(gb._apply_allowlist)


def check_allowlist(obj, df, m):
    # check the obj for a particular allowlist m

    gb = obj.groupby(df.letters)

    f = getattr(type(gb), m)

            

Reported by Pylint.

Redefining name 'df_letters' from outer scope (line 117)
Error

Line: 166 Column: 35

                  assert n.endswith(m)


def test_groupby_series_allowlist(df_letters, s_allowlist_fixture):
    m = s_allowlist_fixture
    df = df_letters
    check_allowlist(df.letters, df, m)



            

Reported by Pylint.

Redefining name 's_allowlist_fixture' from outer scope (line 90)
Error

Line: 166 Column: 47

                  assert n.endswith(m)


def test_groupby_series_allowlist(df_letters, s_allowlist_fixture):
    m = s_allowlist_fixture
    df = df_letters
    check_allowlist(df.letters, df, m)



            

Reported by Pylint.

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

Line: 168 Column: 5

              
def test_groupby_series_allowlist(df_letters, s_allowlist_fixture):
    m = s_allowlist_fixture
    df = df_letters
    check_allowlist(df.letters, df, m)


def test_groupby_frame_allowlist(df_letters, df_allowlist_fixture):
    m = df_allowlist_fixture

            

Reported by Pylint.

Redefining name 'df_letters' from outer scope (line 117)
Error

Line: 172 Column: 34

                  check_allowlist(df.letters, df, m)


def test_groupby_frame_allowlist(df_letters, df_allowlist_fixture):
    m = df_allowlist_fixture
    df = df_letters
    check_allowlist(df, df, m)



            

Reported by Pylint.

pandas/tests/arrays/categorical/test_dtypes.py
82 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

from pandas.core.dtypes.dtypes import CategoricalDtype

from pandas import (
    Categorical,
    CategoricalIndex,
    Index,

            

Reported by Pylint.

Access to a protected member _categories_match_up_to_permutation of a client class
Error

Line: 31 Column: 16

                      c1 = Categorical(list("aabca"), categories=list("abc"), ordered=False)
        c2 = Categorical(list("aabca"), categories=list("cab"), ordered=False)
        c3 = Categorical(list("aabca"), categories=list("cab"), ordered=True)
        assert c1._categories_match_up_to_permutation(c1)
        assert c2._categories_match_up_to_permutation(c2)
        assert c3._categories_match_up_to_permutation(c3)
        assert c1._categories_match_up_to_permutation(c2)
        assert not c1._categories_match_up_to_permutation(c3)
        assert not c1._categories_match_up_to_permutation(Index(list("aabca")))

            

Reported by Pylint.

Access to a protected member _categories_match_up_to_permutation of a client class
Error

Line: 32 Column: 16

                      c2 = Categorical(list("aabca"), categories=list("cab"), ordered=False)
        c3 = Categorical(list("aabca"), categories=list("cab"), ordered=True)
        assert c1._categories_match_up_to_permutation(c1)
        assert c2._categories_match_up_to_permutation(c2)
        assert c3._categories_match_up_to_permutation(c3)
        assert c1._categories_match_up_to_permutation(c2)
        assert not c1._categories_match_up_to_permutation(c3)
        assert not c1._categories_match_up_to_permutation(Index(list("aabca")))
        assert not c1._categories_match_up_to_permutation(c1.astype(object))

            

Reported by Pylint.

Access to a protected member _categories_match_up_to_permutation of a client class
Error

Line: 33 Column: 16

                      c3 = Categorical(list("aabca"), categories=list("cab"), ordered=True)
        assert c1._categories_match_up_to_permutation(c1)
        assert c2._categories_match_up_to_permutation(c2)
        assert c3._categories_match_up_to_permutation(c3)
        assert c1._categories_match_up_to_permutation(c2)
        assert not c1._categories_match_up_to_permutation(c3)
        assert not c1._categories_match_up_to_permutation(Index(list("aabca")))
        assert not c1._categories_match_up_to_permutation(c1.astype(object))
        assert c1._categories_match_up_to_permutation(CategoricalIndex(c1))

            

Reported by Pylint.

Access to a protected member _categories_match_up_to_permutation of a client class
Error

Line: 34 Column: 16

                      assert c1._categories_match_up_to_permutation(c1)
        assert c2._categories_match_up_to_permutation(c2)
        assert c3._categories_match_up_to_permutation(c3)
        assert c1._categories_match_up_to_permutation(c2)
        assert not c1._categories_match_up_to_permutation(c3)
        assert not c1._categories_match_up_to_permutation(Index(list("aabca")))
        assert not c1._categories_match_up_to_permutation(c1.astype(object))
        assert c1._categories_match_up_to_permutation(CategoricalIndex(c1))
        assert c1._categories_match_up_to_permutation(

            

Reported by Pylint.

Access to a protected member _categories_match_up_to_permutation of a client class
Error

Line: 35 Column: 20

                      assert c2._categories_match_up_to_permutation(c2)
        assert c3._categories_match_up_to_permutation(c3)
        assert c1._categories_match_up_to_permutation(c2)
        assert not c1._categories_match_up_to_permutation(c3)
        assert not c1._categories_match_up_to_permutation(Index(list("aabca")))
        assert not c1._categories_match_up_to_permutation(c1.astype(object))
        assert c1._categories_match_up_to_permutation(CategoricalIndex(c1))
        assert c1._categories_match_up_to_permutation(
            CategoricalIndex(c1, categories=list("cab"))

            

Reported by Pylint.

Access to a protected member _categories_match_up_to_permutation of a client class
Error

Line: 36 Column: 20

                      assert c3._categories_match_up_to_permutation(c3)
        assert c1._categories_match_up_to_permutation(c2)
        assert not c1._categories_match_up_to_permutation(c3)
        assert not c1._categories_match_up_to_permutation(Index(list("aabca")))
        assert not c1._categories_match_up_to_permutation(c1.astype(object))
        assert c1._categories_match_up_to_permutation(CategoricalIndex(c1))
        assert c1._categories_match_up_to_permutation(
            CategoricalIndex(c1, categories=list("cab"))
        )

            

Reported by Pylint.

Access to a protected member _categories_match_up_to_permutation of a client class
Error

Line: 37 Column: 20

                      assert c1._categories_match_up_to_permutation(c2)
        assert not c1._categories_match_up_to_permutation(c3)
        assert not c1._categories_match_up_to_permutation(Index(list("aabca")))
        assert not c1._categories_match_up_to_permutation(c1.astype(object))
        assert c1._categories_match_up_to_permutation(CategoricalIndex(c1))
        assert c1._categories_match_up_to_permutation(
            CategoricalIndex(c1, categories=list("cab"))
        )
        assert not c1._categories_match_up_to_permutation(

            

Reported by Pylint.

Access to a protected member _categories_match_up_to_permutation of a client class
Error

Line: 38 Column: 16

                      assert not c1._categories_match_up_to_permutation(c3)
        assert not c1._categories_match_up_to_permutation(Index(list("aabca")))
        assert not c1._categories_match_up_to_permutation(c1.astype(object))
        assert c1._categories_match_up_to_permutation(CategoricalIndex(c1))
        assert c1._categories_match_up_to_permutation(
            CategoricalIndex(c1, categories=list("cab"))
        )
        assert not c1._categories_match_up_to_permutation(
            CategoricalIndex(c1, ordered=True)

            

Reported by Pylint.

Access to a protected member _categories_match_up_to_permutation of a client class
Error

Line: 39 Column: 16

                      assert not c1._categories_match_up_to_permutation(Index(list("aabca")))
        assert not c1._categories_match_up_to_permutation(c1.astype(object))
        assert c1._categories_match_up_to_permutation(CategoricalIndex(c1))
        assert c1._categories_match_up_to_permutation(
            CategoricalIndex(c1, categories=list("cab"))
        )
        assert not c1._categories_match_up_to_permutation(
            CategoricalIndex(c1, ordered=True)
        )

            

Reported by Pylint.

pandas/tests/frame/methods/test_diff.py
82 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

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

            

Reported by Pylint.

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

Line: 181 Column: 14

              
    def test_diff_period(self):
        # GH#32995 Don't pass an incorrect axis
        pi = date_range("2016-01-01", periods=3).to_period("D")
        df = DataFrame({"A": pi})

        result = df.diff(1, axis=1)

        expected = (df - pd.NaT).astype(object)

            

Reported by Pylint.

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

Line: 181 Column: 14

              
    def test_diff_period(self):
        # GH#32995 Don't pass an incorrect axis
        pi = date_range("2016-01-01", periods=3).to_period("D")
        df = DataFrame({"A": pi})

        result = df.diff(1, axis=1)

        expected = (df - pd.NaT).astype(object)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

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

            

Reported by Pylint.

Missing class docstring
Error

Line: 14 Column: 1

              import pandas._testing as tm


class TestDataFrameDiff:
    def test_diff_requires_integer(self):
        df = DataFrame(np.random.randn(2, 2))
        with pytest.raises(ValueError, match="periods must be an integer"):
            df.diff(1.5)


            

Reported by Pylint.

Method could be a function
Error

Line: 15 Column: 5

              

class TestDataFrameDiff:
    def test_diff_requires_integer(self):
        df = DataFrame(np.random.randn(2, 2))
        with pytest.raises(ValueError, match="periods must be an integer"):
            df.diff(1.5)

    def test_diff(self, datetime_frame):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 15 Column: 5

              

class TestDataFrameDiff:
    def test_diff_requires_integer(self):
        df = DataFrame(np.random.randn(2, 2))
        with pytest.raises(ValueError, match="periods must be an integer"):
            df.diff(1.5)

    def test_diff(self, datetime_frame):

            

Reported by Pylint.

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

Line: 16 Column: 9

              
class TestDataFrameDiff:
    def test_diff_requires_integer(self):
        df = DataFrame(np.random.randn(2, 2))
        with pytest.raises(ValueError, match="periods must be an integer"):
            df.diff(1.5)

    def test_diff(self, datetime_frame):
        the_diff = datetime_frame.diff(1)

            

Reported by Pylint.

Method could be a function
Error

Line: 20 Column: 5

                      with pytest.raises(ValueError, match="periods must be an integer"):
            df.diff(1.5)

    def test_diff(self, datetime_frame):
        the_diff = datetime_frame.diff(1)

        tm.assert_series_equal(
            the_diff["A"], datetime_frame["A"] - datetime_frame["A"].shift(1)
        )

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 20 Column: 5

                      with pytest.raises(ValueError, match="periods must be an integer"):
            df.diff(1.5)

    def test_diff(self, datetime_frame):
        the_diff = datetime_frame.diff(1)

        tm.assert_series_equal(
            the_diff["A"], datetime_frame["A"] - datetime_frame["A"].shift(1)
        )

            

Reported by Pylint.

pandas/tests/frame/methods/test_shift.py
81 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 (
    CategoricalIndex,
    DataFrame,

            

Reported by Pylint.

Unused variable 'int_shifted'
Error

Line: 51 Column: 9

                      )

        # shift int frame
        int_shifted = int_frame.shift(1)  # noqa

        # Shifting with PeriodIndex
        ps = tm.makePeriodFrame()
        shifted = ps.shift(1)
        unshifted = shifted.shift(-1)

            

Reported by Pylint.

Access to a protected member _mgr of a client class
Error

Line: 163 Column: 24

                      df2 = DataFrame(np.random.randint(1000, size=(5, 2)))
        df3 = pd.concat([df1, df2], axis=1)
        if not using_array_manager:
            assert len(df3._mgr.blocks) == 2

        result = df3.shift(2, axis=1)

        expected = df3.take([-1, -1, 0, 1, 2], axis=1)
        expected.iloc[:, :2] = np.nan

            

Reported by Pylint.

Access to a protected member _mgr of a client class
Error

Line: 177 Column: 24

                      # rebuild df3 because `take` call above consolidated
        df3 = pd.concat([df1, df2], axis=1)
        if not using_array_manager:
            assert len(df3._mgr.blocks) == 2
        result = df3.shift(-2, axis=1)

        expected = df3.take([2, 3, 4, -1, -1], axis=1)
        expected.iloc[:, -2:] = np.nan
        expected.columns = df3.columns

            

Reported by Pylint.

TODO(ArrayManager) axis=1 support
Error

Line: 186 Column: 3

              
        tm.assert_frame_equal(result, expected)

    @td.skip_array_manager_not_yet_implemented  # TODO(ArrayManager) axis=1 support
    def test_shift_axis1_multiple_blocks_with_int_fill(self):
        # GH#42719
        df1 = DataFrame(np.random.randint(1000, size=(5, 3)))
        df2 = DataFrame(np.random.randint(1000, size=(5, 2)))
        df3 = pd.concat([df1.iloc[:4, 1:3], df2.iloc[:4, :]], axis=1)

            

Reported by Pylint.

Access to a protected member _mgr of a client class
Error

Line: 193 Column: 20

                      df2 = DataFrame(np.random.randint(1000, size=(5, 2)))
        df3 = pd.concat([df1.iloc[:4, 1:3], df2.iloc[:4, :]], axis=1)
        result = df3.shift(2, axis=1, fill_value=np.int_(0))
        assert len(df3._mgr.blocks) == 2

        expected = df3.take([-1, -1, 0, 1], axis=1)
        expected.iloc[:, :2] = np.int_(0)
        expected.columns = df3.columns


            

Reported by Pylint.

Access to a protected member _mgr of a client class
Error

Line: 204 Column: 20

                      # Case with periods < 0
        df3 = pd.concat([df1.iloc[:4, 1:3], df2.iloc[:4, :]], axis=1)
        result = df3.shift(-2, axis=1, fill_value=np.int_(0))
        assert len(df3._mgr.blocks) == 2

        expected = df3.take([2, 3, -1, -1], axis=1)
        expected.iloc[:, -2:] = np.int_(0)
        expected.columns = df3.columns


            

Reported by Pylint.

TODO: remove this test when tshift deprecation is enforced
Error

Line: 214 Column: 3

              
    @pytest.mark.filterwarnings("ignore:tshift is deprecated:FutureWarning")
    def test_tshift(self, datetime_frame):
        # TODO: remove this test when tshift deprecation is enforced

        # PeriodIndex
        ps = tm.makePeriodFrame()
        shifted = ps.tshift(1)
        unshifted = shifted.tshift(-1)

            

Reported by Pylint.

Access to a protected member _with_freq of a client class
Error

Line: 250 Column: 26

                      shifted = inferred_ts.tshift(1)

        expected = datetime_frame.tshift(1)
        expected.index = expected.index._with_freq(None)
        tm.assert_frame_equal(shifted, expected)

        unshifted = shifted.tshift(-1)
        tm.assert_frame_equal(unshifted, inferred_ts)


            

Reported by Pylint.

Access to a protected member _with_freq of a client class
Error

Line: 294 Column: 26

                      )
        shifted = inferred_ts.shift(1, freq="infer")
        expected = datetime_frame.shift(1, freq="infer")
        expected.index = expected.index._with_freq(None)
        tm.assert_frame_equal(shifted, expected)

        unshifted = shifted.shift(-1, freq="infer")
        tm.assert_frame_equal(unshifted, inferred_ts)


            

Reported by Pylint.

asv_bench/benchmarks/gil.py
81 issues
Unable to import 'pandas'
Error

Line: 3 Column: 1

              import numpy as np

from pandas import (
    DataFrame,
    Series,
    date_range,
    factorize,
    read_csv,
)

            

Reported by Pylint.

Unable to import 'pandas.core.algorithms'
Error

Line: 10 Column: 1

                  factorize,
    read_csv,
)
from pandas.core.algorithms import take_nd

from .pandas_vb_common import tm

try:
    from pandas import (

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 12 Column: 1

              )
from pandas.core.algorithms import take_nd

from .pandas_vb_common import tm

try:
    from pandas import (
        rolling_kurt,
        rolling_max,

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 47 Column: 1

                      return wrapper


from .pandas_vb_common import BaseIO  # isort:skip


class ParallelGroupbyMethods:

    params = ([2, 4, 8], ["count", "last", "max", "mean", "min", "prod", "sum", "var"])

            

Reported by Pylint.

No value for argument 'arr' in function call
Error

Line: 147 Column: 9

                      self.parallel_kth_smallest = parallel_kth_smallest

    def time_kth_smallest(self):
        self.parallel_kth_smallest()


class ParallelDatetimeFields:
    def setup(self):
        if not have_real_test_parallel:

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 311 Column: 1

                          self.loop()


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

            

Reported by Pylint.

Unused argument 'num_threads'
Error

Line: 40 Column: 23

              except ImportError:
    have_real_test_parallel = False

    def test_parallel(num_threads=1):
        def wrapper(fname):
            return fname

        return wrapper


            

Reported by Pylint.

Attribute 'parallel' defined outside __init__
Error

Line: 68 Column: 9

                      def parallel():
            getattr(df.groupby("key")["data"], method)()

        self.parallel = parallel

        def loop():
            getattr(df.groupby("key")["data"], method)()

        self.loop = loop

            

Reported by Pylint.

Attribute 'loop' defined outside __init__
Error

Line: 73 Column: 9

                      def loop():
            getattr(df.groupby("key")["data"], method)()

        self.loop = loop

    def time_parallel(self, threads, method):
        self.parallel()

    def time_loop(self, threads, method):

            

Reported by Pylint.

Unused argument 'method'
Error

Line: 75 Column: 38

              
        self.loop = loop

    def time_parallel(self, threads, method):
        self.parallel()

    def time_loop(self, threads, method):
        for i in range(threads):
            self.loop()

            

Reported by Pylint.

pandas/tests/indexes/datetimes/test_datetime.py
81 issues
Unable to import 'pytest'
Error

Line: 5 Column: 1

              
import dateutil
import numpy as np
import pytest

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

            

Reported by Pylint.

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

Line: 23 Column: 9

                  def test_time_loc(self):  # GH8667
        from datetime import time

        from pandas._libs.index import _SIZE_CUTOFF

        ns = _SIZE_CUTOFF + np.array([-100, 100], dtype=np.int64)
        key = time(15, 11, 30)
        start = key.hour * 3600 + key.minute * 60 + key.second
        step = 24 * 3600

            

Reported by Pylint.

Unable to import 'pandas._libs.index'
Error

Line: 23 Column: 9

                  def test_time_loc(self):  # GH8667
        from datetime import time

        from pandas._libs.index import _SIZE_CUTOFF

        ns = _SIZE_CUTOFF + np.array([-100, 100], dtype=np.int64)
        key = time(15, 11, 30)
        start = key.hour * 3600 + key.minute * 60 + key.second
        step = 24 * 3600

            

Reported by Pylint.

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

Line: 137 Column: 30

              
    def test_misc_coverage(self):
        rng = date_range("1/1/2000", periods=5)
        result = rng.groupby(rng.day)
        assert isinstance(list(result.values())[0][0], Timestamp)

    def test_string_index_series_name_converted(self):
        # #1644
        df = DataFrame(np.random.randn(10, 4), index=date_range("1/1/2000", periods=10))

            

Reported by Pylint.

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

Line: 137 Column: 30

              
    def test_misc_coverage(self):
        rng = date_range("1/1/2000", periods=5)
        result = rng.groupby(rng.day)
        assert isinstance(list(result.values())[0][0], Timestamp)

    def test_string_index_series_name_converted(self):
        # #1644
        df = DataFrame(np.random.randn(10, 4), index=date_range("1/1/2000", periods=10))

            

Reported by Pylint.

Instance of 'PrettyDict' has no 'values' member
Error

Line: 138 Column: 32

                  def test_misc_coverage(self):
        rng = date_range("1/1/2000", periods=5)
        result = rng.groupby(rng.day)
        assert isinstance(list(result.values())[0][0], Timestamp)

    def test_string_index_series_name_converted(self):
        # #1644
        df = DataFrame(np.random.randn(10, 4), index=date_range("1/1/2000", periods=10))


            

Reported by Pylint.

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

Line: 183 Column: 68

                      index = DatetimeIndex(dt, freq=freq, name="time")
        self.assert_index_parameters(index)

        new_index = date_range(start=index[0], end=index[-1], freq=index.freq)
        self.assert_index_parameters(new_index)

    def test_asarray_tz_naive(self):
        # This shouldn't produce a warning.
        idx = date_range("2000", periods=2)

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 86 Column: 9

                      start = "2013-01-07"
        idx = date_range(start=start, freq="1d", periods=10, tz="US/Eastern")
        df = DataFrame(np.arange(10), index=idx)
        df["2013-01-14 23:44:34.437768-05:00":]  # no exception here

    def test_append_nondatetimeindex(self):
        rng = date_range("1/1/2000", periods=10)
        idx = Index(["a", "b", "c", "d"])


            

Reported by Pylint.

Access to a protected member _repr_base of a client class
Error

Line: 111 Column: 20

                      for i, ts in enumerate(index):
            result = ts
            expected = index[i]
            assert result._repr_base == expected._repr_base
            assert result == expected

        # 9100
        index = DatetimeIndex(
            ["2014-12-01 03:32:39.987000-08:00", "2014-12-01 04:12:34.987000-08:00"]

            

Reported by Pylint.

Access to a protected member _repr_base of a client class
Error

Line: 111 Column: 41

                      for i, ts in enumerate(index):
            result = ts
            expected = index[i]
            assert result._repr_base == expected._repr_base
            assert result == expected

        # 9100
        index = DatetimeIndex(
            ["2014-12-01 03:32:39.987000-08:00", "2014-12-01 04:12:34.987000-08:00"]

            

Reported by Pylint.

pandas/tests/io/formats/test_printing.py
81 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

import pandas._config.config as cf

import pandas as pd

import pandas.io.formats.format as fmt
import pandas.io.formats.printing as printing

            

Reported by Pylint.

Unable to import 'IPython.core.interactiveshell'
Error

Line: 127 Column: 9

                  def setup_class(cls):
        pytest.importorskip("IPython")

        from IPython.core.interactiveshell import InteractiveShell

        cls.display_formatter = InteractiveShell.instance().display_formatter

    def test_publishes(self):


            

Reported by Pylint.

Using possibly undefined loop variable 'obj'
Error

Line: 149 Column: 55

                      with_latex = pd.option_context("display.latex.repr", True)

        with opt, with_latex:
            formatted = self.display_formatter.format(obj)

        expected = {
            "text/plain",
            "text/html",
            "text/latex",

            

Reported by Pylint.

Access to a protected member _repr_data_resource_ of a client class
Error

Line: 176 Column: 22

                  def test_config_on(self):
        df = pd.DataFrame({"A": [1, 2]})
        with pd.option_context("display.html.table_schema", True):
            result = df._repr_data_resource_()

        assert result is not None

    def test_config_default_off(self):
        df = pd.DataFrame({"A": [1, 2]})

            

Reported by Pylint.

Access to a protected member _repr_data_resource_ of a client class
Error

Line: 183 Column: 22

                  def test_config_default_off(self):
        df = pd.DataFrame({"A": [1, 2]})
        with pd.option_context("display.html.table_schema", False):
            result = df._repr_data_resource_()

        assert result is None

    def test_enable_data_resource_formatter(self):
        # GH 10491

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

import pandas._config.config as cf

import pandas as pd

import pandas.io.formats.format as fmt
import pandas.io.formats.printing as printing

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 12 Column: 1

              import pandas.io.formats.printing as printing


def test_adjoin():
    data = [["a", "b", "c"], ["dd", "ee", "ff"], ["ggg", "hhh", "iii"]]
    expected = "a  dd  ggg\nb  ee  hhh\nc  ff  iii"

    adjoined = printing.adjoin(2, *data)


            

Reported by Pylint.

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

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

              
    adjoined = printing.adjoin(2, *data)

    assert adjoined == expected


def test_repr_binary_type():
    import string


            

Reported by Bandit.

Missing function or method docstring
Error

Line: 21 Column: 1

                  assert adjoined == expected


def test_repr_binary_type():
    import string

    letters = string.ascii_letters
    try:
        raw = bytes(letters, encoding=cf.get_option("display.encoding"))

            

Reported by Pylint.

Import outside toplevel (string)
Error

Line: 22 Column: 5

              

def test_repr_binary_type():
    import string

    letters = string.ascii_letters
    try:
        raw = bytes(letters, encoding=cf.get_option("display.encoding"))
    except TypeError:

            

Reported by Pylint.

pandas/tests/frame/methods/test_rename.py
81 issues
Unable to import 'pytest'
Error

Line: 5 Column: 1

              import inspect

import numpy as np
import pytest

import pandas.util._test_decorators as td

from pandas import (
    DataFrame,

            

Reported by Pylint.

Argument 'mapper' passed by position and keyword in method call
Error

Line: 326 Column: 13

              
        # Duplicates
        with pytest.raises(TypeError, match="multiple values"):
            df.rename(id, mapper=id)

    def test_rename_positional_raises(self):
        # GH 29136
        df = DataFrame(columns=["A", "B"])
        msg = r"rename\(\) takes from 1 to 2 positional arguments"

            

Reported by Pylint.

Too many positional arguments for method call
Error

Line: 334 Column: 13

                      msg = r"rename\(\) takes from 1 to 2 positional arguments"

        with pytest.raises(TypeError, match=msg):
            df.rename(None, str.lower)

    def test_rename_no_mappings_raises(self):
        # GH 29136
        df = DataFrame([[1]])
        msg = "must pass an index to rename"

            

Reported by Pylint.

TODO(ArrayManager) setitem copy/view
Error

Line: 173 Column: 3

                      renamed = df.rename(index={"foo1": "foo3", "bar2": "bar3"}, level=0)
        tm.assert_index_equal(renamed.index, new_index)

    @td.skip_array_manager_not_yet_implemented  # TODO(ArrayManager) setitem copy/view
    def test_rename_nocopy(self, float_frame):
        renamed = float_frame.rename(columns={"C": "foo"}, copy=False)
        renamed["foo"] = 1.0
        assert (float_frame["C"] == 1.0).all()


            

Reported by Pylint.

TODO: can we construct this without merge?
Error

Line: 387 Column: 3

                              names=["STK_ID", "RPT_Date"],
            ),
        )
        # TODO: can we construct this without merge?
        k = merge(df4, df5, how="inner", left_index=True, right_index=True)
        result = k.rename(columns={"TClose_x": "TClose", "TClose_y": "QT_Close"})
        str(result)
        result.dtypes


            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 391 Column: 9

                      k = merge(df4, df5, how="inner", left_index=True, right_index=True)
        result = k.rename(columns={"TClose_x": "TClose", "TClose_y": "QT_Close"})
        str(result)
        result.dtypes

        expected = DataFrame(
            [[0.0454, 22.02, 0.0422, 20130331, 600809, "饡驦", 30.01]],
            columns=[
                "RT",

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from collections import ChainMap
import inspect

import numpy as np
import pytest

import pandas.util._test_decorators as td

from pandas import (

            

Reported by Pylint.

Missing class docstring
Error

Line: 19 Column: 1

              import pandas._testing as tm


class TestRename:
    def test_rename_signature(self):
        sig = inspect.signature(DataFrame.rename)
        parameters = set(sig.parameters)
        assert parameters == {
            "self",

            

Reported by Pylint.

Method could be a function
Error

Line: 20 Column: 5

              

class TestRename:
    def test_rename_signature(self):
        sig = inspect.signature(DataFrame.rename)
        parameters = set(sig.parameters)
        assert parameters == {
            "self",
            "mapper",

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 20 Column: 5

              

class TestRename:
    def test_rename_signature(self):
        sig = inspect.signature(DataFrame.rename)
        parameters = set(sig.parameters)
        assert parameters == {
            "self",
            "mapper",

            

Reported by Pylint.

pandas/tests/groupby/test_filters.py
81 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

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

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

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

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 1

              import pandas._testing as tm


def test_filter_series():
    s = Series([1, 3, 20, 5, 22, 24, 7])
    expected_odd = Series([1, 3, 5, 7], index=[0, 1, 3, 6])
    expected_even = Series([20, 22, 24], index=[2, 4, 5])
    grouper = s.apply(lambda x: x % 2)
    grouped = s.groupby(grouper)

            

Reported by Pylint.

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

Line: 14 Column: 5

              

def test_filter_series():
    s = Series([1, 3, 20, 5, 22, 24, 7])
    expected_odd = Series([1, 3, 5, 7], index=[0, 1, 3, 6])
    expected_even = Series([20, 22, 24], index=[2, 4, 5])
    grouper = s.apply(lambda x: x % 2)
    grouped = s.groupby(grouper)
    tm.assert_series_equal(grouped.filter(lambda x: x.mean() < 10), expected_odd)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 32 Column: 1

                  )


def test_filter_single_column_df():
    df = DataFrame([1, 3, 20, 5, 22, 24, 7])
    expected_odd = DataFrame([1, 3, 5, 7], index=[0, 1, 3, 6])
    expected_even = DataFrame([20, 22, 24], index=[2, 4, 5])
    grouper = df[0].apply(lambda x: x % 2)
    grouped = df.groupby(grouper)

            

Reported by Pylint.

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

Line: 33 Column: 5

              

def test_filter_single_column_df():
    df = DataFrame([1, 3, 20, 5, 22, 24, 7])
    expected_odd = DataFrame([1, 3, 5, 7], index=[0, 1, 3, 6])
    expected_even = DataFrame([20, 22, 24], index=[2, 4, 5])
    grouper = df[0].apply(lambda x: x % 2)
    grouped = df.groupby(grouper)
    tm.assert_frame_equal(grouped.filter(lambda x: x.mean() < 10), expected_odd)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 51 Column: 1

                  )


def test_filter_multi_column_df():
    df = DataFrame({"A": [1, 12, 12, 1], "B": [1, 1, 1, 1]})
    grouper = df["A"].apply(lambda x: x % 2)
    grouped = df.groupby(grouper)
    expected = DataFrame({"A": [12, 12], "B": [1, 1]}, index=[1, 2])
    tm.assert_frame_equal(

            

Reported by Pylint.

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

Line: 52 Column: 5

              

def test_filter_multi_column_df():
    df = DataFrame({"A": [1, 12, 12, 1], "B": [1, 1, 1, 1]})
    grouper = df["A"].apply(lambda x: x % 2)
    grouped = df.groupby(grouper)
    expected = DataFrame({"A": [12, 12], "B": [1, 1]}, index=[1, 2])
    tm.assert_frame_equal(
        grouped.filter(lambda x: x["A"].sum() - x["B"].sum() > 10), expected

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 61 Column: 1

                  )


def test_filter_mixed_df():
    df = DataFrame({"A": [1, 12, 12, 1], "B": "a b c d".split()})
    grouper = df["A"].apply(lambda x: x % 2)
    grouped = df.groupby(grouper)
    expected = DataFrame({"A": [12, 12], "B": ["b", "c"]}, index=[1, 2])
    tm.assert_frame_equal(grouped.filter(lambda x: x["A"].sum() > 10), expected)

            

Reported by Pylint.

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

Line: 62 Column: 5

              

def test_filter_mixed_df():
    df = DataFrame({"A": [1, 12, 12, 1], "B": "a b c d".split()})
    grouper = df["A"].apply(lambda x: x % 2)
    grouped = df.groupby(grouper)
    expected = DataFrame({"A": [12, 12], "B": ["b", "c"]}, index=[1, 2])
    tm.assert_frame_equal(grouped.filter(lambda x: x["A"].sum() > 10), expected)


            

Reported by Pylint.

asv_bench/benchmarks/multiindex_object.py
81 issues
Unable to import 'pandas'
Error

Line: 5 Column: 1

              
import numpy as np

from pandas import (
    DataFrame,
    MultiIndex,
    RangeIndex,
    date_range,
)

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 12 Column: 1

                  date_range,
)

from .pandas_vb_common import tm


class GetLoc:
    def setup(self):
        self.mi_large = MultiIndex.from_product(

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 235 Column: 1

                      getattr(self.left, method)(self.right)


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

            

Reported by Pylint.

Attribute 'mi_large' defined outside __init__
Error

Line: 17 Column: 9

              
class GetLoc:
    def setup(self):
        self.mi_large = MultiIndex.from_product(
            [np.arange(1000), np.arange(20), list(string.ascii_letters)],
            names=["one", "two", "three"],
        )
        self.mi_med = MultiIndex.from_product(
            [np.arange(1000), np.arange(10), list("A")], names=["one", "two", "three"]

            

Reported by Pylint.

Attribute 'mi_med' defined outside __init__
Error

Line: 21 Column: 9

                          [np.arange(1000), np.arange(20), list(string.ascii_letters)],
            names=["one", "two", "three"],
        )
        self.mi_med = MultiIndex.from_product(
            [np.arange(1000), np.arange(10), list("A")], names=["one", "two", "three"]
        )
        self.mi_small = MultiIndex.from_product(
            [np.arange(100), list("A"), list("A")], names=["one", "two", "three"]
        )

            

Reported by Pylint.

Attribute 'mi_small' defined outside __init__
Error

Line: 24 Column: 9

                      self.mi_med = MultiIndex.from_product(
            [np.arange(1000), np.arange(10), list("A")], names=["one", "two", "three"]
        )
        self.mi_small = MultiIndex.from_product(
            [np.arange(100), list("A"), list("A")], names=["one", "two", "three"]
        )

    def time_large_get_loc(self):
        self.mi_large.get_loc((999, 19, "Z"))

            

Reported by Pylint.

Attribute 'mi_unused_levels' defined outside __init__
Error

Line: 55 Column: 9

                      size = 65536
        arrays = [np.random.randint(0, 8192, size), np.random.randint(0, 1024, size)]
        mask = np.random.rand(size) < 0.1
        self.mi_unused_levels = MultiIndex.from_arrays(arrays)
        self.mi_unused_levels = self.mi_unused_levels[mask]

    def time_remove_unused_levels(self):
        self.mi_unused_levels.remove_unused_levels()


            

Reported by Pylint.

Attribute 'mi_unused_levels' defined outside __init__
Error

Line: 56 Column: 9

                      arrays = [np.random.randint(0, 8192, size), np.random.randint(0, 1024, size)]
        mask = np.random.rand(size) < 0.1
        self.mi_unused_levels = MultiIndex.from_arrays(arrays)
        self.mi_unused_levels = self.mi_unused_levels[mask]

    def time_remove_unused_levels(self):
        self.mi_unused_levels.remove_unused_levels()



            

Reported by Pylint.

Attribute 'mi_int' defined outside __init__
Error

Line: 64 Column: 9

              
class Integer:
    def setup(self):
        self.mi_int = MultiIndex.from_product(
            [np.arange(1000), np.arange(1000)], names=["one", "two"]
        )
        self.obj_index = np.array(
            [
                (0, 10),

            

Reported by Pylint.

Attribute 'obj_index' defined outside __init__
Error

Line: 67 Column: 9

                      self.mi_int = MultiIndex.from_product(
            [np.arange(1000), np.arange(1000)], names=["one", "two"]
        )
        self.obj_index = np.array(
            [
                (0, 10),
                (0, 11),
                (0, 12),
                (0, 13),

            

Reported by Pylint.