The following issues were found

pandas/tests/io/excel/test_readers.py
321 issues
Unable to import 'pytest'
Error

Line: 12 Column: 1

              from zipfile import BadZipFile

import numpy as np
import pytest

import pandas.util._test_decorators as td

import pandas as pd
from pandas import (

            

Reported by Pylint.

Unable to import 'xlrd'
Error

Line: 758 Column: 13

                              "specify an engine manually."
            )
        elif engine == "xlrd":
            from xlrd import XLRDError

            error = XLRDError
            msg = (
                "Unsupported format, or corrupt file: Expected BOF "
                "record; found b'foo'"

            

Reported by Pylint.

Unable to import 's3fs'
Error

Line: 799 Column: 9

                      with open("test1" + read_ext, "rb") as f:
            s3_resource.Bucket("pandas-test").put_object(Key="test1" + read_ext, Body=f)

        import s3fs

        s3 = s3fs.S3FileSystem(**s3so)

        with s3.open("s3://pandas-test/test1" + read_ext) as f:
            url_table = pd.read_excel(f)

            

Reported by Pylint.

Unable to import 'py.path'
Error

Line: 845 Column: 9

                  def test_read_from_py_localpath(self, read_ext):

        # GH12655
        from py.path import local as LocalPath

        str_path = os.path.join("test1" + read_ext)
        expected = pd.read_excel(str_path, sheet_name="Sheet1", index_col=0)

        path_obj = LocalPath().join("test1" + read_ext)

            

Reported by Pylint.

Unable to import 'xlrd'
Error

Line: 1555 Column: 13

                      if engine is None:
            pytest.skip()
        elif engine == "xlrd":
            import xlrd

            errors = (BadZipFile, xlrd.biffh.XLRDError)

        with tm.ensure_clean(f"corrupt{read_ext}") as file:
            Path(file).write_text("corrupt")

            

Reported by Pylint.

Redefining name 'engine' from outer scope (line 109)
Error

Line: 56 Column: 31

              ]


def _is_valid_engine_ext_pair(engine, read_ext: str) -> bool:
    """
    Filter out invalid (engine, ext) pairs instead of skipping, as that
    produces 500+ pytest.skips.
    """
    engine = engine.values[0]

            

Reported by Pylint.

Redefining name 'read_ext' from outer scope (line 115)
Error

Line: 56 Column: 39

              ]


def _is_valid_engine_ext_pair(engine, read_ext: str) -> bool:
    """
    Filter out invalid (engine, ext) pairs instead of skipping, as that
    produces 500+ pytest.skips.
    """
    engine = engine.values[0]

            

Reported by Pylint.

Redefining name 'engine' from outer scope (line 109)
Error

Line: 82 Column: 21

                  return True


def _transfer_marks(engine, read_ext):
    """
    engine gives us a pytest.param object with some marks, read_ext is just
    a string.  We need to generate a new pytest.param inheriting the marks.
    """
    values = engine.values + (read_ext,)

            

Reported by Pylint.

Redefining name 'read_ext' from outer scope (line 115)
Error

Line: 82 Column: 29

                  return True


def _transfer_marks(engine, read_ext):
    """
    engine gives us a pytest.param object with some marks, read_ext is just
    a string.  We need to generate a new pytest.param inheriting the marks.
    """
    values = engine.values + (read_ext,)

            

Reported by Pylint.

Redefining name 'engine_and_read_ext' from outer scope (line 99)
Error

Line: 109 Column: 12

              

@pytest.fixture
def engine(engine_and_read_ext):
    engine, read_ext = engine_and_read_ext
    return engine


@pytest.fixture

            

Reported by Pylint.

asv_bench/benchmarks/groupby.py
318 issues
Unable to import 'pandas'
Error

Line: 7 Column: 1

              
import numpy as np

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

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 17 Column: 1

                  period_range,
)

from .pandas_vb_common import tm

