The following issues were found

scripts/tests/test_validate_docstrings.py
57 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              import io
import textwrap

import pytest

from .. import validate_docstrings


class BadDocstrings:

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 6 Column: 1

              
import pytest

from .. import validate_docstrings


class BadDocstrings:
    """Everything here has a bad docstring"""


            

Reported by Pylint.

Unnecessary pass statement
Error

Line: 26 Column: 9

                      pandas.Series.rename : Alter Series index labels or name.
        DataFrame.head : The first `n` rows of the caller object.
        """
        pass

    def redundant_import(self, foo=None, bar=None):
        """
        A sample DataFrame method.


            

Reported by Pylint.

Unnecessary pass statement
Error

Line: 48 Column: 9

                      >>> df.all(bool_only=True)
        Series([], dtype: bool)
        """
        pass

    def unused_import(self):
        """
        Examples
        --------

            

Reported by Pylint.

Unnecessary pass statement
Error

Line: 57 Column: 9

                      >>> import pandas as pdf
        >>> df = pd.DataFrame(np.ones((3, 3)), columns=('a', 'b', 'c'))
        """
        pass

    def missing_whitespace_around_arithmetic_operator(self):
        """
        Examples
        --------

            

Reported by Pylint.

Unnecessary pass statement
Error

Line: 66 Column: 9

                      >>> 2+5
        7
        """
        pass

    def indentation_is_not_a_multiple_of_four(self):
        """
        Examples
        --------

            

Reported by Pylint.

Unnecessary pass statement
Error

Line: 75 Column: 9

                      >>> if 2 + 5:
        ...   pass
        """
        pass

    def missing_whitespace_after_comma(self):
        """
        Examples
        --------

            

Reported by Pylint.

Unnecessary pass statement
Error

Line: 83 Column: 9

                      --------
        >>> df = pd.DataFrame(np.ones((3,3)),columns=('a','b', 'c'))
        """
        pass

    def write_array_like_with_hyphen_not_underscore(self):
        """
        In docstrings, use array-like over array_like
        """

            

Reported by Pylint.

Unnecessary pass statement
Error

Line: 89 Column: 9

                      """
        In docstrings, use array-like over array_like
        """
        pass


class TestValidator:
    def _import_path(self, klass=None, func=None):
        """

            

Reported by Pylint.

Unused argument 'capsys'
Error

Line: 119 Column: 30

              
        return base_path

    def test_bad_class(self, capsys):
        errors = validate_docstrings.pandas_validate(
            self._import_path(klass="BadDocstrings")
        )["errors"]
        assert isinstance(errors, list)
        assert errors

            

Reported by Pylint.

pandas/tests/window/test_api.py
57 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

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

            

Reported by Pylint.

Access to a protected member _selected_obj of a client class
Error

Line: 22 Column: 27

              def test_getitem():
    frame = DataFrame(np.random.randn(5, 5))
    r = frame.rolling(window=5)
    tm.assert_index_equal(r._selected_obj.columns, frame.columns)

    r = frame.rolling(window=5)[1]
    assert r._selected_obj.name == frame.columns[1]

    # technically this is allowed

            

Reported by Pylint.

Access to a protected member _selected_obj of a client class
Error

Line: 25 Column: 12

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

    r = frame.rolling(window=5)[1]
    assert r._selected_obj.name == frame.columns[1]

    # technically this is allowed
    r = frame.rolling(window=5)[1, 3]
    tm.assert_index_equal(r._selected_obj.columns, frame.columns[[1, 3]])


            

Reported by Pylint.

Access to a protected member _selected_obj of a client class
Error

Line: 29 Column: 27

              
    # technically this is allowed
    r = frame.rolling(window=5)[1, 3]
    tm.assert_index_equal(r._selected_obj.columns, frame.columns[[1, 3]])

    r = frame.rolling(window=5)[[1, 3]]
    tm.assert_index_equal(r._selected_obj.columns, frame.columns[[1, 3]])



            

Reported by Pylint.

Access to a protected member _selected_obj of a client class
Error

Line: 32 Column: 27

                  tm.assert_index_equal(r._selected_obj.columns, frame.columns[[1, 3]])

    r = frame.rolling(window=5)[[1, 3]]
    tm.assert_index_equal(r._selected_obj.columns, frame.columns[[1, 3]])


