The following issues were found

pandas/tests/series/methods/test_cov_corr.py
45 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              import math

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 'scipy.stats'
Error

Line: 61 Column: 9

              class TestSeriesCorr:
    @td.skip_if_no_scipy
    def test_corr(self, datetime_series):
        import scipy.stats as stats

        # full overlap
        tm.assert_almost_equal(datetime_series.corr(datetime_series), 1)

        # partial overlap

            

Reported by Pylint.

Unable to import 'scipy.stats'
Error

Line: 91 Column: 9

              
    @td.skip_if_no_scipy
    def test_corr_rank(self):
        import scipy.stats as stats

        # kendall and spearman
        A = tm.makeTimeSeries()
        B = tm.makeTimeSeries()
        A[-5:] = A[:5]

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import math

import numpy as np
import pytest

import pandas.util._test_decorators as td

import pandas as pd
from pandas import (

            

Reported by Pylint.

Missing class docstring
Error

Line: 16 Column: 1

              import pandas._testing as tm


class TestSeriesCov:
    def test_cov(self, datetime_series):
        # full overlap
        tm.assert_almost_equal(
            datetime_series.cov(datetime_series), datetime_series.std() ** 2
        )

            

Reported by Pylint.

Method could be a function
Error

Line: 17 Column: 5

              

class TestSeriesCov:
    def test_cov(self, datetime_series):
        # full overlap
        tm.assert_almost_equal(
            datetime_series.cov(datetime_series), datetime_series.std() ** 2
        )


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 5

              

class TestSeriesCov:
    def test_cov(self, datetime_series):
        # full overlap
        tm.assert_almost_equal(
            datetime_series.cov(datetime_series), datetime_series.std() ** 2
        )


            

Reported by Pylint.

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

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

                      )

        # No overlap
        assert np.isnan(datetime_series[::2].cov(datetime_series[1::2]))

        # all NA
        cp = datetime_series[:10].copy()
        cp[:] = np.nan
        assert isna(cp.cov(cp))

            

Reported by Bandit.

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

Line: 33 Column: 9

                      assert np.isnan(datetime_series[::2].cov(datetime_series[1::2]))

        # all NA
        cp = datetime_series[:10].copy()
        cp[:] = np.nan
        assert isna(cp.cov(cp))

        # min_periods
        assert isna(datetime_series[:15].cov(datetime_series[5:], min_periods=12))

            

Reported by Pylint.

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

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

                      # all NA
        cp = datetime_series[:10].copy()
        cp[:] = np.nan
        assert isna(cp.cov(cp))

        # min_periods
        assert isna(datetime_series[:15].cov(datetime_series[5:], min_periods=12))

        ts1 = datetime_series[:15].reindex(datetime_series.index)

            

Reported by Bandit.

pandas/tests/tseries/offsets/test_month.py
45 issues
Unable to import 'pytest'
Error

