The following issues were found

pandas/tests/frame/test_subclass.py
164 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,
    Index,

            

Reported by Pylint.

Access to a protected member _metadata of a client class
Error

Line: 89 Column: 16

                      # see gh-10553
        unpickled = tm.round_trip_pickle(df)
        tm.assert_frame_equal(df, unpickled)
        assert df._metadata == unpickled._metadata
        assert df.testattr == unpickled.testattr

    def test_indexing_sliced(self):
        # GH 11559
        df = tm.SubclassedDataFrame(

            

Reported by Pylint.

Access to a protected member _metadata of a client class
Error

Line: 89 Column: 32

                      # see gh-10553
        unpickled = tm.round_trip_pickle(df)
        tm.assert_frame_equal(df, unpickled)
        assert df._metadata == unpickled._metadata
        assert df.testattr == unpickled.testattr

    def test_indexing_sliced(self):
        # GH 11559
        df = tm.SubclassedDataFrame(

            

Reported by Pylint.

Expression "A().bar" is assigned to nothing
Error

Line: 135 Column: 13

                              return self.i_dont_exist

        with pytest.raises(AttributeError, match=".*i_dont_exist.*"):
            A().bar

    def test_subclass_align(self):
        # GH 12983
        df1 = tm.SubclassedDataFrame(
            {"a": [1, 3, 5], "b": [1, 3, 5]}, index=list("ACE")

            

Reported by Pylint.

Lambda may not be necessary
Error

Line: 537 Column: 18

                          columns=["first", "last", "variable", "value"],
        )

        df.apply(lambda x: check_row_subclass(x))
        df.apply(lambda x: check_row_subclass(x), axis=1)

        expected = tm.SubclassedDataFrame(
            [
                ["John", "Doe", "height", 6.0],

            

Reported by Pylint.

Lambda may not be necessary
Error

Line: 538 Column: 18

                      )

        df.apply(lambda x: check_row_subclass(x))
        df.apply(lambda x: check_row_subclass(x), axis=1)

        expected = tm.SubclassedDataFrame(
            [
                ["John", "Doe", "height", 6.0],
                ["Mary", "Bo", "height", 6.5],

            

Reported by Pylint.

Lambda may not be necessary
Error

Line: 550 Column: 27

                          columns=["first", "last", "variable", "value"],
        )

        result = df.apply(lambda x: stretch(x), axis=1)
        assert isinstance(result, tm.SubclassedDataFrame)
        tm.assert_frame_equal(result, expected)

        expected = tm.SubclassedDataFrame([[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]])


            

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

            

Reported by Pylint.

Missing class docstring
Error

Line: 16 Column: 1

              import pandas._testing as tm


class TestDataFrameSubclassing:
    def test_frame_subclassing_and_slicing(self):
        # Subclass frame and ensure it returns the right class on slicing it
        # In reference to PR 9632

        class CustomSeries(Series):

            

Reported by Pylint.

Too many public methods (29/20)
Error

Line: 16 Column: 1

              import pandas._testing as tm


class TestDataFrameSubclassing:
    def test_frame_subclassing_and_slicing(self):
        # Subclass frame and ensure it returns the right class on slicing it
        # In reference to PR 9632

        class CustomSeries(Series):

            

Reported by Pylint.

pandas/core/groupby/generic.py
162 issues
No name 'lib' in module 'pandas._libs'
Error

Line: 29 Column: 1

              
import numpy as np

from pandas._libs import (
    lib,
    reduction as libreduction,
)
from pandas._typing import (
    ArrayLike,

            

Reported by Pylint.

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

Line: 29 Column: 1

              
import numpy as np

from pandas._libs import (
    lib,
    reduction as libreduction,
)
from pandas._typing import (
    ArrayLike,

            

Reported by Pylint.

TODO(typing) the return value on this callable should be any *scalar*.
Error

Line: 93 Column: 3

              from pandas.plotting import boxplot_frame_groupby

NamedAgg = namedtuple("NamedAgg", ["column", "aggfunc"])
# TODO(typing) the return value on this callable should be any *scalar*.
AggScalar = Union[str, Callable[..., Any]]
# TODO: validate types on ScalarResult and move to _typing
# Blocked from using by https://github.com/python/mypy/issues/1484
# See note at _mangle_lambda_list
ScalarResult = TypeVar("ScalarResult")

            

Reported by Pylint.

TODO: validate types on ScalarResult and move to _typing
Error

Line: 95 Column: 3

              NamedAgg = namedtuple("NamedAgg", ["column", "aggfunc"])
# TODO(typing) the return value on this callable should be any *scalar*.
AggScalar = Union[str, Callable[..., Any]]
# TODO: validate types on ScalarResult and move to _typing
# Blocked from using by https://github.com/python/mypy/issues/1484
# See note at _mangle_lambda_list
ScalarResult = TypeVar("ScalarResult")



            

Reported by Pylint.

Access to a protected member _make_wrapper of a client class
Error

Line: 116 Column: 16

                  """

    def prop(self):
        return self._make_wrapper(name)

    parent_method = getattr(klass, name)
    prop.__doc__ = parent_method.__doc__ or ""
    prop.__name__ = name
    return property(prop)

            

Reported by Pylint.

Keyword argument before variable positional arguments list in the definition of aggregate function
Error

Line: 226 Column: 5

                      return super().apply(func, *args, **kwargs)

    @doc(_agg_template, examples=_agg_examples_doc, klass="Series")
    def aggregate(self, func=None, *args, engine=None, engine_kwargs=None, **kwargs):

        if maybe_use_numba(engine):
            with group_selection_context(self):
                data = self._selected_obj
            result, index = self._aggregate_with_numba(

            

Reported by Pylint.

Parameters differ from overridden 'aggregate' method
Error

Line: 226 Column: 5

                      return super().apply(func, *args, **kwargs)

    @doc(_agg_template, examples=_agg_examples_doc, klass="Series")
    def aggregate(self, func=None, *args, engine=None, engine_kwargs=None, **kwargs):

        if maybe_use_numba(engine):
            with group_selection_context(self):
                data = self._selected_obj
            result, index = self._aggregate_with_numba(

            

Reported by Pylint.

Access to a protected member _constructor of a client class
Error

Line: 234 Column: 20

                          result, index = self._aggregate_with_numba(
                data.to_frame(), func, *args, engine_kwargs=engine_kwargs, **kwargs
            )
            return self.obj._constructor(result.ravel(), index=index, name=data.name)

        relabeling = func is None
        columns = None
        if relabeling:
            columns, func = validate_func_kwargs(kwargs)

            

Reported by Pylint.

TODO: KeyError is raised in _python_agg_general,
Error

Line: 267 Column: 3

                          try:
                return self._python_agg_general(func, *args, **kwargs)
            except KeyError:
                # TODO: KeyError is raised in _python_agg_general,
                #  see test_groupby.test_basic
                result = self._aggregate_named(func, *args, **kwargs)

                index = Index(sorted(result), name=self.grouper.names[0])
                return create_series_with_explicit_dtype(

            

Reported by Pylint.

Access to a protected member _constructor_expanddim of a client class
Error

Line: 316 Column: 18

                          return res_df  # type: ignore[return-value]

        indexed_output = {key.position: val for key, val in results.items()}
        output = self.obj._constructor_expanddim(indexed_output, index=None)
        output.columns = Index(key.label for key in results)

        output = self._reindex_output(output)
        return output


            

Reported by Pylint.

pandas/tests/indexing/test_chaining_and_caching.py
162 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              from string import ascii_letters as letters

import numpy as np
import pytest

import pandas.util._test_decorators as td

import pandas as pd
from pandas import (

            

Reported by Pylint.

Unused variable 'i'
Error

Line: 24 Column: 9

              
def random_text(nobs=100):
    df = []
    for i in range(nobs):
        idx = np.random.randint(len(letters), size=2)
        idx.sort()

        df.append([letters[idx[0] : idx[1]]])


            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 46 Column: 13

                          df["cc"] = 0.0

            # caches a reference to the 'bb' series
            df["bb"]

            # repr machinery triggers consolidation
            repr(df)

            # Assignment to wrong series

            

Reported by Pylint.

Access to a protected member _clear_item_cache of a client class
Error

Line: 53 Column: 13

              
            # Assignment to wrong series
            df["bb"].iloc[0] = 0.17
            df._clear_item_cache()
            tm.assert_almost_equal(df["bb"][0], 0.17)

    @pytest.mark.parametrize("do_ref", [True, False])
    def test_setitem_cache_updating(self, do_ref):
        # GH 5424

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 65 Column: 13

              
        # ref the cache
        if do_ref:
            df.loc[0, "c"]

        # set it
        df.loc[7, "c"] = 1

        assert df.loc[0, "c"] == 0.0

            

Reported by Pylint.

Unused variable 'ix'
Error

Line: 85 Column: 13

                      # loop through df to update out
        six = Timestamp("5/7/2014")
        eix = Timestamp("5/9/2014")
        for ix, row in df.iterrows():
            out.loc[six:eix, row["C"]] = out.loc[six:eix, row["C"]] + row["D"]

        tm.assert_frame_equal(out, expected)
        tm.assert_series_equal(out["A"], expected["A"])


            

Reported by Pylint.

Access to a protected member _item_cache of a client class
Error

Line: 113 Column: 23

                      df = DataFrame([[1, 2], [3, 4]], index=["a", "b"], columns=["A", "B"])
        ser = df["A"]

        assert "A" in df._item_cache

        # Adding a new entry to ser swaps in a new array, so "A" needs to
        #  be removed from df._item_cache
        ser["c"] = 5
        assert len(ser) == 3

            

Reported by Pylint.

Access to a protected member _item_cache of a client class
Error

Line: 119 Column: 27

                      #  be removed from df._item_cache
        ser["c"] = 5
        assert len(ser) == 3
        assert "A" not in df._item_cache
        assert df["A"] is not ser
        assert len(df["A"]) == 2


class TestChaining:

            

Reported by Pylint.

Access to a protected member _is_copy of a client class
Error

Line: 167 Column: 16

                      # work with the chain
        expected = DataFrame([[-5, 1], [-6, 3]], columns=list("AB"))
        df = DataFrame(np.arange(4).reshape(2, 2), columns=list("AB"), dtype="int64")
        assert df._is_copy is None

        df["A"][0] = -5
        df["A"][1] = -6
        tm.assert_frame_equal(df, expected)


            

Reported by Pylint.

Access to a protected member _is_copy of a client class
Error

Line: 183 Column: 16

                              "B": np.array(np.arange(2, 4), dtype=np.float64),
            }
        )
        assert df._is_copy is None

        if not using_array_manager:
            with pytest.raises(com.SettingWithCopyError, match=msg):
                df["A"][0] = -5


            

Reported by Pylint.

pandas/core/internals/blocks.py
160 issues
No name 'writers' in module 'pandas._libs'
Error

Line: 18 Column: 1

              
import numpy as np

from pandas._libs import (
    Timestamp,
    algos as libalgos,
    internals as libinternals,
    lib,
    writers,

            

Reported by Pylint.

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

Line: 18 Column: 1

              
import numpy as np

from pandas._libs import (
    Timestamp,
    algos as libalgos,
    internals as libinternals,
    lib,
    writers,

            

Reported by Pylint.

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

Line: 18 Column: 1

              
import numpy as np

from pandas._libs import (
    Timestamp,
    algos as libalgos,
    internals as libinternals,
    lib,
    writers,

            

Reported by Pylint.

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

Line: 18 Column: 1

              
import numpy as np

from pandas._libs import (
    Timestamp,
    algos as libalgos,
    internals as libinternals,
    lib,
    writers,

            

Reported by Pylint.

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

Line: 25 Column: 1

                  lib,
    writers,
)
from pandas._libs.internals import BlockPlacement
from pandas._typing import (
    ArrayLike,
    DtypeObj,
    F,
    Shape,

            

Reported by Pylint.

Unable to import 'pandas._libs.internals'
Error

Line: 25 Column: 1

                  lib,
    writers,
)
from pandas._libs.internals import BlockPlacement
from pandas._typing import (
    ArrayLike,
    DtypeObj,
    F,
    Shape,

            

Reported by Pylint.

Method 'dtype' has no 'name' member
Error

Line: 167 Column: 39

                  @final
    @cache_readonly
    def _consolidate_key(self):
        return self._can_consolidate, self.dtype.name

    @property
    def is_view(self) -> bool:
        """return a boolean if I am possibly a view"""
        values = self.values

            

Reported by Pylint.

Method 'dtype' has no 'kind' member
Error

Line: 184 Column: 20

                      """
        dtype = self.dtype
        if isinstance(dtype, np.dtype):
            return dtype.kind not in ["b", "i", "u"]
        return dtype._can_hold_na

    @final
    @cache_readonly
    def is_categorical(self) -> bool:

            

Reported by Pylint.

Method 'dtype' has no '_can_hold_na' member
Error

Line: 185 Column: 16

                      dtype = self.dtype
        if isinstance(dtype, np.dtype):
            return dtype.kind not in ["b", "i", "u"]
        return dtype._can_hold_na

    @final
    @cache_readonly
    def is_categorical(self) -> bool:
        warnings.warn(

            

Reported by Pylint.

Method 'dtype' has no 'kind' member
Error

Line: 515 Column: 33

              
        # no need to downcast our float
        # unless indicated
        if downcast is None and self.dtype.kind in ["f", "m", "M"]:
            # TODO: complex?  more generally, self._can_hold_na?
            return blocks

        return extend_blocks([b.downcast(downcast) for b in blocks])


            

Reported by Pylint.

pandas/io/clipboard/__init__.py
159 issues
Undefined variable 'Foundation'
Error

Line: 129 Column: 18

                  def copy_osx_pyobjc(text):
        """Copy string argument to clipboard"""
        text = _stringifyText(text)  # Converts non-str values to str.
        newStr = Foundation.NSString.stringWithString_(text).nsstring()
        newData = newStr.dataUsingEncoding_(Foundation.NSUTF8StringEncoding)
        board = AppKit.NSPasteboard.generalPasteboard()
        board.declareTypes_owner_([AppKit.NSStringPboardType], None)
        board.setData_forType_(newData, AppKit.NSStringPboardType)


            

Reported by Pylint.

Undefined variable 'Foundation'
Error

Line: 130 Column: 45

                      """Copy string argument to clipboard"""
        text = _stringifyText(text)  # Converts non-str values to str.
        newStr = Foundation.NSString.stringWithString_(text).nsstring()
        newData = newStr.dataUsingEncoding_(Foundation.NSUTF8StringEncoding)
        board = AppKit.NSPasteboard.generalPasteboard()
        board.declareTypes_owner_([AppKit.NSStringPboardType], None)
        board.setData_forType_(newData, AppKit.NSStringPboardType)

    def paste_osx_pyobjc():

            

Reported by Pylint.

Undefined variable 'AppKit'
Error

Line: 131 Column: 17

                      text = _stringifyText(text)  # Converts non-str values to str.
        newStr = Foundation.NSString.stringWithString_(text).nsstring()
        newData = newStr.dataUsingEncoding_(Foundation.NSUTF8StringEncoding)
        board = AppKit.NSPasteboard.generalPasteboard()
        board.declareTypes_owner_([AppKit.NSStringPboardType], None)
        board.setData_forType_(newData, AppKit.NSStringPboardType)

    def paste_osx_pyobjc():
        """Returns contents of clipboard"""

            

Reported by Pylint.

Undefined variable 'AppKit'
Error

Line: 132 Column: 36

                      newStr = Foundation.NSString.stringWithString_(text).nsstring()
        newData = newStr.dataUsingEncoding_(Foundation.NSUTF8StringEncoding)
        board = AppKit.NSPasteboard.generalPasteboard()
        board.declareTypes_owner_([AppKit.NSStringPboardType], None)
        board.setData_forType_(newData, AppKit.NSStringPboardType)

    def paste_osx_pyobjc():
        """Returns contents of clipboard"""
        board = AppKit.NSPasteboard.generalPasteboard()

            

Reported by Pylint.

Undefined variable 'AppKit'
Error

Line: 133 Column: 41

                      newData = newStr.dataUsingEncoding_(Foundation.NSUTF8StringEncoding)
        board = AppKit.NSPasteboard.generalPasteboard()
        board.declareTypes_owner_([AppKit.NSStringPboardType], None)
        board.setData_forType_(newData, AppKit.NSStringPboardType)

    def paste_osx_pyobjc():
        """Returns contents of clipboard"""
        board = AppKit.NSPasteboard.generalPasteboard()
        content = board.stringForType_(AppKit.NSStringPboardType)

            

Reported by Pylint.

Undefined variable 'AppKit'
Error

Line: 137 Column: 17

              
    def paste_osx_pyobjc():
        """Returns contents of clipboard"""
        board = AppKit.NSPasteboard.generalPasteboard()
        content = board.stringForType_(AppKit.NSStringPboardType)
        return content

    return copy_osx_pyobjc, paste_osx_pyobjc


            

Reported by Pylint.

Undefined variable 'AppKit'
Error

Line: 138 Column: 40

                  def paste_osx_pyobjc():
        """Returns contents of clipboard"""
        board = AppKit.NSPasteboard.generalPasteboard()
        content = board.stringForType_(AppKit.NSStringPboardType)
        return content

    return copy_osx_pyobjc, paste_osx_pyobjc



            

Reported by Pylint.

Instance of 'CheckedCall' has no 'f' member
Error

Line: 308 Column: 15

                      super().__setattr__("f", f)

    def __call__(self, *args):
        ret = self.f(*args)
        if not ret and get_errno():
            raise PyperclipWindowsException("Error calling " + self.f.__name__)
        return ret

    def __setattr__(self, key, value):

            

Reported by Pylint.

Instance of 'CheckedCall' has no 'f' member
Error

Line: 310 Column: 64

                  def __call__(self, *args):
        ret = self.f(*args)
        if not ret and get_errno():
            raise PyperclipWindowsException("Error calling " + self.f.__name__)
        return ret

    def __setattr__(self, key, value):
        setattr(self.f, key, value)


            

Reported by Pylint.

Instance of 'CheckedCall' has no 'f' member
Error

Line: 314 Column: 17

                      return ret

    def __setattr__(self, key, value):
        setattr(self.f, key, value)


def init_windows_clipboard():
    global HGLOBAL, LPVOID, DWORD, LPCSTR, INT
    global HWND, HINSTANCE, HMENU, BOOL, UINT, HANDLE

            

Reported by Pylint.

pandas/tests/scalar/timestamp/test_constructors.py
159 issues
Unable to import 'pytest'
Error

Line: 10 Column: 1

              import dateutil.tz
from dateutil.tz import tzutc
import numpy as np
import pytest
import pytz

from pandas.compat import PY310
from pandas.errors import OutOfBoundsDatetime


            

Reported by Pylint.

Unable to import 'pytz'
Error

Line: 11 Column: 1

              from dateutil.tz import tzutc
import numpy as np
import pytest
import pytz

from pandas.compat import PY310
from pandas.errors import OutOfBoundsDatetime

from pandas import (

            

Reported by Pylint.

Unused variable 'offset'
Error

Line: 147 Column: 21

                              assert result.value == expected

            # with timezone
            for tz, offset in timezones:
                result = Timestamp(date_str, tz=tz)
                expected_tz = expected
                assert result.value == expected_tz

                # should preserve tz

            

Reported by Pylint.

Use of eval
Error

Line: 167 Column: 26

                      assert result.value == Timestamp("2013-11-01 05:00").value
        expected = "Timestamp('2013-11-01 00:00:00-0500', tz='America/Chicago')"
        assert repr(result) == expected
        assert result == eval(repr(result))

        # This should be 2013-11-01 05:00 in UTC
        # converted to Tokyo tz (+09:00)
        result = Timestamp("2013-11-01 00:00:00-0500", tz="Asia/Tokyo")
        assert result.value == Timestamp("2013-11-01 05:00").value

            

Reported by Pylint.

Use of possibly insecure function - consider using safer ast.literal_eval.
Security blacklist

Line: 167
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval

                      assert result.value == Timestamp("2013-11-01 05:00").value
        expected = "Timestamp('2013-11-01 00:00:00-0500', tz='America/Chicago')"
        assert repr(result) == expected
        assert result == eval(repr(result))

        # This should be 2013-11-01 05:00 in UTC
        # converted to Tokyo tz (+09:00)
        result = Timestamp("2013-11-01 00:00:00-0500", tz="Asia/Tokyo")
        assert result.value == Timestamp("2013-11-01 05:00").value

            

Reported by Bandit.

Use of eval
Error

Line: 175 Column: 26

                      assert result.value == Timestamp("2013-11-01 05:00").value
        expected = "Timestamp('2013-11-01 14:00:00+0900', tz='Asia/Tokyo')"
        assert repr(result) == expected
        assert result == eval(repr(result))

        # GH11708
        # This should be 2015-11-18 10:00 in UTC
        # converted to Asia/Katmandu
        result = Timestamp("2015-11-18 15:45:00+05:45", tz="Asia/Katmandu")

            

Reported by Pylint.

Use of possibly insecure function - consider using safer ast.literal_eval.
Security blacklist

Line: 175
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval

                      assert result.value == Timestamp("2013-11-01 05:00").value
        expected = "Timestamp('2013-11-01 14:00:00+0900', tz='Asia/Tokyo')"
        assert repr(result) == expected
        assert result == eval(repr(result))

        # GH11708
        # This should be 2015-11-18 10:00 in UTC
        # converted to Asia/Katmandu
        result = Timestamp("2015-11-18 15:45:00+05:45", tz="Asia/Katmandu")

            

Reported by Bandit.

Use of eval
Error

Line: 184 Column: 26

                      assert result.value == Timestamp("2015-11-18 10:00").value
        expected = "Timestamp('2015-11-18 15:45:00+0545', tz='Asia/Katmandu')"
        assert repr(result) == expected
        assert result == eval(repr(result))

        # This should be 2015-11-18 10:00 in UTC
        # converted to Asia/Kolkata
        result = Timestamp("2015-11-18 15:30:00+05:30", tz="Asia/Kolkata")
        assert result.value == Timestamp("2015-11-18 10:00").value

            

Reported by Pylint.

Use of possibly insecure function - consider using safer ast.literal_eval.
Security blacklist

Line: 184
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval

                      assert result.value == Timestamp("2015-11-18 10:00").value
        expected = "Timestamp('2015-11-18 15:45:00+0545', tz='Asia/Katmandu')"
        assert repr(result) == expected
        assert result == eval(repr(result))

        # This should be 2015-11-18 10:00 in UTC
        # converted to Asia/Kolkata
        result = Timestamp("2015-11-18 15:30:00+05:30", tz="Asia/Kolkata")
        assert result.value == Timestamp("2015-11-18 10:00").value

            

Reported by Bandit.

Use of eval
Error

Line: 192 Column: 26

                      assert result.value == Timestamp("2015-11-18 10:00").value
        expected = "Timestamp('2015-11-18 15:30:00+0530', tz='Asia/Kolkata')"
        assert repr(result) == expected
        assert result == eval(repr(result))

    def test_constructor_invalid(self):
        msg = "Cannot convert input"
        with pytest.raises(TypeError, match=msg):
            Timestamp(slice(2))

            

Reported by Pylint.

pandas/tests/frame/test_api.py
159 issues
Unable to import 'pytest'
Error

Line: 6 Column: 1

              import pydoc

import numpy as np
import pytest

import pandas.util._test_decorators as td
from pandas.util._test_decorators import (
    async_mark,
    skip_if_no,

            

Reported by Pylint.

Unable to import 'IPython.core.completer'
Error

Line: 276 Column: 9

                  async def test_tab_complete_warning(self, ip, frame_or_series):
        # GH 16409
        pytest.importorskip("IPython", minversion="6.0.0")
        from IPython.core.completer import provisionalcompleter

        if frame_or_series is DataFrame:
            code = "from pandas import DataFrame; obj = DataFrame()"
        else:
            code = "from pandas import Series; obj = Series(dtype=object)"

            

Reported by Pylint.

Access to a protected member _get_axis_number of a client class
Error

Line: 40 Column: 16

              
    def test_get_axis(self, float_frame):
        f = float_frame
        assert f._get_axis_number(0) == 0
        assert f._get_axis_number(1) == 1
        assert f._get_axis_number("index") == 0
        assert f._get_axis_number("rows") == 0
        assert f._get_axis_number("columns") == 1


            

Reported by Pylint.

Access to a protected member _get_axis_number of a client class
Error

Line: 41 Column: 16

                  def test_get_axis(self, float_frame):
        f = float_frame
        assert f._get_axis_number(0) == 0
        assert f._get_axis_number(1) == 1
        assert f._get_axis_number("index") == 0
        assert f._get_axis_number("rows") == 0
        assert f._get_axis_number("columns") == 1

        assert f._get_axis_name(0) == "index"

            

Reported by Pylint.

Access to a protected member _get_axis_number of a client class
Error

Line: 42 Column: 16

                      f = float_frame
        assert f._get_axis_number(0) == 0
        assert f._get_axis_number(1) == 1
        assert f._get_axis_number("index") == 0
        assert f._get_axis_number("rows") == 0
        assert f._get_axis_number("columns") == 1

        assert f._get_axis_name(0) == "index"
        assert f._get_axis_name(1) == "columns"

            

Reported by Pylint.

Access to a protected member _get_axis_number of a client class
Error

Line: 43 Column: 16

                      assert f._get_axis_number(0) == 0
        assert f._get_axis_number(1) == 1
        assert f._get_axis_number("index") == 0
        assert f._get_axis_number("rows") == 0
        assert f._get_axis_number("columns") == 1

        assert f._get_axis_name(0) == "index"
        assert f._get_axis_name(1) == "columns"
        assert f._get_axis_name("index") == "index"

            

Reported by Pylint.

Access to a protected member _get_axis_number of a client class
Error

Line: 44 Column: 16

                      assert f._get_axis_number(1) == 1
        assert f._get_axis_number("index") == 0
        assert f._get_axis_number("rows") == 0
        assert f._get_axis_number("columns") == 1

        assert f._get_axis_name(0) == "index"
        assert f._get_axis_name(1) == "columns"
        assert f._get_axis_name("index") == "index"
        assert f._get_axis_name("rows") == "index"

            

Reported by Pylint.

Access to a protected member _get_axis_name of a client class
Error

Line: 46 Column: 16

                      assert f._get_axis_number("rows") == 0
        assert f._get_axis_number("columns") == 1

        assert f._get_axis_name(0) == "index"
        assert f._get_axis_name(1) == "columns"
        assert f._get_axis_name("index") == "index"
        assert f._get_axis_name("rows") == "index"
        assert f._get_axis_name("columns") == "columns"


            

Reported by Pylint.

Access to a protected member _get_axis_name of a client class
Error

Line: 47 Column: 16

                      assert f._get_axis_number("columns") == 1

        assert f._get_axis_name(0) == "index"
        assert f._get_axis_name(1) == "columns"
        assert f._get_axis_name("index") == "index"
        assert f._get_axis_name("rows") == "index"
        assert f._get_axis_name("columns") == "columns"

        assert f._get_axis(0) is f.index

            

Reported by Pylint.

Access to a protected member _get_axis_name of a client class
Error

Line: 48 Column: 16

              
        assert f._get_axis_name(0) == "index"
        assert f._get_axis_name(1) == "columns"
        assert f._get_axis_name("index") == "index"
        assert f._get_axis_name("rows") == "index"
        assert f._get_axis_name("columns") == "columns"

        assert f._get_axis(0) is f.index
        assert f._get_axis(1) is f.columns

            

Reported by Pylint.

pandas/tests/indexing/test_coercion.py
158 issues
Unable to import 'pytest'
Error

Line: 7 Column: 1

              import itertools

import numpy as np
import pytest

from pandas.compat import (
    IS64,
    is_platform_windows,
)

            

Reported by Pylint.

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

Line: 839 Column: 14

              
    def test_where_index_period(self):
        dti = pd.date_range("2016-01-01", periods=3, freq="QS")
        pi = dti.to_period("Q")

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

        # Passinga  valid scalar
        value = pi[-1] + pi.freq * 10

            

Reported by Pylint.

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

Line: 839 Column: 14

              
    def test_where_index_period(self):
        dti = pd.date_range("2016-01-01", periods=3, freq="QS")
        pi = dti.to_period("Q")

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

        # Passinga  valid scalar
        value = pi[-1] + pi.freq * 10

            

Reported by Pylint.

FIXME: dont leave commented-out
Error

Line: 87 Column: 3

                      # check dtype explicitly for sure
        assert temp.dtype == expected_dtype

        # FIXME: dont leave commented-out
        # .loc works different rule, temporary disable
        # temp = original_series.copy()
        # temp.loc[1] = loc_value
        # tm.assert_series_equal(temp, expected_series)


            

Reported by Pylint.

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

Line: 393 Column: 16

                  )
    def test_insert_index_object(self, insert, coerced_val, coerced_dtype):
        obj = pd.Index(list("abcd"))
        assert obj.dtype == object

        exp = pd.Index(["a", coerced_val, "b", "c", "d"])
        self._assert_insert_conversion(obj, insert, exp, coerced_dtype)

    @pytest.mark.parametrize(

            

Reported by Pylint.

Unused argument 'insert_value'
Error

Line: 442 Column: 73

                      "insert_value",
        [pd.Timestamp("2012-01-01"), pd.Timestamp("2012-01-01", tz="Asia/Tokyo"), 1],
    )
    def test_insert_index_datetimes(self, request, fill_val, exp_dtype, insert_value):

        obj = pd.DatetimeIndex(
            ["2011-01-01", "2011-01-02", "2011-01-03", "2011-01-04"], tz=fill_val.tz
        )
        assert obj.dtype == exp_dtype

            

Reported by Pylint.

Unused argument 'request'
Error

Line: 442 Column: 43

                      "insert_value",
        [pd.Timestamp("2012-01-01"), pd.Timestamp("2012-01-01", tz="Asia/Tokyo"), 1],
    )
    def test_insert_index_datetimes(self, request, fill_val, exp_dtype, insert_value):

        obj = pd.DatetimeIndex(
            ["2011-01-01", "2011-01-02", "2011-01-03", "2011-01-04"], tz=fill_val.tz
        )
        assert obj.dtype == exp_dtype

            

Reported by Pylint.

TODO: ATM inserting '2012-01-01 00:00:00' when we have obj.freq=="M"
Error

Line: 534 Column: 3

                          expected = obj.astype(object).insert(0, insert)
            tm.assert_index_equal(result, expected)

            # TODO: ATM inserting '2012-01-01 00:00:00' when we have obj.freq=="M"
            #  casts that string to Period[M], not clear that is desirable
            if not isinstance(insert, pd.Timestamp):
                # non-castable string
                result = obj.insert(0, str(insert))
                expected = obj.astype(object).insert(0, str(insert))

            

Reported by Pylint.

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

Line: 751 Column: 16

                              pd.Timestamp("2011-01-04"),
            ]
        )
        assert obj.dtype == "datetime64[ns]"
        cond = pd.Index([True, False, True, False])

        result = obj.where(cond, fill_val)
        expected = pd.DatetimeIndex([obj[0], fill_val, obj[2], fill_val])
        tm.assert_index_equal(result, expected)

            

Reported by Pylint.

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

Line: 782 Column: 16

                              pd.Timestamp("2011-01-04"),
            ]
        )
        assert obj.dtype == "datetime64[ns]"
        cond = pd.Index([True, False, True, False])

        msg = "Index\\(\\.\\.\\.\\) must be called with a collection of some kind"
        with pytest.raises(TypeError, match=msg):
            obj.where(cond, fill_val)

            

Reported by Pylint.

pandas/tests/groupby/test_apply.py
157 issues
Unable to import 'pytest'
Error

Line: 8 Column: 1

              from io import StringIO

import numpy as np
import pytest

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

            

Reported by Pylint.

TODO: Use assert_frame_equal when column name is not np.nan (GH 36306)
Error

Line: 362 Column: 3

                  grouped = df.groupby(["A", "B"], as_index=False)
    result = grouped.apply(len)
    expected = grouped.count().rename(columns={"C": np.nan}).drop(columns="D")
    # TODO: Use assert_frame_equal when column name is not np.nan (GH 36306)
    tm.assert_index_equal(result.index, expected.index)
    tm.assert_numpy_array_equal(result.values, expected.values)


def test_apply_frame_concat_series():

            

Reported by Pylint.

Unused argument 'batch'
Error

Line: 680 Column: 27

              
    df = DataFrame({"a": 1, "b": [datetime.now() for nn in range(10)]})

    def func_with_no_date(batch):
        return Series({"c": 2})

    def func_with_date(batch):
        return Series({"b": datetime(2015, 1, 1), "c": 2})


            

Reported by Pylint.

Unused argument 'batch'
Error

Line: 683 Column: 24

                  def func_with_no_date(batch):
        return Series({"c": 2})

    def func_with_date(batch):
        return Series({"b": datetime(2015, 1, 1), "c": 2})

    dfg_no_conversion = df.groupby(by=["a"]).apply(func_with_no_date)
    dfg_no_conversion_expected = DataFrame({"c": 2}, index=[1])
    dfg_no_conversion_expected.index.name = "a"

            

Reported by Pylint.

Unused argument 'x'
Error

Line: 730 Column: 19

                  # values. Issue 9684.
    test_df = DataFrame({"groups": [0, 0, 1, 1], "random_vars": [8, 7, 4, 5]})

    def test_func(x):
        pass

    result = test_df.groupby("groups").apply(test_func)
    expected = DataFrame()
    tm.assert_frame_equal(result, expected)

            

Reported by Pylint.

TODO: more informative name
Error

Line: 1144 Column: 3

              
def test_doctest_example2():
    # GH#42702 this fails if we cache_readonly Block.shape
    # TODO: more informative name
    df = DataFrame({"A": ["a", "a", "b"], "B": [1, 2, 3], "C": [4, 6, 5]})
    gb = df.groupby("A")
    result = gb[["B", "C"]].apply(lambda x: x.astype(float).max() - x.min())

    expected = DataFrame(

            

Reported by Pylint.

Too many lines in module (1152/1000)
Error

Line: 1 Column: 1

              from datetime import (
    date,
    datetime,
)
from io import StringIO

import numpy as np
import pytest


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from datetime import (
    date,
    datetime,
)
from io import StringIO

import numpy as np
import pytest


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 21 Column: 1

              import pandas._testing as tm


def test_apply_issues():
    # GH 5788

    s = """2011.05.16,00:00,1.40893
2011.05.16,01:00,1.40760
2011.05.16,02:00,1.40750

            

Reported by Pylint.

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

Line: 24 Column: 5

              def test_apply_issues():
    # GH 5788

    s = """2011.05.16,00:00,1.40893
2011.05.16,01:00,1.40760
2011.05.16,02:00,1.40750
2011.05.16,03:00,1.40649
2011.05.17,02:00,1.40893
2011.05.17,03:00,1.40760

            

Reported by Pylint.

asv_bench/benchmarks/strings.py
156 issues
Unable to import 'pandas'
Error

Line: 5 Column: 1

              
import numpy as np

from pandas import (
    Categorical,
    DataFrame,
    Series,
)


            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 11 Column: 1

                  Series,
)

from .pandas_vb_common import tm


class Dtypes:
    params = ["str", "string[python]", "string[pyarrow]"]
    param_names = ["dtype"]

            

Reported by Pylint.

Attribute 's' defined outside __init__
Error

Line: 20 Column: 13

              
    def setup(self, dtype):
        try:
            self.s = Series(tm.makeStringIndex(10 ** 5), dtype=dtype)
        except ImportError:
            raise NotImplementedError


class Construction:

            

Reported by Pylint.

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

Line: 22 Column: 13

                      try:
            self.s = Series(tm.makeStringIndex(10 ** 5), dtype=dtype)
        except ImportError:
            raise NotImplementedError


class Construction:

    params = ["str", "string"]

            

Reported by Pylint.

Unused argument 'dtype'
Error

Line: 30 Column: 21

                  params = ["str", "string"]
    param_names = ["dtype"]

    def setup(self, dtype):
        self.series_arr = tm.rands_array(nchars=10, size=10 ** 5)
        self.frame_arr = self.series_arr.reshape((50_000, 2)).copy()

        # GH37371. Testing construction of string series/frames from ExtensionArrays
        self.series_cat_arr = Categorical(self.series_arr)

            

Reported by Pylint.

Attribute 'series_arr' defined outside __init__
Error

Line: 31 Column: 9

                  param_names = ["dtype"]

    def setup(self, dtype):
        self.series_arr = tm.rands_array(nchars=10, size=10 ** 5)
        self.frame_arr = self.series_arr.reshape((50_000, 2)).copy()

        # GH37371. Testing construction of string series/frames from ExtensionArrays
        self.series_cat_arr = Categorical(self.series_arr)
        self.frame_cat_arr = Categorical(self.frame_arr)

            

Reported by Pylint.

Attribute 'frame_arr' defined outside __init__
Error

Line: 32 Column: 9

              
    def setup(self, dtype):
        self.series_arr = tm.rands_array(nchars=10, size=10 ** 5)
        self.frame_arr = self.series_arr.reshape((50_000, 2)).copy()

        # GH37371. Testing construction of string series/frames from ExtensionArrays
        self.series_cat_arr = Categorical(self.series_arr)
        self.frame_cat_arr = Categorical(self.frame_arr)


            

Reported by Pylint.

Attribute 'series_cat_arr' defined outside __init__
Error

Line: 35 Column: 9

                      self.frame_arr = self.series_arr.reshape((50_000, 2)).copy()

        # GH37371. Testing construction of string series/frames from ExtensionArrays
        self.series_cat_arr = Categorical(self.series_arr)
        self.frame_cat_arr = Categorical(self.frame_arr)

    def time_series_construction(self, dtype):
        Series(self.series_arr, dtype=dtype)


            

Reported by Pylint.

Attribute 'frame_cat_arr' defined outside __init__
Error

Line: 36 Column: 9

              
        # GH37371. Testing construction of string series/frames from ExtensionArrays
        self.series_cat_arr = Categorical(self.series_arr)
        self.frame_cat_arr = Categorical(self.frame_arr)

    def time_series_construction(self, dtype):
        Series(self.series_arr, dtype=dtype)

    def peakmem_series_construction(self, dtype):

            

Reported by Pylint.

Unused argument 'dtype'
Error

Line: 64 Column: 27

              

class Methods(Dtypes):
    def time_center(self, dtype):
        self.s.str.center(100)

    def time_count(self, dtype):
        self.s.str.count("A")


            

Reported by Pylint.