method_blocklist = {
    "object": {
        "median",
        "prod",

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 874 Column: 1

                      self.df.groupby(self.groups).sample(n=1, weights=self.weights)


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

            

Reported by Pylint.

Attribute 'labels' defined outside __init__
Error

Line: 61 Column: 9

              
class ApplyDictReturn:
    def setup(self):
        self.labels = np.arange(1000).repeat(10)
        self.data = Series(np.random.randn(len(self.labels)))

    def time_groupby_apply_dict_return(self):
        self.data.groupby(self.labels).apply(
            lambda x: {"first": x.values[0], "last": x.values[-1]}

            

Reported by Pylint.

Attribute 'data' defined outside __init__
Error

Line: 62 Column: 9

              class ApplyDictReturn:
    def setup(self):
        self.labels = np.arange(1000).repeat(10)
        self.data = Series(np.random.randn(len(self.labels)))

    def time_groupby_apply_dict_return(self):
        self.data.groupby(self.labels).apply(
            lambda x: {"first": x.values[0], "last": x.values[-1]}
        )

            

Reported by Pylint.

Attribute 'df' defined outside __init__
Error

Line: 92 Column: 9

                              "value2": ["foo", "bar", "baz", "qux"] * (N // 4),
            }
        )
        self.df = df

    def time_scalar_function_multi_col(self, factor):
        self.df.groupby(["key", "key2"]).apply(lambda x: 1)

    def time_scalar_function_single_col(self, factor):

            

Reported by Pylint.

Unused argument 'factor'
Error

Line: 94 Column: 46

                      )
        self.df = df

    def time_scalar_function_multi_col(self, factor):
        self.df.groupby(["key", "key2"]).apply(lambda x: 1)

    def time_scalar_function_single_col(self, factor):
        self.df.groupby("key").apply(lambda x: 1)


            

Reported by Pylint.

Unused argument 'factor'
Error

Line: 97 Column: 47

                  def time_scalar_function_multi_col(self, factor):
        self.df.groupby(["key", "key2"]).apply(lambda x: 1)

    def time_scalar_function_single_col(self, factor):
        self.df.groupby("key").apply(lambda x: 1)

    @staticmethod
    def df_copy_function(g):
        # ensure that the group name is available (see GH #15062)

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 103 Column: 9

                  @staticmethod
    def df_copy_function(g):
        # ensure that the group name is available (see GH #15062)
        g.name
        return g.copy()

    def time_copy_function_multi_col(self, factor):
        self.df.groupby(["key", "key2"]).apply(self.df_copy_function)


            

Reported by Pylint.

Unused argument 'factor'
Error

Line: 106 Column: 44

                      g.name
        return g.copy()

    def time_copy_function_multi_col(self, factor):
        self.df.groupby(["key", "key2"]).apply(self.df_copy_function)

    def time_copy_overhead_single_col(self, factor):
        self.df.groupby("key").apply(self.df_copy_function)


            

Reported by Pylint.

pandas/tests/resample/test_datetime_index.py
311 issues
Unable to import 'pytest'
Error

Line: 6 Column: 1

              from io import StringIO

import numpy as np
import pytest
import pytz

from pandas._libs import lib
from pandas.errors import UnsupportedFunctionCall


            

Reported by Pylint.

Unable to import 'pytz'
Error

Line: 7 Column: 1

              
import numpy as np
import pytest
import pytz

from pandas._libs import lib
from pandas.errors import UnsupportedFunctionCall

import pandas as pd

            

Reported by Pylint.

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

Line: 9 Column: 1

              import pytest
import pytz

from pandas._libs import lib
from pandas.errors import UnsupportedFunctionCall

import pandas as pd
from pandas import (
    DataFrame,

            

Reported by Pylint.

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

Line: 881 Column: 59

                  ts_no_tz = ts_1.tz_localize(None)
    result_3 = ts_no_tz.resample("D", origin="epoch").mean()
    result_4 = ts_no_tz.resample("24H", origin="epoch").mean()
    tm.assert_series_equal(result_1, result_3.tz_localize(rng.tz), check_freq=False)
    tm.assert_series_equal(result_1, result_4.tz_localize(rng.tz), check_freq=False)

    # check that we have the similar results with two different timezones (+2H and +5H)
    start, end = "2000-10-01 23:30:00+0200", "2000-12-02 00:30:00+0200"
    rng = date_range(start, end, freq="7min")

            

Reported by Pylint.

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

Line: 881 Column: 59

                  ts_no_tz = ts_1.tz_localize(None)
    result_3 = ts_no_tz.resample("D", origin="epoch").mean()
    result_4 = ts_no_tz.resample("24H", origin="epoch").mean()
    tm.assert_series_equal(result_1, result_3.tz_localize(rng.tz), check_freq=False)
    tm.assert_series_equal(result_1, result_4.tz_localize(rng.tz), check_freq=False)

    # check that we have the similar results with two different timezones (+2H and +5H)
    start, end = "2000-10-01 23:30:00+0200", "2000-12-02 00:30:00+0200"
    rng = date_range(start, end, freq="7min")

            

Reported by Pylint.

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

Line: 882 Column: 59

                  result_3 = ts_no_tz.resample("D", origin="epoch").mean()
    result_4 = ts_no_tz.resample("24H", origin="epoch").mean()
    tm.assert_series_equal(result_1, result_3.tz_localize(rng.tz), check_freq=False)
    tm.assert_series_equal(result_1, result_4.tz_localize(rng.tz), check_freq=False)

    # check that we have the similar results with two different timezones (+2H and +5H)
    start, end = "2000-10-01 23:30:00+0200", "2000-12-02 00:30:00+0200"
    rng = date_range(start, end, freq="7min")
    ts_2 = Series(random_values, index=rng)

            

Reported by Pylint.

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

Line: 882 Column: 59

                  result_3 = ts_no_tz.resample("D", origin="epoch").mean()
    result_4 = ts_no_tz.resample("24H", origin="epoch").mean()
    tm.assert_series_equal(result_1, result_3.tz_localize(rng.tz), check_freq=False)
    tm.assert_series_equal(result_1, result_4.tz_localize(rng.tz), check_freq=False)

    # check that we have the similar results with two different timezones (+2H and +5H)
    start, end = "2000-10-01 23:30:00+0200", "2000-12-02 00:30:00+0200"
    rng = date_range(start, end, freq="7min")
    ts_2 = Series(random_values, index=rng)

            

Reported by Pylint.

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

Line: 1077 Column: 20

                  # #1471, #1458

    rng = date_range("1/1/2012", "4/1/2012", freq="100min")
    df = DataFrame(rng.month, index=rng)

    result = df.resample("M").mean()
    expected = df.resample("M", kind="period").mean().to_timestamp(how="end")
    expected.index += Timedelta(1, "ns") - Timedelta(1, "D")
    expected.index = expected.index._with_freq("infer")

            

Reported by Pylint.

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

Line: 1077 Column: 20

                  # #1471, #1458

    rng = date_range("1/1/2012", "4/1/2012", freq="100min")
    df = DataFrame(rng.month, index=rng)

    result = df.resample("M").mean()
    expected = df.resample("M", kind="period").mean().to_timestamp(how="end")
    expected.index += Timedelta(1, "ns") - Timedelta(1, "D")
    expected.index = expected.index._with_freq("infer")

            

Reported by Pylint.

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

Line: 1096 Column: 20

                  tm.assert_frame_equal(result, exp)

    rng = date_range("1/1/2012", "4/1/2012", freq="100min")
    df = DataFrame(rng.month, index=rng)

    result = df.resample("Q").mean()
    expected = df.resample("Q", kind="period").mean().to_timestamp(how="end")
    expected.index += Timedelta(1, "ns") - Timedelta(1, "D")
    expected.index._data.freq = "Q"

            

Reported by Pylint.

pandas/tests/frame/test_stack_unstack.py
306 issues
Unable to import 'pytest'
Error

Line: 6 Column: 1

              import itertools

import numpy as np
import pytest

import pandas.util._test_decorators as td

import pandas as pd
from pandas import (

            

Reported by Pylint.

Instance of 'tuple' has no 'levels' member
Error

Line: 649 Column: 45

                      exp_col = MultiIndex.from_product([[0, 1], ["A", "B", "C"]])
        expected = DataFrame([[1, 1, 1, 0, 0, 0]], index=["a"], columns=exp_col)
        tm.assert_frame_equal(result, expected)
        assert (result.columns.levels[1] == idx.levels[1]).all()

        # Unused items on both levels
        levels = [[0, 1, 7], [0, 1, 2, 3]]
        codes = [[0, 0, 1, 1], [0, 2, 0, 2]]
        idx = MultiIndex(levels, codes)

            

Reported by Pylint.

Access to a protected member _mgr of a client class
Error

Line: 71 Column: 24

                      df2 = df[["x"]]
        df2["y"] = df["y"]
        if not using_array_manager:
            assert len(df2._mgr.blocks) == 2

        res = df2.unstack()
        expected = df.unstack()
        tm.assert_series_equal(res, expected)


            

Reported by Pylint.

Redefining name 'td' from outer scope (line 8)
Error

Line: 187 Column: 9

                  def test_unstack_fill_frame_timedelta(self):

        # Test unstacking with time deltas
        td = [Timedelta(days=i) for i in range(4)]
        data = Series(td)
        data.index = MultiIndex.from_tuples(
            [("x", "a"), ("x", "b"), ("y", "b"), ("z", "a")]
        )


            

Reported by Pylint.

TODO(ArrayManager) MultiIndex bug
Error

Line: 952 Column: 3

                      left = df.loc[17264:].copy().set_index(["s_id", "dosage", "agent"])
        tm.assert_frame_equal(left.unstack(), right)

    @td.skip_array_manager_not_yet_implemented  # TODO(ArrayManager) MultiIndex bug
    def test_unstack_nan_index5(self):
        # GH9497 - multiple unstack with nulls
        df = DataFrame(
            {
                "1st": [1, 2, 1, 2, 1, 2],

            

Reported by Pylint.

Access to a protected member _mgr of a client class
Error

Line: 1295 Column: 58

                  df = DataFrame(np.random.randn(15, 4), index=mi)
    df[1] = df[1].astype(np.int64)
    if not using_array_manager:
        assert any(not x.mgr_locs.is_slice_like for x in df._mgr.blocks)

    res = df.unstack()

    expected = pd.concat([df[n].unstack() for n in range(4)], keys=range(4), axis=1)
    tm.assert_frame_equal(res, expected)

            

Reported by Pylint.

Access to a protected member _mgr of a client class
Error

Line: 1952 Column: 24

                      # add another int column to get 2 blocks
        df["is_"] = 1
        if not using_array_manager:
            assert len(df._mgr.blocks) == 2

        result = df.unstack("b")
        result[("is_", "ca")] = result[("is_", "ca")].fillna(0)

        expected = DataFrame(

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from datetime import datetime
from io import StringIO
import itertools

import numpy as np
import pytest

import pandas.util._test_decorators as td


            

Reported by Pylint.

Too many lines in module (2083/1000)
Error

Line: 1 Column: 1

              from datetime import datetime
from io import StringIO
import itertools

import numpy as np
import pytest

import pandas.util._test_decorators as td


            

Reported by Pylint.

Too many public methods (38/20)
Error

Line: 23 Column: 1

              import pandas._testing as tm


class TestDataFrameReshape:
    def test_stack_unstack(self, float_frame):
        df = float_frame.copy()
        df[:] = np.arange(np.prod(df.shape)).reshape(df.shape)

        stacked = df.stack()

            

Reported by Pylint.

pandas/tests/io/excel/test_writers.py
306 issues
Unable to import 'pytest'
Error

Line: 12 Column: 1

              import re

import numpy as np
import pytest

import pandas.util._test_decorators as td

import pandas as pd
from pandas import (

            

Reported by Pylint.

Abstract class 'ExcelWriter' with abstract methods instantiated
Error

Line: 114 Column: 18

                      refdf = DataFrame([[1, "foo"], [2, "bar"], [3, "baz"]], columns=["a", "b"])

        with tm.ensure_clean(ext) as pth:
            with ExcelWriter(pth) as writer:
                refdf.to_excel(writer, "Data_no_head", header=False, index=False)
                refdf.to_excel(writer, "Data_with_head", index=False)

            refdf.columns = ["A", "B"]


            

Reported by Pylint.

Abstract class 'ExcelWriter' with abstract methods instantiated
Error

Line: 149 Column: 18

                      dfs = dict(zip(sheets, dfs))

        with tm.ensure_clean(ext) as pth:
            with ExcelWriter(pth) as ew:
                for sheetname, df in dfs.items():
                    df.to_excel(ew, sheetname)

            dfs_returned = pd.read_excel(pth, sheet_name=sheets, index_col=0)


            

Reported by Pylint.

Abstract class 'ExcelWriter' with abstract methods instantiated
Error

Line: 366 Column: 14

                          pd.read_excel(xl, "0")

    def test_excel_writer_context_manager(self, frame, path):
        with ExcelWriter(path) as writer:
            frame.to_excel(writer, "Data1")
            frame2 = frame.copy()
            frame2.columns = frame.columns[::-1]
            frame2.to_excel(writer, "Data2")


            

Reported by Pylint.

Abstract class 'ExcelWriter' with abstract methods instantiated
Error

Line: 535 Column: 14

                      frame.to_excel(path, "test1", index=False)

        # Test writing to separate sheets
        with ExcelWriter(path) as writer:
            frame.to_excel(writer, "test1")
            tsframe.to_excel(writer, "test2")
        with ExcelFile(path) as reader:
            recons = pd.read_excel(reader, sheet_name="test1", index_col=0)
            tm.assert_frame_equal(frame, recons)

            

Reported by Pylint.

Abstract class 'ExcelWriter' with abstract methods instantiated
Error

Line: 673 Column: 18

                      )

        with tm.ensure_clean(ext) as filename2:
            with ExcelWriter(path) as writer1:
                df.to_excel(writer1, "test1")

            with ExcelWriter(
                filename2,
                date_format="DD.MM.YYYY",

            

Reported by Pylint.

Abstract class 'ExcelWriter' with abstract methods instantiated
Error

Line: 676 Column: 18

                          with ExcelWriter(path) as writer1:
                df.to_excel(writer1, "test1")

            with ExcelWriter(
                filename2,
                date_format="DD.MM.YYYY",
                datetime_format="DD.MM.YYYY HH-MM-SS",
            ) as writer2:
                df.to_excel(writer2, "test1")

            

Reported by Pylint.

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

Line: 771 Column: 68

              
    # GH13511
    def test_to_excel_multiindex_nan_label(self, merge_cells, path):
        df = DataFrame({"A": [None, 2, 3], "B": [10, 20, 30], "C": np.random.sample(3)})
        df = df.set_index(["A", "B"])

        df.to_excel(path, merge_cells=merge_cells)
        df1 = pd.read_excel(path, index_col=[0, 1])
        tm.assert_frame_equal(df, df1)

            

Reported by Pylint.

Abstract class 'ExcelWriter' with abstract methods instantiated
Error

Line: 1221 Column: 18

                          df = DataFrame(np.random.randn(10, 2))

            # Pass engine explicitly, as there is no file path to infer from.
            with ExcelWriter(bio, engine=engine) as writer:
                df.to_excel(writer)

            bio.seek(0)
            reread_df = pd.read_excel(bio, index_col=0)
            tm.assert_frame_equal(df, reread_df)

            

Reported by Pylint.

Abstract class 'ExcelWriter' with abstract methods instantiated
Error

Line: 1342 Column: 17

              
        with tm.ensure_clean(ext) as f:
            with pytest.raises(ValueError, match=re.escape(msg)):
                ExcelWriter(f, if_sheet_exists="replace")


class TestExcelWriterEngineTests:
    @pytest.mark.parametrize(
        "klass,ext",

            

Reported by Pylint.

pandas/tests/io/formats/test_to_latex.py
301 issues
Unable to import 'pytest'
Error

Line: 5 Column: 1

              from datetime import datetime
from textwrap import dedent

import pytest

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

            

Reported by Pylint.

Redefining name 'df_short' from outer scope (line 34)
Error

Line: 458 Column: 42

                      """Label for longtable LaTeX environment."""
        return "tab:longtable"

    def test_to_latex_caption_only(self, df_short, caption_table):
        # GH 25436
        result = df_short.to_latex(caption=caption_table)
        expected = _dedent(
            r"""
            \begin{table}

            

Reported by Pylint.

Redefining name 'df_short' from outer scope (line 34)
Error

Line: 479 Column: 40

                      )
        assert result == expected

    def test_to_latex_label_only(self, df_short, label_table):
        # GH 25436
        result = df_short.to_latex(label=label_table)
        expected = _dedent(
            r"""
            \begin{table}

            

Reported by Pylint.

Redefining name 'df_short' from outer scope (line 34)
Error

Line: 500 Column: 47

                      )
        assert result == expected

    def test_to_latex_caption_and_label(self, df_short, caption_table, label_table):
        # GH 25436
        result = df_short.to_latex(caption=caption_table, label=label_table)
        expected = _dedent(
            r"""
            \begin{table}

            

Reported by Pylint.

Redefining name 'df_short' from outer scope (line 34)
Error

Line: 524 Column: 9

              
    def test_to_latex_caption_and_shortcaption(
        self,
        df_short,
        caption_table,
        short_caption,
    ):
        result = df_short.to_latex(caption=(caption_table, short_caption))
        expected = _dedent(

            

Reported by Pylint.

Redefining name 'df_short' from outer scope (line 34)
Error

Line: 547 Column: 65

                      )
        assert result == expected

    def test_to_latex_caption_and_shortcaption_list_is_ok(self, df_short):
        caption = ("Long-long-caption", "Short")
        result_tuple = df_short.to_latex(caption=caption)
        result_list = df_short.to_latex(caption=list(caption))
        assert result_tuple == result_list


            

Reported by Pylint.

Redefining name 'df_short' from outer scope (line 34)
Error

Line: 555 Column: 9

              
    def test_to_latex_caption_shortcaption_and_label(
        self,
        df_short,
        caption_table,
        short_caption,
        label_table,
    ):
        # test when the short_caption is provided alongside caption and label

            

Reported by Pylint.

Redefining name 'df_short' from outer scope (line 34)
Error

Line: 601 Column: 47

                      with pytest.raises(ValueError, match=msg):
            df.to_latex(caption=bad_caption)

    def test_to_latex_two_chars_caption(self, df_short):
        # test that two chars caption is handled correctly
        # it must not be unpacked into long_caption, short_caption.
        result = df_short.to_latex(caption="xy")
        expected = _dedent(
            r"""

            

Reported by Pylint.

Redefining name 'df_short' from outer scope (line 34)
Error

Line: 623 Column: 52

                      )
        assert result == expected

    def test_to_latex_longtable_caption_only(self, df_short, caption_longtable):
        # GH 25436
        # test when no caption and no label is provided
        # is performed by test_to_latex_longtable()
        result = df_short.to_latex(longtable=True, caption=caption_longtable)
        expected = _dedent(

            

Reported by Pylint.

Redefining name 'df_short' from outer scope (line 34)
Error

Line: 655 Column: 50

                      )
        assert result == expected

    def test_to_latex_longtable_label_only(self, df_short, label_longtable):
        # GH 25436
        result = df_short.to_latex(longtable=True, label=label_longtable)
        expected = _dedent(
            r"""
            \begin{longtable}{lrl}

            

Reported by Pylint.

pandas/tests/frame/test_reductions.py
293 issues
Unable to import 'pytest'
Error

Line: 7 Column: 1

              
from dateutil.tz import tzlocal
import numpy as np
import pytest

from pandas.compat import is_platform_windows
import pandas.util._test_decorators as td

from pandas.core.dtypes.common import is_categorical_dtype

            

Reported by Pylint.

Unable to import 'scipy.stats'
Error

Line: 323 Column: 13

                          return np.std(x, ddof=1) / np.sqrt(len(x))

        def skewness(x):
            from scipy.stats import skew  # noqa:F811

            if len(x) < 3:
                return np.nan
            return skew(x, bias=False)


            

Reported by Pylint.

Unable to import 'scipy.stats'
Error

Line: 330 Column: 13

                          return skew(x, bias=False)

        def kurt(x):
            from scipy.stats import kurtosis  # noqa:F811

            if len(x) < 4:
                return np.nan
            return kurtosis(x, bias=False)


            

Reported by Pylint.

Access to a protected member _make_skipna_wrapper of a client class
Error

Line: 90 Column: 26

                      def wrapper(x):
            return alternative(x.values)

        skipna_wrapper = tm._make_skipna_wrapper(alternative, skipna_alternative)
        result0 = f(axis=0, skipna=False)
        result1 = f(axis=1, skipna=False)
        tm.assert_series_equal(
            result0, frame.apply(wrapper), check_dtype=check_dtype, rtol=rtol, atol=atol
        )

            

Reported by Pylint.

FIXME: HACK: win32
Error

Line: 96 Column: 3

                      tm.assert_series_equal(
            result0, frame.apply(wrapper), check_dtype=check_dtype, rtol=rtol, atol=atol
        )
        # FIXME: HACK: win32
        tm.assert_series_equal(
            result1,
            frame.apply(wrapper, axis=1),
            check_dtype=False,
            rtol=rtol,

            

Reported by Pylint.

FIXME: HACK: win32
Error

Line: 205 Column: 3

                      tm.assert_series_equal(result0, frame.apply(wrapper))
        tm.assert_series_equal(
            result1, frame.apply(wrapper, axis=1), check_dtype=False
        )  # FIXME: HACK: win32
    else:
        skipna_wrapper = alternative
        wrapper = alternative

    result0 = f(axis=0)

            

Reported by Pylint.

Unused kurtosis imported from scipy.stats
Error

Line: 293 Column: 13

                      assert_stat_op_api("median", float_frame, float_string_frame)

        try:
            from scipy.stats import (  # noqa:F401
                kurtosis,
                skew,
            )

            assert_stat_op_api("skew", float_frame, float_string_frame)

            

Reported by Pylint.

Unused skew imported from scipy.stats
Error

Line: 293 Column: 13

                      assert_stat_op_api("median", float_frame, float_string_frame)

        try:
            from scipy.stats import (  # noqa:F401
                kurtosis,
                skew,
            )

            assert_stat_op_api("skew", float_frame, float_string_frame)

            

Reported by Pylint.

Unused skew imported from scipy
Error

Line: 379 Column: 13

                      )

        try:
            from scipy import (  # noqa:F401
                kurtosis,
                skew,
            )

            assert_stat_op_calc("skew", skewness, float_frame_with_na)

            

Reported by Pylint.

Unused kurtosis imported from scipy
Error

Line: 379 Column: 13

                      )

        try:
            from scipy import (  # noqa:F401
                kurtosis,
                skew,
            )

            assert_stat_op_calc("skew", skewness, float_frame_with_na)

            

Reported by Pylint.

pandas/tests/arithmetic/test_period.py
291 issues
Unable to import 'pytest'
Error

Line: 7 Column: 1

              import operator

import numpy as np
import pytest

from pandas._libs.tslibs import (
    IncompatibleFrequency,
    Period,
    Timestamp,

            

Reported by Pylint.

bad operand type for unary ~: IntervalArray
Error

Line: 98 Column: 33

                      tm.assert_equal(result, expected)

        result = parr != other
        tm.assert_equal(result, ~expected)
        result = parr < other
        tm.assert_equal(result, ~expected)
        result = parr > other
        tm.assert_equal(result, ~expected)


            

Reported by Pylint.

bad operand type for unary ~: Index
Error

Line: 98 Column: 33

                      tm.assert_equal(result, expected)

        result = parr != other
        tm.assert_equal(result, ~expected)
        result = parr < other
        tm.assert_equal(result, ~expected)
        result = parr > other
        tm.assert_equal(result, ~expected)


            

Reported by Pylint.

bad operand type for unary ~: ArrowStringArray
Error

Line: 98 Column: 33

                      tm.assert_equal(result, expected)

        result = parr != other
        tm.assert_equal(result, ~expected)
        result = parr < other
        tm.assert_equal(result, ~expected)
        result = parr > other
        tm.assert_equal(result, ~expected)


            

Reported by Pylint.

bad operand type for unary ~: PeriodArray
Error

Line: 98 Column: 33

                      tm.assert_equal(result, expected)

        result = parr != other
        tm.assert_equal(result, ~expected)
        result = parr < other
        tm.assert_equal(result, ~expected)
        result = parr > other
        tm.assert_equal(result, ~expected)


            

Reported by Pylint.

bad operand type for unary ~: IntervalArray
Error

Line: 100 Column: 33

                      result = parr != other
        tm.assert_equal(result, ~expected)
        result = parr < other
        tm.assert_equal(result, ~expected)
        result = parr > other
        tm.assert_equal(result, ~expected)

        other = other_box(pi[::-1])


            

Reported by Pylint.

bad operand type for unary ~: ArrowStringArray
Error

Line: 100 Column: 33

                      result = parr != other
        tm.assert_equal(result, ~expected)
        result = parr < other
        tm.assert_equal(result, ~expected)
        result = parr > other
        tm.assert_equal(result, ~expected)

        other = other_box(pi[::-1])


            

Reported by Pylint.

bad operand type for unary ~: Index
Error

Line: 100 Column: 33

                      result = parr != other
        tm.assert_equal(result, ~expected)
        result = parr < other
        tm.assert_equal(result, ~expected)
        result = parr > other
        tm.assert_equal(result, ~expected)

        other = other_box(pi[::-1])


            

Reported by Pylint.

bad operand type for unary ~: PeriodArray
Error

Line: 100 Column: 33

                      result = parr != other
        tm.assert_equal(result, ~expected)
        result = parr < other
        tm.assert_equal(result, ~expected)
        result = parr > other
        tm.assert_equal(result, ~expected)

        other = other_box(pi[::-1])


            

Reported by Pylint.

bad operand type for unary ~: IntervalArray
Error

Line: 102 Column: 33

                      result = parr < other
        tm.assert_equal(result, ~expected)
        result = parr > other
        tm.assert_equal(result, ~expected)

        other = other_box(pi[::-1])

        expected = np.array([False, False, True, False, False])
        expected = tm.box_expected(expected, xbox)

            

Reported by Pylint.

pandas/tests/scalar/timestamp/test_timestamp.py
290 issues
Unable to import 'pytest'
Error

Line: 14 Column: 1

              
from dateutil.tz import tzutc
import numpy as np
import pytest
import pytz
from pytz import (
    timezone,
    utc,
)

            

Reported by Pylint.

Unable to import 'pytz'
Error

Line: 15 Column: 1

              from dateutil.tz import tzutc
import numpy as np
import pytest
import pytz
from pytz import (
    timezone,
    utc,
)


            

Reported by Pylint.

Unable to import 'pytz'
Error

Line: 16 Column: 1

              import numpy as np
import pytest
import pytz
from pytz import (
    timezone,
    utc,
)

from pandas._libs.tslibs.timezones import (

            

Reported by Pylint.

Unable to import 'pandas._libs.tslibs.timezones'
Error

Line: 21 Column: 1

                  utc,
)

from pandas._libs.tslibs.timezones import (
    dateutil_gettz as gettz,
    get_timezone,
)
from pandas.compat import np_datetime64_compat
import pandas.util._test_decorators as td

            

Reported by Pylint.

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

Line: 21 Column: 1

                  utc,
)

from pandas._libs.tslibs.timezones import (
    dateutil_gettz as gettz,
    get_timezone,
)
from pandas.compat import np_datetime64_compat
import pandas.util._test_decorators as td

            

Reported by Pylint.

Too many positional arguments for method call
Error

Line: 281 Column: 49

              
        for n in ns:
            assert (
                Timestamp(n).asm8.view("i8") == np.datetime64(n, "ns").view("i8") == n
            )

        assert Timestamp("nat").asm8.view("i8") == np.datetime64("nat", "ns").view("i8")

    def test_class_ops_pytz(self):

            

Reported by Pylint.

Too many positional arguments for method call
Error

Line: 284 Column: 52

                              Timestamp(n).asm8.view("i8") == np.datetime64(n, "ns").view("i8") == n
            )

        assert Timestamp("nat").asm8.view("i8") == np.datetime64("nat", "ns").view("i8")

    def test_class_ops_pytz(self):
        def compare(x, y):
            assert int((Timestamp(x).value - Timestamp(y).value) / 1e9) == 0


            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 50 Column: 13

                      msg = "Timestamp.freq is deprecated"
        with tm.assert_produces_warning(FutureWarning, match=msg):
            # warning issued at attribute lookup
            ts.freq

        for per in ["month", "quarter", "year"]:
            for side in ["start", "end"]:
                attr = f"is_{per}_{side}"


            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 111 Column: 13

                      check(ts.second, 3)
        msg = "'Timestamp' object has no attribute 'millisecond'"
        with pytest.raises(AttributeError, match=msg):
            ts.millisecond
        check(ts.microsecond, 100)
        check(ts.nanosecond, 1)
        check(ts.dayofweek, 6)
        check(ts.day_of_week, 6)
        check(ts.quarter, 2)

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 133 Column: 13

                      check(ts.second, 0)
        msg = "'Timestamp' object has no attribute 'millisecond'"
        with pytest.raises(AttributeError, match=msg):
            ts.millisecond
        check(ts.microsecond, 0)
        check(ts.nanosecond, 0)
        check(ts.dayofweek, 2)
        check(ts.day_of_week, 2)
        check(ts.quarter, 4)

            

Reported by Pylint.

pandas/tests/indexes/period/test_indexing.py
288 issues
Unable to import 'pytest'
Error

Line: 8 Column: 1

              import re

import numpy as np
import pytest

from pandas._libs.tslibs import period as libperiod
from pandas.errors import InvalidIndexError

import pandas as pd

            

Reported by Pylint.

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

Line: 10 Column: 1

              import numpy as np
import pytest

from pandas._libs.tslibs import period as libperiod
from pandas.errors import InvalidIndexError

import pandas as pd
from pandas import (
    DatetimeIndex,

            

Reported by Pylint.

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

Line: 332 Column: 14

              
    def test_get_loc_integer(self):
        dti = date_range("2016-01-01", periods=3)
        pi = dti.to_period("D")
        with pytest.raises(KeyError, match="16801"):
            pi.get_loc(16801)

        pi2 = dti.to_period("Y")  # duplicates, ordinals are all 46
        with pytest.raises(KeyError, match="46"):

            

Reported by Pylint.

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

Line: 332 Column: 14

              
    def test_get_loc_integer(self):
        dti = date_range("2016-01-01", periods=3)
        pi = dti.to_period("D")
        with pytest.raises(KeyError, match="16801"):
            pi.get_loc(16801)

        pi2 = dti.to_period("Y")  # duplicates, ordinals are all 46
        with pytest.raises(KeyError, match="46"):

            

Reported by Pylint.

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

Line: 336 Column: 15

                      with pytest.raises(KeyError, match="16801"):
            pi.get_loc(16801)

        pi2 = dti.to_period("Y")  # duplicates, ordinals are all 46
        with pytest.raises(KeyError, match="46"):
            pi2.get_loc(46)

    # TODO: This method came from test_period; de-dup with version above
    @pytest.mark.parametrize("method", [None, "pad", "backfill", "nearest"])

            

Reported by Pylint.

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

Line: 336 Column: 15

                      with pytest.raises(KeyError, match="16801"):
            pi.get_loc(16801)

        pi2 = dti.to_period("Y")  # duplicates, ordinals are all 46
        with pytest.raises(KeyError, match="46"):
            pi2.get_loc(46)

    # TODO: This method came from test_period; de-dup with version above
    @pytest.mark.parametrize("method", [None, "pad", "backfill", "nearest"])

            

Reported by Pylint.

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

Line: 416 Column: 14

                      # see also test_get_indexer_mismatched_dtype testing we get analogous
        # behavior for get_loc
        dti = date_range("2016-01-01", periods=3)
        pi = dti.to_period("D")
        pi2 = dti.to_period("W")
        pi3 = pi.view(pi2.dtype)  # i.e. matching i8 representations

        with pytest.raises(KeyError, match="W-SUN"):
            pi.get_loc(pi2[0])

            

Reported by Pylint.

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

Line: 416 Column: 14

                      # see also test_get_indexer_mismatched_dtype testing we get analogous
        # behavior for get_loc
        dti = date_range("2016-01-01", periods=3)
        pi = dti.to_period("D")
        pi2 = dti.to_period("W")
        pi3 = pi.view(pi2.dtype)  # i.e. matching i8 representations

        with pytest.raises(KeyError, match="W-SUN"):
            pi.get_loc(pi2[0])

            

Reported by Pylint.

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

Line: 417 Column: 15

                      # behavior for get_loc
        dti = date_range("2016-01-01", periods=3)
        pi = dti.to_period("D")
        pi2 = dti.to_period("W")
        pi3 = pi.view(pi2.dtype)  # i.e. matching i8 representations

        with pytest.raises(KeyError, match="W-SUN"):
            pi.get_loc(pi2[0])


            

Reported by Pylint.

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

Line: 417 Column: 15

                      # behavior for get_loc
        dti = date_range("2016-01-01", periods=3)
        pi = dti.to_period("D")
        pi2 = dti.to_period("W")
        pi3 = pi.view(pi2.dtype)  # i.e. matching i8 representations

        with pytest.raises(KeyError, match="W-SUN"):
            pi.get_loc(pi2[0])


            

Reported by Pylint.