Line: 10 Column: 1

              """
from datetime import datetime

import pytest

from pandas._libs.tslibs import Timestamp
from pandas._libs.tslibs.offsets import (
    MonthBegin,
    MonthEnd,

            

Reported by Pylint.

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

Line: 13 Column: 1

              import pytest

from pandas._libs.tslibs import Timestamp
from pandas._libs.tslibs.offsets import (
    MonthBegin,
    MonthEnd,
    SemiMonthBegin,
    SemiMonthEnd,
)

            

Reported by Pylint.

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

Line: 13 Column: 1

              import pytest

from pandas._libs.tslibs import Timestamp
from pandas._libs.tslibs.offsets import (
    MonthBegin,
    MonthEnd,
    SemiMonthBegin,
    SemiMonthEnd,
)

            

Reported by Pylint.

Missing class docstring
Error

Line: 33 Column: 1

              )


class TestSemiMonthEnd(Base):
    _offset = SemiMonthEnd
    offset1 = _offset()
    offset2 = _offset(2)

    def test_offset_whole_year(self):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 38 Column: 5

                  offset1 = _offset()
    offset2 = _offset(2)

    def test_offset_whole_year(self):
        dates = (
            datetime(2007, 12, 31),
            datetime(2008, 1, 15),
            datetime(2008, 1, 31),
            datetime(2008, 2, 15),

            

Reported by Pylint.

Method could be a function
Error

Line: 38 Column: 5

                  offset1 = _offset()
    offset2 = _offset(2)

    def test_offset_whole_year(self):
        dates = (
            datetime(2007, 12, 31),
            datetime(2008, 1, 15),
            datetime(2008, 1, 31),
            datetime(2008, 2, 15),

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 211 Column: 5

                  )

    @pytest.mark.parametrize("case", offset_cases)
    def test_offset(self, case):
        offset, cases = case
        for base, expected in cases.items():
            assert_offset_equal(offset, base, expected)

    @pytest.mark.parametrize("case", offset_cases)

            

Reported by Pylint.

Method could be a function
Error

Line: 211 Column: 5

                  )

    @pytest.mark.parametrize("case", offset_cases)
    def test_offset(self, case):
        offset, cases = case
        for base, expected in cases.items():
            assert_offset_equal(offset, base, expected)

    @pytest.mark.parametrize("case", offset_cases)

            

Reported by Pylint.

Method could be a function
Error

Line: 217 Column: 5

                          assert_offset_equal(offset, base, expected)

    @pytest.mark.parametrize("case", offset_cases)
    def test_apply_index(self, case):
        # https://github.com/pandas-dev/pandas/issues/34580
        offset, cases = case
        shift = DatetimeIndex(cases.keys())
        exp = DatetimeIndex(cases.values())


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 217 Column: 5

                          assert_offset_equal(offset, base, expected)

    @pytest.mark.parametrize("case", offset_cases)
    def test_apply_index(self, case):
        # https://github.com/pandas-dev/pandas/issues/34580
        offset, cases = case
        shift = DatetimeIndex(cases.keys())
        exp = DatetimeIndex(cases.values())


            

Reported by Pylint.

pandas/core/base.py
45 issues
Unable to import 'pandas._libs.lib'
Error

Line: 21 Column: 1

              
import numpy as np

import pandas._libs.lib as lib
from pandas._typing import (
    ArrayLike,
    DtypeObj,
    FrameOrSeries,
    IndexLabel,

            

Reported by Pylint.

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

Line: 21 Column: 1

              
import numpy as np

import pandas._libs.lib as lib
from pandas._typing import (
    ArrayLike,
    DtypeObj,
    FrameOrSeries,
    IndexLabel,

            

Reported by Pylint.

memory_usage is not callable
Error

Line: 122 Column: 19

                      """
        memory_usage = getattr(self, "memory_usage", None)
        if memory_usage:
            mem = memory_usage(deep=True)
            return int(mem if is_scalar(mem) else mem.sum())

        # no memory_usage attribute, so fall back to object's 'sizeof'
        return super().__sizeof__()


            

Reported by Pylint.

Method '_selected_obj' has no 'ndim' member
Error

Line: 202 Column: 16

                  @final
    @cache_readonly
    def ndim(self) -> int:
        return self._selected_obj.ndim

    @final
    @cache_readonly
    def _obj_with_exclusions(self):
        if self._selection is not None and isinstance(self.obj, ABCDataFrame):

            

Reported by Pylint.

Module 'numpy.typing' has no 'NDArray' member
Error

Line: 1225 Column: 64

                      """

    @doc(_shared_docs["searchsorted"], klass="Index")
    def searchsorted(self, value, side="left", sorter=None) -> npt.NDArray[np.intp]:
        return algorithms.searchsorted(self._values, value, side=side, sorter=sorter)

    def drop_duplicates(self, keep="first"):
        duplicated = self._duplicated(keep=keep)
        # error: Value of type "IndexOpsMixin" is not indexable

            

Reported by Pylint.

Module 'numpy.typing' has no 'NDArray' member
Error

Line: 1236 Column: 10

                  @final
    def _duplicated(
        self, keep: Literal["first", "last", False] = "first"
    ) -> npt.NDArray[np.bool_]:
        return duplicated(self._values, keep=keep)

            

Reported by Pylint.

TODO(GH-24345): Avoid potential double copy
Error

Line: 531 Column: 3

                          )

        result = np.asarray(self._values, dtype=dtype)
        # TODO(GH-24345): Avoid potential double copy
        if copy or na_value is not lib.no_default:
            result = result.copy()
            if na_value is not lib.no_default:
                result[self.isna()] = na_value
        return result

            

Reported by Pylint.

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

Line: 542 Column: 5

                  def empty(self) -> bool:
        return not self.size

    def max(self, axis=None, skipna: bool = True, *args, **kwargs):
        """
        Return the maximum value of the Index.

        Parameters
        ----------

            

Reported by Pylint.

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