def test_select_bad_cols():
    df = DataFrame([[1, 2]], columns=["A", "B"])
    g = df.rolling(window=5)

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 39 Column: 9

                  df = DataFrame([[1, 2]], columns=["A", "B"])
    g = df.rolling(window=5)
    with pytest.raises(KeyError, match="Columns not found: 'C'"):
        g[["C"]]
    with pytest.raises(KeyError, match="^[^A]+$"):
        # A should not be referenced as a bad column...
        # will have to rethink regex if you change message!
        g[["A", "C"]]


            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 43 Column: 9

                  with pytest.raises(KeyError, match="^[^A]+$"):
        # A should not be referenced as a bad column...
        # will have to rethink regex if you change message!
        g[["A", "C"]]


def test_attribute_access():

    df = DataFrame([[1, 2]], columns=["A", "B"])

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 53 Column: 9

                  tm.assert_series_equal(r.A.sum(), r["A"].sum())
    msg = "'Rolling' object has no attribute 'F'"
    with pytest.raises(AttributeError, match=msg):
        r.F


def tests_skip_nuisance():

    df = DataFrame({"A": range(5), "B": range(5, 10), "C": "foo"})

            

Reported by Pylint.

Access to a protected member _attributes of a client class
Error

Line: 342 Column: 59

                  roll_obj = Series(range(1)).rolling(
        1, center=center, closed=closed, min_periods=min_periods
    )
    expected = {attr: getattr(roll_obj, attr) for attr in roll_obj._attributes}
    getattr(roll_obj, arithmetic_win_operators)()
    result = {attr: getattr(roll_obj, attr) for attr in roll_obj._attributes}
    assert result == expected

            

Reported by Pylint.

Access to a protected member _attributes of a client class
Error

Line: 344 Column: 57

                  )
    expected = {attr: getattr(roll_obj, attr) for attr in roll_obj._attributes}
    getattr(roll_obj, arithmetic_win_operators)()
    result = {attr: getattr(roll_obj, attr) for attr in roll_obj._attributes}
    assert result == expected

            

Reported by Pylint.

pandas/tests/io/formats/test_to_string.py
57 issues
Unable to import 'pytest'
Error

Line: 6 Column: 1

              from textwrap import dedent

import numpy as np
import pytest