Line: 587 Column: 5

                      return nanops.nanmax(self._values, skipna=skipna)

    @doc(op="max", oppose="min", value="largest")
    def argmax(self, axis=None, skipna: bool = True, *args, **kwargs) -> int:
        """
        Return int position of the {value} value in the Series.

        If the {op}imum is achieved in multiple locations,
        the first row position is returned.

            

Reported by Pylint.

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

Line: 654 Column: 5

                              delegate, skipna=skipna
            )

    def min(self, axis=None, skipna: bool = True, *args, **kwargs):
        """
        Return the minimum value of the Index.

        Parameters
        ----------

            

Reported by Pylint.

pandas/io/formats/html.py
45 issues
No name 'lib' in module 'pandas._libs'
Error

Line: 16 Column: 1

              
from pandas._config import get_option

from pandas._libs import lib

from pandas import (
    MultiIndex,
    option_context,
)

            

Reported by Pylint.

TODO: Refactor to remove code duplication with code
Error

Line: 315 Column: 3

                              # Column Offset Bug with to_html(index=False) with
                # MultiIndex Columns and Index.
                # Initially fill row with blank cells before column names.
                # TODO: Refactor to remove code duplication with code
                # block below for standard columns index.
                row = [""] * (self.row_levels - 1)
                if self.fmt.index or self.show_col_idx_names:
                    # see gh-22747
                    # If to_html(index_names=False) do not show columns

            

Reported by Pylint.

TODO: Refactor to use _get_column_name_list from
Error

Line: 322 Column: 3

                                  # see gh-22747
                    # If to_html(index_names=False) do not show columns
                    # index names.
                    # TODO: Refactor to use _get_column_name_list from
                    # DataFrameFormatter class and create a
                    # _get_formatted_column_labels function for code
                    # parity with DataFrameFormatter class.
                    if self.fmt.show_index_names:
                        name = self.columns.names[lnum]

            

Reported by Pylint.

TODO: Refactor to remove code duplication with code block
Error

Line: 348 Column: 3

                          # Column misalignment also occurs for
            # a standard index when the columns index is named.
            # Initially fill row with blank cells before column names.
            # TODO: Refactor to remove code duplication with code block
            # above for columns MultiIndex.
            row = [""] * (self.row_levels - 1)
            if self.fmt.index or self.show_col_idx_names:
                # see gh-22747
                # If to_html(index_names=False) do not show columns

            

Reported by Pylint.

TODO: Refactor to use _get_column_name_list from
Error

Line: 355 Column: 3

                              # see gh-22747
                # If to_html(index_names=False) do not show columns
                # index names.
                # TODO: Refactor to use _get_column_name_list from
                # DataFrameFormatter class.
                if self.fmt.show_index_names:
                    row.append(self.columns.name or "")
                else:
                    row.append("")

            

Reported by Pylint.

Access to a protected member _get_formatter of a client class
Error

Line: 414 Column: 19

                      nrows = len(self.fmt.tr_frame)

        if self.fmt.index:
            fmt = self.fmt._get_formatter("__index__")
            if fmt is not None:
                index_values = self.fmt.tr_frame.index.map(fmt)
            else:
                index_values = self.fmt.tr_frame.index.format()


            

Reported by Pylint.

Too many instance attributes (12/7)
Error

Line: 31 Column: 1

              from pandas.io.formats.printing import pprint_thing


class HTMLFormatter:
    """
    Internal class for formatting output data in html.
    This class is intended for shared functionality between
    DataFrame.to_html() and DataFrame._repr_html_().
    Any logic in common with other output formatting methods

            

Reported by Pylint.

Too many arguments (6/5)
Error

Line: 43 Column: 5

              
    indent_delta = 2

    def __init__(
        self,
        formatter: DataFrameFormatter,
        classes: str | list[str] | tuple[str, ...] | None = None,
        border: int | None = None,
        table_id: str | None = None,

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 71 Column: 5

                          for column, value in self.fmt.col_space.items()
        }

    def to_string(self) -> str:
        lines = self.render()
        if any(isinstance(x, str) for x in lines):
            lines = [str(x) for x in lines]
        return "\n".join(lines)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 77 Column: 5

                          lines = [str(x) for x in lines]
        return "\n".join(lines)

    def render(self) -> list[str]:
        self._write_table()

        if self.should_show_dimensions:
            by = chr(215)  # ×
            self.write(

            

Reported by Pylint.

setup.py
45 issues
Attribute 'all' defined outside __init__
Error

Line: 113 Column: 9

                  user_options = [("all", "a", "")]

    def initialize_options(self):
        self.all = True
        self._clean_me = []
        self._clean_trees = []

        base = pjoin("pandas", "_libs", "src")
        tsbase = pjoin("pandas", "_libs", "tslibs", "src")

            

Reported by Pylint.

Attribute '_clean_me' defined outside __init__
Error

Line: 114 Column: 9

              
    def initialize_options(self):
        self.all = True
        self._clean_me = []
        self._clean_trees = []

        base = pjoin("pandas", "_libs", "src")
        tsbase = pjoin("pandas", "_libs", "tslibs", "src")
        dt = pjoin(tsbase, "datetime")

            

Reported by Pylint.

Attribute '_clean_trees' defined outside __init__
Error

Line: 115 Column: 9

                  def initialize_options(self):
        self.all = True
        self._clean_me = []
        self._clean_trees = []

        base = pjoin("pandas", "_libs", "src")
        tsbase = pjoin("pandas", "_libs", "tslibs", "src")
        dt = pjoin(tsbase, "datetime")
        util = pjoin("pandas", "util")

            

Reported by Pylint.

Attribute '_clean_exclude' defined outside __init__
Error

Line: 124 Column: 9

                      parser = pjoin(base, "parser")
        ujson_python = pjoin(base, "ujson", "python")
        ujson_lib = pjoin(base, "ujson", "lib")
        self._clean_exclude = [
            pjoin(dt, "np_datetime.c"),
            pjoin(dt, "np_datetime_strings.c"),
            pjoin(parser, "tokenizer.c"),
            pjoin(parser, "io.c"),
            pjoin(ujson_python, "ujson.c"),

            

Reported by Pylint.

Redefining name 'root' from outer scope (line 605)
Error

Line: 138 Column: 13

                          pjoin(util, "move.c"),
        ]

        for root, dirs, files in os.walk("pandas"):
            for f in files:
                filepath = pjoin(root, f)
                if filepath in self._clean_exclude:
                    continue


            

Reported by Pylint.

Redefining name 'files' from outer scope (line 70)
Error

Line: 138 Column: 25

                          pjoin(util, "move.c"),
        ]

        for root, dirs, files in os.walk("pandas"):
            for f in files:
                filepath = pjoin(root, f)
                if filepath in self._clean_exclude:
                    continue


            

Reported by Pylint.

Redefining name 'extensions' from outer scope (line 561)
Error

Line: 261 Column: 39

                  Subclass build_ext to get clearer report if Cython is necessary.
    """

    def check_cython_extensions(self, extensions):
        for ext in extensions:
            for src in ext.sources:
                if not os.path.exists(src):
                    print(f"{ext.name}: -> [{ext.sources}]")
                    raise Exception(

            

Reported by Pylint.

Redefining name 'ext' from outer scope (line 603)
Error

Line: 262 Column: 13

                  """

    def check_cython_extensions(self, extensions):
        for ext in extensions:
            for src in ext.sources:
                if not os.path.exists(src):
                    print(f"{ext.name}: -> [{ext.sources}]")
                    raise Exception(
                        f"""Cython-generated file '{src}' not found.

            

Reported by Pylint.

Redefining name 'ext' from outer scope (line 603)
Error

Line: 285 Column: 31

                  C-compile method build_extension() with a no-op.
    """

    def build_extension(self, ext):
        pass


class DummyBuildSrc(Command):
    """numpy's build_src command interferes with Cython's build_ext."""

            

Reported by Pylint.

Attribute 'py_modules_dict' defined outside __init__
Error

Line: 295 Column: 9

                  user_options = []

    def initialize_options(self):
        self.py_modules_dict = {}

    def finalize_options(self):
        pass

    def run(self):

            

Reported by Pylint.

pandas/core/arrays/boolean.py
44 issues
No name 'missing' in module 'pandas._libs'
Error

Line: 9 Column: 1

              
import numpy as np

from pandas._libs import (
    lib,
    missing as libmissing,
)
from pandas._typing import (
    ArrayLike,

            

Reported by Pylint.

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

Line: 9 Column: 1

              
import numpy as np

from pandas._libs import (
    lib,
    missing as libmissing,
)
from pandas._typing import (
    ArrayLike,

            

Reported by Pylint.

Unable to import 'pyarrow'
Error

Line: 42 Column: 5

              )

if TYPE_CHECKING:
    import pyarrow


@register_extension_dtype
class BooleanDtype(BaseMaskedDtype):
    """

            

Reported by Pylint.

Unable to import 'pyarrow'
Error

Line: 115 Column: 9

                      """
        Construct BooleanArray from pyarrow Array/ChunkedArray.
        """
        import pyarrow

        if array.type != pyarrow.bool_():
            raise TypeError(f"Expected array of boolean type, got {array.type} instead")

        if isinstance(array, pyarrow.Array):

            

Reported by Pylint.

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

Line: 80 Column: 5

                      return np.bool_

    @property
    def kind(self) -> str:
        return "b"

    @property
    def numpy_dtype(self) -> np.dtype:
        return np.dtype("bool")

            

Reported by Pylint.

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

Line: 84 Column: 5

                      return "b"

    @property
    def numpy_dtype(self) -> np.dtype:
        return np.dtype("bool")

    @classmethod
    def construct_array_type(cls) -> type_t[BooleanArray]:
        """

            

Reported by Pylint.

Access to a protected member _concat_same_type of a client class
Error

Line: 148 Column: 20

                              np.array([], dtype=np.bool_), np.array([], dtype=np.bool_)
            )
        else:
            return BooleanArray._concat_same_type(results)


def coerce_to_array(
    values, mask=None, copy: bool = False
) -> tuple[np.ndarray, np.ndarray]:

            

Reported by Pylint.

Access to a protected member _data of a client class
Error

Line: 171 Column: 24

                  if isinstance(values, BooleanArray):
        if mask is not None:
            raise ValueError("cannot pass mask for BooleanArray input")
        values, mask = values._data, values._mask
        if copy:
            values = values.copy()
            mask = mask.copy()
        return values, mask


            

Reported by Pylint.

Access to a protected member _mask of a client class
Error

Line: 171 Column: 38

                  if isinstance(values, BooleanArray):
        if mask is not None:
            raise ValueError("cannot pass mask for BooleanArray input")
        values, mask = values._data, values._mask
        if copy:
            values = values.copy()
            mask = mask.copy()
        return values, mask


            

Reported by Pylint.

Parameters differ from overridden '_from_sequence_of_strings' method
Error

Line: 320 Column: 5

                      return BooleanArray(values, mask)

    @classmethod
    def _from_sequence_of_strings(
        cls,
        strings: list[str],
        *,
        dtype: Dtype | None = None,
        copy: bool = False,

            

Reported by Pylint.

pandas/tests/io/pytables/test_read.py
44 issues
Unable to import 'pytest'
Error

Line: 5 Column: 1

              import re

import numpy as np
import pytest

from pandas._libs.tslibs import Timestamp
from pandas.compat import is_platform_windows

import pandas as pd

            

Reported by Pylint.

Unexpected keyword argument 'where' in method call
Error

Line: 83 Column: 13

              
        msg = re.escape("select_column() got an unexpected keyword argument 'where'")
        with pytest.raises(TypeError, match=msg):
            store.select_column("df", "index", where=["index>5"])

        # valid
        result = store.select_column("df", "index")
        tm.assert_almost_equal(result.values, Series(df.index).values)
        assert isinstance(result, Series)

            

Reported by Pylint.

Unable to import 'py.path'
Error

Line: 296 Column: 5

              def test_read_from_py_localpath(setup_path):

    # GH11773
    from py.path import local as LocalPath

    expected = DataFrame(
        np.random.rand(4, 5), index=list("abcd"), columns=list("ABCDE")
    )
    with ensure_clean_path(setup_path) as filename:

            

Reported by Pylint.

Unused argument 'setup_path'
Error

Line: 140 Column: 41

                      tm.assert_series_equal(result, expected)


def test_pytables_native_read(datapath, setup_path):
    with ensure_clean_store(
        datapath("io", "data", "legacy_hdf/pytables_native.h5"), mode="r"
    ) as store:
        d2 = store["detector/readout"]
        assert isinstance(d2, DataFrame)

            

Reported by Pylint.

Unused argument 'setup_path'
Error

Line: 149 Column: 42

              

@pytest.mark.skipif(is_platform_windows(), reason="native2 read fails oddly on windows")
def test_pytables_native2_read(datapath, setup_path):
    with ensure_clean_store(
        datapath("io", "data", "legacy_hdf", "pytables_native2.h5"), mode="r"
    ) as store:
        str(store)
        d1 = store["detector"]

            

Reported by Pylint.

Unused argument 'setup_path'
Error

Line: 158 Column: 55

                      assert isinstance(d1, DataFrame)


def test_legacy_table_fixed_format_read_py2(datapath, setup_path):
    # GH 24510
    # legacy table with fixed format written in Python 2
    with ensure_clean_store(
        datapath("io", "data", "legacy_hdf", "legacy_table_fixed_py2.h5"), mode="r"
    ) as store:

            

Reported by Pylint.

Unused argument 'setup_path'
Error

Line: 173 Column: 64

                      tm.assert_frame_equal(expected, result)


def test_legacy_table_fixed_format_read_datetime_py2(datapath, setup_path):
    # GH 31750
    # legacy table with fixed format and datetime64 column written in Python 2
    with ensure_clean_store(
        datapath("io", "data", "legacy_hdf", "legacy_table_fixed_datetime_py2.h5"),
        mode="r",

            

Reported by Pylint.

Unused argument 'setup_path'
Error

Line: 189 Column: 42

                      tm.assert_frame_equal(expected, result)


def test_legacy_table_read_py2(datapath, setup_path):
    # issue: 24925
    # legacy table written in Python 2
    with ensure_clean_store(
        datapath("io", "data", "legacy_hdf", "legacy_table_py2.h5"), mode="r"
    ) as store:

            

Reported by Pylint.

Redefining built-in 'format'
Error

Line: 311 Column: 33

              

@pytest.mark.parametrize("format", ["fixed", "table"])
def test_read_hdf_series_mode_r(format, setup_path):
    # GH 16583
    # Tests that reading a Series saved to an HDF file
    # still works if a mode='r' argument is supplied
    series = tm.makeFloatSeries()
    with ensure_clean_path(setup_path) as path:

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from pathlib import Path
import re

import numpy as np
import pytest

from pandas._libs.tslibs import Timestamp
from pandas.compat import is_platform_windows


            

Reported by Pylint.

pandas/tests/resample/test_time_grouper.py
44 issues
Unable to import 'pytest'
Error

Line: 5 Column: 1

              from operator import methodcaller

import numpy as np
import pytest

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

            

Reported by Pylint.

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

Line: 213 Column: 22

                  expected = normal_result.append(pad)
    expected = expected.sort_index()
    dti = date_range(start="2013-01-01", freq="D", periods=5, name="key")
    expected.index = dti._with_freq(None)  # TODO: is this desired?
    tm.assert_frame_equal(expected, dt_result)
    assert dt_result.index.name == "key"


def test_aggregate_with_nat_size():

            

Reported by Pylint.

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

Line: 213 Column: 22

                  expected = normal_result.append(pad)
    expected = expected.sort_index()
    dti = date_range(start="2013-01-01", freq="D", periods=5, name="key")
    expected.index = dti._with_freq(None)  # TODO: is this desired?
    tm.assert_frame_equal(expected, dt_result)
    assert dt_result.index.name == "key"


def test_aggregate_with_nat_size():

            

Reported by Pylint.

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

Line: 243 Column: 22

                  pad = Series([0], index=[3])
    expected = normal_result.append(pad)
    expected = expected.sort_index()
    expected.index = date_range(
        start="2013-01-01", freq="D", periods=5, name="key"
    )._with_freq(None)
    tm.assert_series_equal(expected, dt_result)
    assert dt_result.index.name == "key"


            

Reported by Pylint.

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

Line: 243 Column: 22

                  pad = Series([0], index=[3])
    expected = normal_result.append(pad)
    expected = expected.sort_index()
    expected.index = date_range(
        start="2013-01-01", freq="D", periods=5, name="key"
    )._with_freq(None)
    tm.assert_series_equal(expected, dt_result)
    assert dt_result.index.name == "key"


            

Reported by Pylint.

Access to a protected member _get_grouper of a client class
Error

Line: 67 Column: 21

                  df = DataFrame({"open": 1, "close": 2}, index=ind)
    tg = Grouper(freq="M")

    _, grouper, _ = tg._get_grouper(df)

    # Errors
    grouped = df.groupby(grouper, group_keys=False)

    def f(df):

            

Reported by Pylint.

String statement has no effect
Error

Line: 150 Column: 5

              
    # if TimeGrouper is used included, 'nth' doesn't work yet

    """
    for func in ['nth']:
        expected = getattr(normal_grouped, func)(3)
        expected.index = date_range(start='2013-01-01',
                                    freq='D', periods=5, name='key')
        dt_result = getattr(dt_grouped, func)(3)

            

Reported by Pylint.

Access to a protected member _with_freq of a client class
Error

Line: 213 Column: 22

                  expected = normal_result.append(pad)
    expected = expected.sort_index()
    dti = date_range(start="2013-01-01", freq="D", periods=5, name="key")
    expected.index = dti._with_freq(None)  # TODO: is this desired?
    tm.assert_frame_equal(expected, dt_result)
    assert dt_result.index.name == "key"


def test_aggregate_with_nat_size():

            

Reported by Pylint.

TODO: is this desired?
Error

Line: 213 Column: 3

                  expected = normal_result.append(pad)
    expected = expected.sort_index()
    dti = date_range(start="2013-01-01", freq="D", periods=5, name="key")
    expected.index = dti._with_freq(None)  # TODO: is this desired?
    tm.assert_frame_equal(expected, dt_result)
    assert dt_result.index.name == "key"


def test_aggregate_with_nat_size():

            

Reported by Pylint.

Access to a protected member _with_freq of a client class
Error

Line: 243 Column: 22

                  pad = Series([0], index=[3])
    expected = normal_result.append(pad)
    expected = expected.sort_index()
    expected.index = date_range(
        start="2013-01-01", freq="D", periods=5, name="key"
    )._with_freq(None)
    tm.assert_series_equal(expected, dt_result)
    assert dt_result.index.name == "key"


            

Reported by Pylint.

pandas/core/internals/construction.py
44 issues
No name 'lib' in module 'pandas._libs'
Error

Line: 20 Column: 1

              import numpy as np
import numpy.ma as ma

from pandas._libs import lib
from pandas._typing import (
    ArrayLike,
    DtypeObj,
    Manager,
)

            

Reported by Pylint.

TODO: See if we can avoid these copies
Error

Line: 460 Column: 3

                      columns = Index(keys)
        arrays = [com.maybe_iterable_to_list(data[k]) for k in keys]
        # GH#24096 need copy to be deep for datetime64tz case
        # TODO: See if we can avoid these copies
        arrays = [arr if not isinstance(arr, Index) else arr._data for arr in arrays]
        arrays = [
            arr if not is_datetime64tz_dtype(arr) else arr.copy() for arr in arrays
        ]


            

Reported by Pylint.

Access to a protected member _data of a client class
Error

Line: 461 Column: 58

                      arrays = [com.maybe_iterable_to_list(data[k]) for k in keys]
        # GH#24096 need copy to be deep for datetime64tz case
        # TODO: See if we can avoid these copies
        arrays = [arr if not isinstance(arr, Index) else arr._data for arr in arrays]
        arrays = [
            arr if not is_datetime64tz_dtype(arr) else arr.copy() for arr in arrays
        ]

    if copy:

            

Reported by Pylint.

TODO: can we get rid of the dt64tz special case above?
Error

Line: 475 Column: 3

                          else x.copy()
            for x in arrays
        ]
        # TODO: can we get rid of the dt64tz special case above?

    return arrays_to_mgr(arrays, columns, index, dtype=dtype, typ=typ, consolidate=copy)