from pandas import (
    DataFrame,
    Series,
    option_context,

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from datetime import datetime
from io import StringIO
from textwrap import dedent

import numpy as np
import pytest

from pandas import (
    DataFrame,

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 16 Column: 1

              )


def test_repr_embedded_ndarray():
    arr = np.empty(10, dtype=[("err", object)])
    for i in range(len(arr)):
        arr["err"][i] = np.random.randn(i)

    df = DataFrame(arr)

            

Reported by Pylint.

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

Line: 21 Column: 5

                  for i in range(len(arr)):
        arr["err"][i] = np.random.randn(i)

    df = DataFrame(arr)
    repr(df["err"])
    repr(df)
    df.to_string()



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 27 Column: 1

                  df.to_string()


def test_repr_tuples():
    buf = StringIO()

    df = DataFrame({"tups": list(zip(range(10), range(10)))})
    repr(df)
    df.to_string(col_space=10, buf=buf)

            

Reported by Pylint.

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

Line: 30 Column: 5

              def test_repr_tuples():
    buf = StringIO()

    df = DataFrame({"tups": list(zip(range(10), range(10)))})
    repr(df)
    df.to_string(col_space=10, buf=buf)


def test_to_string_truncate():

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 35 Column: 1

                  df.to_string(col_space=10, buf=buf)


def test_to_string_truncate():
    # GH 9784 - dont truncate when calling DataFrame.to_string
    df = DataFrame(
        [
            {
                "a": "foo",

            

Reported by Pylint.

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

Line: 37 Column: 5

              
def test_to_string_truncate():
    # GH 9784 - dont truncate when calling DataFrame.to_string
    df = DataFrame(
        [
            {
                "a": "foo",
                "b": "bar",
                "c": "let's make this a very VERY long line that is longer "

            

Reported by Pylint.

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

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

                      ]
    )
    df.set_index(["a", "b", "c"])
    assert df.to_string() == (
        "     a    b                                         "
        "                                                c  d\n"
        "0  foo  bar  let's make this a very VERY long line t"
        "hat is longer than the default 50 character limit  1\n"
        "1  foo  bar                                         "

            

Reported by Bandit.

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

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

                  )
    with option_context("max_colwidth", 20):
        # the display option has no effect on the to_string method
        assert df.to_string() == (
            "     a    b                                         "
            "                                                c  d\n"
            "0  foo  bar  let's make this a very VERY long line t"
            "hat is longer than the default 50 character limit  1\n"
            "1  foo  bar                                         "

            

Reported by Bandit.

pandas/io/formats/xml.py
57 issues
No name 'etree' in module 'xml'
Error

Line: 299 Column: 9

                      self.prefix_uri = self.get_prefix_uri()

    def build_tree(self) -> bytes:
        from xml.etree.ElementTree import (
            Element,
            SubElement,
            tostring,
        )


            

Reported by Pylint.

No name 'etree' in module 'xml'
Error

Line: 339 Column: 9

                      return self.out_xml

    def get_prefix_uri(self) -> str:
        from xml.etree.ElementTree import register_namespace

        uri = ""
        if self.namespaces:
            for p, n in self.namespaces.items():
                if isinstance(p, str) and isinstance(n, str):

            

Reported by Pylint.

No name 'etree' in module 'xml'
Error

Line: 382 Column: 9

                              raise KeyError(f"no valid column, {col}")

    def build_elems(self) -> None:
        from xml.etree.ElementTree import SubElement

        if not self.elem_cols:
            return

        for col in self.elem_cols:

            

Reported by Pylint.

No name 'dom' in module 'xml'
Error

Line: 414 Column: 9

                      This method will pretty print xml with line breaks and indentation.
        """

        from xml.dom.minidom import parseString

        dom = parseString(self.out_xml)

        return dom.toprettyxml(indent="  ", encoding=self.encoding)


            

Reported by Pylint.

Unable to import 'lxml.etree'
Error

Line: 471 Column: 9

                      This method initializes the root and builds attributes and elements
        with optional namespaces.
        """
        from lxml.etree import (
            Element,
            SubElement,
            tostring,
        )


            

Reported by Pylint.

Unable to import 'lxml.etree'
Error

Line: 554 Column: 9

                              raise KeyError(f"no valid column, {col}")

    def build_elems(self) -> None:
        from lxml.etree import SubElement

        if not self.elem_cols:
            return

        for col in self.elem_cols:

            

Reported by Pylint.

Unable to import 'lxml.etree'
Error

Line: 588 Column: 9

                      original tree with XSLT script.
        """

        from lxml.etree import (
            XSLT,
            XMLParser,
            fromstring,
            parse,
        )

            

Reported by Pylint.

Unused variable 'out_str'
Error

Line: 267 Column: 9

                  def write_output(self) -> str | None:
        xml_doc = self.build_tree()

        out_str: str | None

        if self.path_or_buffer is not None:
            with get_handle(
                self.path_or_buffer,
                "wb",

            

Reported by Pylint.

Attribute 'root' defined outside __init__
Error

Line: 305 Column: 9

                          tostring,
        )

        self.root = Element(
            f"{self.prefix_uri}{self.root_name}", attrib=self.other_namespaces()
        )

        for d in self.frame_dicts.values():
            self.d = d

            

Reported by Pylint.

Attribute 'd' defined outside __init__
Error

Line: 310 Column: 13

                      )

        for d in self.frame_dicts.values():
            self.d = d
            self.elem_row = SubElement(self.root, f"{self.prefix_uri}{self.row_name}")

            if not self.attr_cols and not self.elem_cols:
                self.elem_cols = list(self.d.keys())
                self.build_elems()

            

Reported by Pylint.

pandas/tests/frame/methods/test_transpose.py
56 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

import pandas.util._test_decorators as td

from pandas import (
    DataFrame,
    date_range,
)

            

Reported by Pylint.

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

Line: 35 Column: 16

                  def test_transpose_tzaware_2col_mixed_tz(self):
        # GH#26825
        dti = date_range("2016-04-05 04:30", periods=3, tz="UTC")
        dti2 = dti.tz_convert("US/Pacific")

        df4 = DataFrame({"A": dti, "B": dti2})
        assert (df4.dtypes == [dti.dtype, dti2.dtype]).all()
        assert (df4.T.dtypes == object).all()
        tm.assert_frame_equal(df4.T.T, df4)

            

Reported by Pylint.

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

Line: 35 Column: 16

                  def test_transpose_tzaware_2col_mixed_tz(self):
        # GH#26825
        dti = date_range("2016-04-05 04:30", periods=3, tz="UTC")
        dti2 = dti.tz_convert("US/Pacific")

        df4 = DataFrame({"A": dti, "B": dti2})
        assert (df4.dtypes == [dti.dtype, dti2.dtype]).all()
        assert (df4.T.dtypes == object).all()
        tm.assert_frame_equal(df4.T.T, df4)

            

Reported by Pylint.

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

Line: 54 Column: 16

                  def test_transpose_object_to_tzaware_mixed_tz(self):
        # GH#26825
        dti = date_range("2016-04-05 04:30", periods=3, tz="UTC")
        dti2 = dti.tz_convert("US/Pacific")

        # mixed all-tzaware dtypes
        df2 = DataFrame([dti, dti2])
        assert (df2.dtypes == object).all()
        res2 = df2.T

            

Reported by Pylint.

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

Line: 54 Column: 16

                  def test_transpose_object_to_tzaware_mixed_tz(self):
        # GH#26825
        dti = date_range("2016-04-05 04:30", periods=3, tz="UTC")
        dti2 = dti.tz_convert("US/Pacific")

        # mixed all-tzaware dtypes
        df2 = DataFrame([dti, dti2])
        assert (df2.dtypes == object).all()
        res2 = df2.T

            

Reported by Pylint.

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

Line: 19 Column: 17

                      dti = date_range("2016-04-05 04:30", periods=3, tz="UTC")

        df = DataFrame(dti)
        assert (df.dtypes == dti.dtype).all()
        res = df.T
        assert (res.dtypes == dti.dtype).all()

    def test_transpose_tzaware_2col_single_tz(self):
        # GH#26825

            

Reported by Pylint.

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

Line: 21 Column: 17

                      df = DataFrame(dti)
        assert (df.dtypes == dti.dtype).all()
        res = df.T
        assert (res.dtypes == dti.dtype).all()

    def test_transpose_tzaware_2col_single_tz(self):
        # GH#26825
        dti = date_range("2016-04-05 04:30", periods=3, tz="UTC")


            

Reported by Pylint.

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

Line: 28 Column: 17

                      dti = date_range("2016-04-05 04:30", periods=3, tz="UTC")

        df3 = DataFrame({"A": dti, "B": dti})
        assert (df3.dtypes == dti.dtype).all()
        res3 = df3.T
        assert (res3.dtypes == dti.dtype).all()

    def test_transpose_tzaware_2col_mixed_tz(self):
        # GH#26825

            

Reported by Pylint.

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

Line: 30 Column: 17

                      df3 = DataFrame({"A": dti, "B": dti})
        assert (df3.dtypes == dti.dtype).all()
        res3 = df3.T
        assert (res3.dtypes == dti.dtype).all()

    def test_transpose_tzaware_2col_mixed_tz(self):
        # GH#26825
        dti = date_range("2016-04-05 04:30", periods=3, tz="UTC")
        dti2 = dti.tz_convert("US/Pacific")

            

Reported by Pylint.

Access to a protected member _data of a client class
Error

Line: 97 Column: 15

                  @td.skip_array_manager_invalid_test
    def test_transpose_get_view_dt64tzget_view(self):
        dti = date_range("2016-01-01", periods=6, tz="US/Pacific")
        arr = dti._data.reshape(3, 2)
        df = DataFrame(arr)
        assert df._mgr.nblocks == 1

        result = df.T
        assert result._mgr.nblocks == 1

            

Reported by Pylint.

pandas/tests/arrays/test_numpy.py
56 issues
Unable to import 'pytest'
Error

Line: 6 Column: 1

              the interface tests.
"""
import numpy as np
import pytest

from pandas.core.dtypes.dtypes import PandasDtype

import pandas as pd
import pandas._testing as tm

            

Reported by Pylint.

Access to a protected member _is_numeric of a client class
Error

Line: 56 Column: 12

              )
def test_is_numeric(dtype, expected):
    dtype = PandasDtype(dtype)
    assert dtype._is_numeric is expected


@pytest.mark.parametrize(
    "dtype, expected",
    [

            

Reported by Pylint.

Access to a protected member _is_boolean of a client class
Error

Line: 76 Column: 12

              )
def test_is_boolean(dtype, expected):
    dtype = PandasDtype(dtype)
    assert dtype._is_boolean is expected


def test_repr():
    dtype = PandasDtype(np.dtype("int64"))
    assert repr(dtype) == "PandasDtype('int64')"

            

Reported by Pylint.

Access to a protected member _from_sequence of a client class
Error

Line: 122 Column: 14

              
def test_from_sequence_dtype():
    arr = np.array([1, 2, 3], dtype="int64")
    result = PandasArray._from_sequence(arr, dtype="uint64")
    expected = PandasArray(np.array([1, 2, 3], dtype="uint64"))
    tm.assert_extension_array_equal(result, expected)


def test_constructor_copy():

            

Reported by Pylint.

Access to a protected member _ndarray of a client class
Error

Line: 131 Column: 29

                  arr = np.array([0, 1])
    result = PandasArray(arr, copy=True)

    assert np.shares_memory(result._ndarray, arr) is False


def test_constructor_with_data(any_numpy_array):
    nparr = any_numpy_array
    arr = PandasArray(nparr)

            

Reported by Pylint.

Redefining name 'any_numpy_array' from outer scope (line 24)
Error

Line: 134 Column: 32

                  assert np.shares_memory(result._ndarray, arr) is False


def test_constructor_with_data(any_numpy_array):
    nparr = any_numpy_array
    arr = PandasArray(nparr)
    assert arr.dtype.numpy_dtype == nparr.dtype



            

Reported by Pylint.

Access to a protected member _ndarray of a client class
Error

Line: 147 Column: 22

              def test_to_numpy():
    arr = PandasArray(np.array([1, 2, 3]))
    result = arr.to_numpy()
    assert result is arr._ndarray

    result = arr.to_numpy(copy=True)
    assert result is not arr._ndarray

    result = arr.to_numpy(dtype="f8")

            

Reported by Pylint.

Access to a protected member _ndarray of a client class
Error

Line: 150 Column: 26

                  assert result is arr._ndarray

    result = arr.to_numpy(copy=True)
    assert result is not arr._ndarray

    result = arr.to_numpy(dtype="f8")
    expected = np.array([1, 2, 3], dtype="f8")
    tm.assert_numpy_array_equal(result, expected)


            

Reported by Pylint.

Redefining name 'any_numpy_array' from outer scope (line 24)
Error

Line: 168 Column: 18

                  tm.assert_series_equal(ser, expected)


def test_setitem(any_numpy_array):
    nparr = any_numpy_array
    arr = PandasArray(nparr, copy=True)

    arr[0] = arr[1]
    nparr[0] = nparr[1]

            

Reported by Pylint.

Access to a protected member _reduce of a client class
Error

Line: 187 Column: 9

                  arr = PandasArray(arr)
    msg = "cannot perform not_a_method with type int"
    with pytest.raises(TypeError, match=msg):
        arr._reduce(msg)


def test_validate_reduction_keyword_args():
    arr = PandasArray(np.array([1, 2, 3]))
    msg = "the 'keepdims' parameter is not supported .*all"

            

Reported by Pylint.

pandas/tests/arrays/integer/test_construction.py
56 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

import pandas as pd
import pandas._testing as tm
from pandas.api.types import is_integer
from pandas.core.arrays import IntegerArray
from pandas.core.arrays.integer import (
    Int8Dtype,

            

Reported by Pylint.

No value for argument 'mask' in constructor call
Error

Line: 91 Column: 9

                      IntegerArray(values.astype(float), mask)
    msg = r"__init__\(\) missing 1 required positional argument: 'mask'"
    with pytest.raises(TypeError, match=msg):
        IntegerArray(values)


def test_integer_array_constructor_copy():
    values = np.array([1, 2, 3, 4], dtype="int64")
    mask = np.array([False, False, False, True], dtype="bool")

            

Reported by Pylint.

Access to a protected member _from_sequence of a client class
Error

Line: 15 Column: 35

              )


@pytest.fixture(params=[pd.array, IntegerArray._from_sequence])
def constructor(request):
    return request.param


def test_uses_pandas_na():

            

Reported by Pylint.

Access to a protected member _data of a client class
Error

Line: 99 Column: 12

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

    result = IntegerArray(values, mask)
    assert result._data is values
    assert result._mask is mask

    result = IntegerArray(values, mask, copy=True)
    assert result._data is not values
    assert result._mask is not mask

            

Reported by Pylint.

Access to a protected member _mask of a client class
Error

Line: 100 Column: 12

              
    result = IntegerArray(values, mask)
    assert result._data is values
    assert result._mask is mask

    result = IntegerArray(values, mask, copy=True)
    assert result._data is not values
    assert result._mask is not mask


            

Reported by Pylint.

Access to a protected member _data of a client class
Error

Line: 103 Column: 12

                  assert result._mask is mask

    result = IntegerArray(values, mask, copy=True)
    assert result._data is not values
    assert result._mask is not mask


@pytest.mark.parametrize(
    "a, b",

            

Reported by Pylint.

Access to a protected member _mask of a client class
Error

Line: 104 Column: 12

              
    result = IntegerArray(values, mask, copy=True)
    assert result._data is not values
    assert result._mask is not mask


@pytest.mark.parametrize(
    "a, b",
    [

            

Reported by Pylint.

Access to a protected member _from_sequence of a client class
Error

Line: 147 Column: 9

                      pd.array(values, dtype="Int64")

    with pytest.raises(TypeError, match=msg):
        IntegerArray._from_sequence(values)


def test_to_integer_array_inferred_dtype(constructor):
    # if values has dtype -> respect it
    result = constructor(np.array([1, 2], dtype="int8"))

            

Reported by Pylint.

Redefining name 'constructor' from outer scope (line 16)
Error

Line: 150 Column: 42

                      IntegerArray._from_sequence(values)


def test_to_integer_array_inferred_dtype(constructor):
    # if values has dtype -> respect it
    result = constructor(np.array([1, 2], dtype="int8"))
    assert result.dtype == Int8Dtype()
    result = constructor(np.array([1, 2], dtype="int32"))
    assert result.dtype == Int32Dtype()

            

Reported by Pylint.

Redefining name 'constructor' from outer scope (line 16)
Error

Line: 162 Column: 41

                  assert result.dtype == Int64Dtype()


def test_to_integer_array_dtype_keyword(constructor):
    result = constructor([1, 2], dtype="Int8")
    assert result.dtype == Int8Dtype()

    # if values has dtype -> override it
    result = constructor(np.array([1, 2], dtype="int8"), dtype="Int32")

            

Reported by Pylint.

pandas/tseries/frequencies.py
56 issues
Unable to import 'pandas._libs.algos'
Error

Line: 7 Column: 1

              
import numpy as np

from pandas._libs.algos import unique_deltas
from pandas._libs.tslibs import (
    Timestamp,
    tzconversion,
)
from pandas._libs.tslibs.ccalendar import (

            

Reported by Pylint.

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

Line: 7 Column: 1

              
import numpy as np

from pandas._libs.algos import unique_deltas
from pandas._libs.tslibs import (
    Timestamp,
    tzconversion,
)
from pandas._libs.tslibs.ccalendar import (

            

Reported by Pylint.

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

Line: 8 Column: 1

              import numpy as np

from pandas._libs.algos import unique_deltas
from pandas._libs.tslibs import (
    Timestamp,
    tzconversion,
)
from pandas._libs.tslibs.ccalendar import (
    DAYS,

            

Reported by Pylint.

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

Line: 12 Column: 1

                  Timestamp,
    tzconversion,
)
from pandas._libs.tslibs.ccalendar import (
    DAYS,
    MONTH_ALIASES,
    MONTH_NUMBERS,
    MONTHS,
    int_to_weekday,

            

Reported by Pylint.

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

Line: 12 Column: 1

                  Timestamp,
    tzconversion,
)
from pandas._libs.tslibs.ccalendar import (
    DAYS,
    MONTH_ALIASES,
    MONTH_NUMBERS,
    MONTHS,
    int_to_weekday,

            

Reported by Pylint.

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

Line: 19 Column: 1

                  MONTHS,
    int_to_weekday,
)
from pandas._libs.tslibs.fields import (
    build_field_sarray,
    month_position_check,
)
from pandas._libs.tslibs.offsets import (  # noqa:F401
    DateOffset,

            

Reported by Pylint.

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

Line: 19 Column: 1

                  MONTHS,
    int_to_weekday,
)
from pandas._libs.tslibs.fields import (
    build_field_sarray,
    month_position_check,
)
from pandas._libs.tslibs.offsets import (  # noqa:F401
    DateOffset,

            

Reported by Pylint.

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

Line: 23 Column: 1

                  build_field_sarray,
    month_position_check,
)
from pandas._libs.tslibs.offsets import (  # noqa:F401
    DateOffset,
    Day,
    _get_offset,
    to_offset,
)

            

Reported by Pylint.

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

Line: 23 Column: 1

                  build_field_sarray,
    month_position_check,
)
from pandas._libs.tslibs.offsets import (  # noqa:F401
    DateOffset,
    Day,
    _get_offset,
    to_offset,
)

            

Reported by Pylint.

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

Line: 29 Column: 1

                  _get_offset,
    to_offset,
)
from pandas._libs.tslibs.parsing import get_rule_month
from pandas.util._decorators import cache_readonly

from pandas.core.dtypes.common import (
    is_datetime64_dtype,
    is_period_dtype,

            

Reported by Pylint.

pandas/tests/series/methods/test_drop_duplicates.py
56 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

from pandas import (
    Categorical,
    Series,
)
import pandas._testing as tm


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

from pandas import (
    Categorical,
    Series,
)
import pandas._testing as tm


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 1

                      ("first", Series([False, False, False, False, True, True, False])),
        ("last", Series([False, True, True, False, False, False, False])),
        (False, Series([False, True, True, False, True, True, False])),
    ],
)
def test_drop_duplicates(any_numpy_dtype, keep, expected):
    tc = Series([1, 0, 3, 5, 3, 0, 4], dtype=np.dtype(any_numpy_dtype))

    if tc.dtype == "bool":

            

Reported by Pylint.

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

Line: 20 Column: 5

                  ],
)
def test_drop_duplicates(any_numpy_dtype, keep, expected):
    tc = Series([1, 0, 3, 5, 3, 0, 4], dtype=np.dtype(any_numpy_dtype))

    if tc.dtype == "bool":
        pytest.skip("tested separately in test_drop_duplicates_bool")

    tm.assert_series_equal(tc.duplicated(keep=keep), expected)

            

Reported by Pylint.

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

Line: 27 Column: 5

              
    tm.assert_series_equal(tc.duplicated(keep=keep), expected)
    tm.assert_series_equal(tc.drop_duplicates(keep=keep), tc[~expected])
    sc = tc.copy()
    return_value = sc.drop_duplicates(keep=keep, inplace=True)
    assert return_value is None
    tm.assert_series_equal(sc, tc[~expected])



            

Reported by Pylint.

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

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

                  tm.assert_series_equal(tc.drop_duplicates(keep=keep), tc[~expected])
    sc = tc.copy()
    return_value = sc.drop_duplicates(keep=keep, inplace=True)
    assert return_value is None
    tm.assert_series_equal(sc, tc[~expected])


@pytest.mark.parametrize(
    "keep, expected",

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 39 Column: 1

                      ("first", Series([False, False, True, True])),
        ("last", Series([True, True, False, False])),
        (False, Series([True, True, True, True])),
    ],
)
def test_drop_duplicates_bool(keep, expected):
    tc = Series([True, False, True, False])

    tm.assert_series_equal(tc.duplicated(keep=keep), expected)

            

Reported by Pylint.

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

Line: 42 Column: 5

                  ],
)
def test_drop_duplicates_bool(keep, expected):
    tc = Series([True, False, True, False])

    tm.assert_series_equal(tc.duplicated(keep=keep), expected)
    tm.assert_series_equal(tc.drop_duplicates(keep=keep), tc[~expected])
    sc = tc.copy()
    return_value = sc.drop_duplicates(keep=keep, inplace=True)

            

Reported by Pylint.

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

Line: 46 Column: 5

              
    tm.assert_series_equal(tc.duplicated(keep=keep), expected)
    tm.assert_series_equal(tc.drop_duplicates(keep=keep), tc[~expected])
    sc = tc.copy()
    return_value = sc.drop_duplicates(keep=keep, inplace=True)
    tm.assert_series_equal(sc, tc[~expected])
    assert return_value is None



            

Reported by Pylint.

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

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

                  sc = tc.copy()
    return_value = sc.drop_duplicates(keep=keep, inplace=True)
    tm.assert_series_equal(sc, tc[~expected])
    assert return_value is None


@pytest.mark.parametrize("values", [[], list(range(5))])
def test_drop_duplicates_no_duplicates(any_numpy_dtype, keep, values):
    tc = Series(values, dtype=np.dtype(any_numpy_dtype))

            

Reported by Bandit.

pandas/tests/io/pytables/test_timezones.py
55 issues
Unable to import 'pytest'
Error

Line: 7 Column: 1

              )

import numpy as np
import pytest

from pandas._libs.tslibs.timezones import maybe_get_tz
import pandas.util._test_decorators as td

import pandas as pd

            

Reported by Pylint.

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

Line: 9 Column: 1

              import numpy as np
import pytest

from pandas._libs.tslibs.timezones import maybe_get_tz
import pandas.util._test_decorators as td

import pandas as pd
from pandas import (
    DataFrame,

            

Reported by Pylint.

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

Line: 9 Column: 1

              import numpy as np
import pytest

from pandas._libs.tslibs.timezones import maybe_get_tz
import pandas.util._test_decorators as td

import pandas as pd
from pandas import (
    DataFrame,

            

Reported by Pylint.

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

Line: 137 Column: 11

                  # GH#4098 example

    dti = date_range("2000-1-1", periods=3, freq="H", tz=gettz("US/Eastern"))
    dti = dti._with_freq(None)  # freq doesn't round-trip

    df = DataFrame({"A": Series(range(3), index=dti)})

    with ensure_clean_store(setup_path) as store:


            

Reported by Pylint.

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

Line: 137 Column: 11

                  # GH#4098 example

    dti = date_range("2000-1-1", periods=3, freq="H", tz=gettz("US/Eastern"))
    dti = dti._with_freq(None)  # freq doesn't round-trip

    df = DataFrame({"A": Series(range(3), index=dti)})

    with ensure_clean_store(setup_path) as store:


            

Reported by Pylint.

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

Line: 191 Column: 16

                  with ensure_clean_store(setup_path) as store:
        store.append("frame", frame)
        result = store.select_column("frame", "index")
        assert rng.tz == DatetimeIndex(result.values).tz

    # check utc
    rng = date_range("1/1/2000", "1/30/2000", tz="UTC")
    frame = DataFrame(np.random.randn(len(rng), 4), index=rng)


            

Reported by Pylint.

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

Line: 191 Column: 16

                  with ensure_clean_store(setup_path) as store:
        store.append("frame", frame)
        result = store.select_column("frame", "index")
        assert rng.tz == DatetimeIndex(result.values).tz

    # check utc
    rng = date_range("1/1/2000", "1/30/2000", tz="UTC")
    frame = DataFrame(np.random.randn(len(rng), 4), index=rng)


            

Reported by Pylint.

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

Line: 200 Column: 16

                  with ensure_clean_store(setup_path) as store:
        store.append("frame", frame)
        result = store.select_column("frame", "index")
        assert rng.tz == result.dt.tz

    # double check non-utc
    rng = date_range("1/1/2000", "1/30/2000", tz="US/Eastern")
    frame = DataFrame(np.random.randn(len(rng), 4), index=rng)


            

Reported by Pylint.

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

Line: 200 Column: 16

                  with ensure_clean_store(setup_path) as store:
        store.append("frame", frame)
        result = store.select_column("frame", "index")
        assert rng.tz == result.dt.tz

    # double check non-utc
    rng = date_range("1/1/2000", "1/30/2000", tz="US/Eastern")
    frame = DataFrame(np.random.randn(len(rng), 4), index=rng)


            

Reported by Pylint.

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

Line: 209 Column: 16

                  with ensure_clean_store(setup_path) as store:
        store.append("frame", frame)
        result = store.select_column("frame", "index")
        assert rng.tz == result.dt.tz


def test_timezones_fixed_format_frame_non_empty(setup_path):
    with ensure_clean_store(setup_path) as store:


            

Reported by Pylint.