def nested_data_to_arrays(

            

Reported by Pylint.

Access to a protected member _ndarray of a client class
Error

Line: 530 Column: 18

                  ):
        # On older numpy, np.asarray below apparently does not call __array__,
        #  so nanoseconds get dropped.
        values = values._ndarray

    if not isinstance(values, (np.ndarray, ABCSeries, Index)):
        if len(values) == 0:
            return np.empty((0, 0), dtype=object)
        elif isinstance(values, range):

            

Reported by Pylint.

Access to a protected member _values of a client class
Error

Line: 584 Column: 19

                              # are putting it into an ndarray later
                val = val.reindex(index, copy=False)

            val = val._values
        else:
            if isinstance(val, dict):
                # GH#41785 this _should_ be equivalent to (but faster than)
                #  val = create_series_with_explicit_dtype(val, index=index)._values
                if oindex is None:

            

Reported by Pylint.

Access to a protected member _values of a client class
Error

Line: 598 Column: 46

                              else:
                    # see test_constructor_subclass_dict
                    val = dict(val)
                val = lib.fast_multiget(val, oindex._values, default=np.nan)

            val = sanitize_array(
                val, index, dtype=dtype, copy=False, raise_cast_failure=False
            )
            com.require_length_match(val, index)

            

Reported by Pylint.

Access to a protected member _ixs of a client class
Error

Line: 794 Column: 17

                      # see test_from_records_with_index_data, test_from_records_bad_index_column
        if columns is not None:
            arrays = [
                data._ixs(i, axis=1).values
                for i, col in enumerate(data.columns)
                if col in columns
            ]
        else:
            columns = data.columns

            

Reported by Pylint.

Access to a protected member _ixs of a client class
Error

Line: 800 Column: 23

                          ]
        else:
            columns = data.columns
            arrays = [data._ixs(i, axis=1).values for i in range(len(columns))]

        return arrays, columns

    if not len(data):
        if isinstance(data, np.ndarray):

            

Reported by Pylint.

TODO: is that an issue with numpy?
Error

Line: 813 Column: 3

              
                if len(data) == 0:
                    # GH#42456 the indexing above results in list of 2D ndarrays
                    # TODO: is that an issue with numpy?
                    for i, arr in enumerate(arrays):
                        if arr.ndim == 2:
                            arrays[i] = arr[:, 0]

                return arrays, columns

            

Reported by Pylint.

pandas/conftest.py
44 issues
Unable to import 'hypothesis'
Error

Line: 37 Column: 1

                  tzlocal,
    tzutc,
)
import hypothesis
from hypothesis import strategies as st
import numpy as np
import pytest
from pytz import (
    FixedOffset,

            

Reported by Pylint.

Unable to import 'hypothesis'
Error

Line: 38 Column: 1

                  tzutc,
)
import hypothesis
from hypothesis import strategies as st
import numpy as np
import pytest
from pytz import (
    FixedOffset,
    utc,

            

Reported by Pylint.

Unable to import 'pytest'
Error

Line: 40 Column: 1

              import hypothesis
from hypothesis import strategies as st
import numpy as np
import pytest
from pytz import (
    FixedOffset,
    utc,
)


            

Reported by Pylint.

Unable to import 'pytz'
Error

Line: 41 Column: 1

              from hypothesis import strategies as st
import numpy as np
import pytest
from pytz import (
    FixedOffset,
    utc,
)

import pandas.util._test_decorators as td

            

Reported by Pylint.

Undefined variable 'key'
Error

Line: 505 Column: 68

              
@pytest.fixture(
    params=[
        key for key in indices_dict if not isinstance(indices_dict[key], MultiIndex)
    ]
)
def index_flat(request):
    """
    index fixture, but excluding MultiIndex cases.

            

Reported by Pylint.

Unable to import 'IPython.core.interactiveshell'
Error

Line: 1552 Column: 5

                  Will raise a skip if IPython is not installed.
    """
    pytest.importorskip("IPython", minversion="6.0.0")
    from IPython.core.interactiveshell import InteractiveShell

    # GH#35711 make sure sqlite history file handle is not leaked
    from traitlets.config import Config  # isort:skip

    c = Config()

            

Reported by Pylint.

Unable to import 'traitlets.config'
Error

Line: 1555 Column: 5

                  from IPython.core.interactiveshell import InteractiveShell

    # GH#35711 make sure sqlite history file handle is not leaked
    from traitlets.config import Config  # isort:skip

    c = Config()
    c.HistoryManager.hist_file = ":memory:"

    return InteractiveShell(config=c)

            

Reported by Pylint.

Unable to import 'scipy'
Error

Line: 1568 Column: 5

                  """
    Yields scipy sparse matrix classes.
    """
    from scipy import sparse

    return getattr(sparse, request.param + "_matrix")


@pytest.fixture(

            

Reported by Pylint.

Unable to import 'fsspec'
Error

Line: 1599 Column: 5

              @pytest.fixture()
def fsspectest():
    pytest.importorskip("fsspec")
    from fsspec import register_implementation
    from fsspec.implementations.memory import MemoryFileSystem
    from fsspec.registry import _registry as registry

    class TestMemoryFS(MemoryFileSystem):
        protocol = "testmem"

            

Reported by Pylint.

Unable to import 'fsspec.implementations.memory'
Error

Line: 1600 Column: 5

              def fsspectest():
    pytest.importorskip("fsspec")
    from fsspec import register_implementation
    from fsspec.implementations.memory import MemoryFileSystem
    from fsspec.registry import _registry as registry

    class TestMemoryFS(MemoryFileSystem):
        protocol = "testmem"
        test = [None]

            

Reported by Pylint.