The following issues were found

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.

pandas/tests/indexes/test_any_index.py
55 issues
Unable to import 'pytest'
Error

Line: 9 Column: 1

              import re

import numpy as np
import pytest

from pandas.core.dtypes.common import is_float_dtype

import pandas._testing as tm


            

Reported by Pylint.

Access to a protected member _is_backward_compat_public_numeric_index of a client class
Error

Line: 54 Column: 8

              def test_map_identity_mapping(index):
    # GH#12766
    result = index.map(lambda x: x)
    if index._is_backward_compat_public_numeric_index:
        if is_float_dtype(index.dtype):
            expected = index.astype(np.float64)
        elif index.dtype == np.uint64:
            expected = index.astype(np.uint64)
        else:

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 147 Column: 13

                          "and integer or boolean arrays are valid indices"
        )
        with pytest.raises(IndexError, match=msg):
            index[item]


class TestRendering:
    def test_str(self, index):
        # test the string repr

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 16 Column: 1

              import pandas._testing as tm


def test_boolean_context_compat(index):
    # GH#7897
    with pytest.raises(ValueError, match="The truth value of a"):
        if index:
            pass


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 26 Column: 1

                      bool(index)


def test_sort(index):
    msg = "cannot sort an Index object in-place, use sort_values instead"
    with pytest.raises(TypeError, match=msg):
        index.sort()



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 32 Column: 1

                      index.sort()


def test_hash_error(index):
    with pytest.raises(TypeError, match=f"unhashable type: '{type(index).__name__}'"):
        hash(index)


def test_copy_dtype_deprecated(index):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 37 Column: 1

                      hash(index)


def test_copy_dtype_deprecated(index):
    # GH#35853
    with tm.assert_produces_warning(FutureWarning):
        index.copy(dtype=object)



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 43 Column: 1

                      index.copy(dtype=object)


def test_mutability(index):
    if not len(index):
        return
    msg = "Index does not support mutable operations"
    with pytest.raises(TypeError, match=msg):
        index[0] = index[0]

            

Reported by Pylint.

Do not use `len(SEQUENCE)` without comparison to determine if a sequence is empty
Error

Line: 44 Column: 8

              

def test_mutability(index):
    if not len(index):
        return
    msg = "Index does not support mutable operations"
    with pytest.raises(TypeError, match=msg):
        index[0] = index[0]


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 51 Column: 1

                      index[0] = index[0]


def test_map_identity_mapping(index):
    # GH#12766
    result = index.map(lambda x: x)
    if index._is_backward_compat_public_numeric_index:
        if is_float_dtype(index.dtype):
            expected = index.astype(np.float64)

            

Reported by Pylint.

pandas/plotting/_core.py
55 issues
Too many lines in module (1850/1000)
Error

Line: 1 Column: 1

              from __future__ import annotations

import importlib
import types
from typing import (
    TYPE_CHECKING,
    Sequence,
)


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from __future__ import annotations

import importlib
import types
from typing import (
    TYPE_CHECKING,
    Sequence,
)


            

Reported by Pylint.

Too many arguments (12/5)
Error

Line: 33 Column: 1

                  from pandas import DataFrame


def hist_series(
    self,
    by=None,
    ax=None,
    grid: bool = True,
    xlabelsize: int | None = None,

            

Reported by Pylint.

Argument name "by" doesn't conform to snake_case naming style
Error

Line: 33 Column: 1

                  from pandas import DataFrame


def hist_series(
    self,
    by=None,
    ax=None,
    grid: bool = True,
    xlabelsize: int | None = None,

            

Reported by Pylint.

Argument name "ax" doesn't conform to snake_case naming style
Error

Line: 33 Column: 1

                  from pandas import DataFrame


def hist_series(
    self,
    by=None,
    ax=None,
    grid: bool = True,
    xlabelsize: int | None = None,

            

Reported by Pylint.

Argument name "ax" doesn't conform to snake_case naming style
Error

Line: 116 Column: 1

                  )


def hist_frame(
    data: DataFrame,
    column: IndexLabel = None,
    by=None,
    grid: bool = True,
    xlabelsize: int | None = None,

            

Reported by Pylint.

Argument name "by" doesn't conform to snake_case naming style
Error

Line: 116 Column: 1

                  )


def hist_frame(
    data: DataFrame,
    column: IndexLabel = None,
    by=None,
    grid: bool = True,
    xlabelsize: int | None = None,

            

Reported by Pylint.

Too many local variables (18/15)
Error

Line: 116 Column: 1

                  )


def hist_frame(
    data: DataFrame,
    column: IndexLabel = None,
    by=None,
    grid: bool = True,
    xlabelsize: int | None = None,

            

Reported by Pylint.

Too many arguments (16/5)
Error

Line: 116 Column: 1

                  )


def hist_frame(
    data: DataFrame,
    column: IndexLabel = None,
    by=None,
    grid: bool = True,
    xlabelsize: int | None = None,

            

Reported by Pylint.

Constant name "_boxplot_doc" doesn't conform to UPPER_CASE naming style
Error

Line: 246 Column: 1

                  )


_boxplot_doc = """
Make a box plot from DataFrame columns.

Make a box-and-whisker plot from DataFrame columns, optionally grouped
by some other columns. A box plot is a method for graphically depicting
groups of numerical data through their quartiles.

            

Reported by Pylint.

pandas/tests/series/indexing/test_get.py
54 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

import pandas as pd
from pandas import Series
import pandas._testing as tm


def test_get():

            

Reported by Pylint.

TODO: better name, possibly split
Error

Line: 161 Column: 3

                  [np.random.randn(10), tm.makeDateIndex(10, name="a").tz_localize(tz="US/Eastern")],
)
def test_get2(arr):
    # TODO: better name, possibly split
    # GH#21260
    ser = Series(arr, index=[2 * i for i in range(len(arr))])
    assert ser.get(4) == ser.iloc[2]

    result = ser.get([4, 6])

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

import pandas as pd
from pandas import Series
import pandas._testing as tm


def test_get():

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 9 Column: 1

              import pandas._testing as tm


def test_get():
    # GH 6383
    s = Series(
        np.array(
            [
                43,

            

Reported by Pylint.

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

Line: 11 Column: 5

              
def test_get():
    # GH 6383
    s = Series(
        np.array(
            [
                43,
                48,
                60,

            

Reported by Pylint.

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

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

              
    result = s.get(25, 0)
    expected = 0
    assert result == expected

    s = Series(
        np.array(
            [
                43,

            

Reported by Bandit.

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

Line: 42 Column: 5

                  expected = 0
    assert result == expected

    s = Series(
        np.array(
            [
                43,
                48,
                60,

            

Reported by Pylint.

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

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

              
    result = s.get(25, 0)
    expected = 43
    assert result == expected

    # GH 7407
    # with a boolean accessor
    df = pd.DataFrame({"i": [0] * 3, "b": [False] * 3})
    vc = df.i.value_counts()

            

Reported by Bandit.

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

Line: 99 Column: 5

              
    # GH 7407
    # with a boolean accessor
    df = pd.DataFrame({"i": [0] * 3, "b": [False] * 3})
    vc = df.i.value_counts()
    result = vc.get(99, default="Missing")
    assert result == "Missing"

    vc = df.b.value_counts()

            

Reported by Pylint.

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

Line: 100 Column: 5

                  # GH 7407
    # with a boolean accessor
    df = pd.DataFrame({"i": [0] * 3, "b": [False] * 3})
    vc = df.i.value_counts()
    result = vc.get(99, default="Missing")
    assert result == "Missing"

    vc = df.b.value_counts()
    result = vc.get(False, default="Missing")

            

Reported by Pylint.

pandas/tests/generic/test_to_xarray.py
54 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 (
    Categorical,
    DataFrame,
    MultiIndex,

            

Reported by Pylint.

Unable to import 'xarray'
Error

Line: 39 Column: 9

                      if len(index) == 0:
            pytest.skip("Test doesn't make sense for empty index")

        from xarray import Dataset

        df.index = index[:3]
        df.index.name = "foo"
        df.columns.name = "bar"
        result = df.to_xarray()

            

Reported by Pylint.

Unable to import 'xarray'
Error

Line: 60 Column: 9

                      tm.assert_frame_equal(result.to_dataframe(), expected)

    def test_to_xarray_empty(self, df):
        from xarray import Dataset

        df.index.name = "foo"
        result = df[0:0].to_xarray()
        assert result.dims["foo"] == 0
        assert isinstance(result, Dataset)

            

Reported by Pylint.

Unable to import 'xarray'
Error

Line: 68 Column: 9

                      assert isinstance(result, Dataset)

    def test_to_xarray_with_multiindex(self, df):
        from xarray import Dataset

        # MultiIndex
        df.index = MultiIndex.from_product([["a"], range(3)], names=["one", "two"])
        result = df.to_xarray()
        assert result.dims["one"] == 1

            

Reported by Pylint.

Unable to import 'xarray'
Error

Line: 93 Column: 9

                      if isinstance(index, MultiIndex):
            pytest.skip("MultiIndex is tested separately")

        from xarray import DataArray

        ser = Series(range(len(index)), index=index, dtype="int64")
        ser.index.name = "foo"
        result = ser.to_xarray()
        repr(result)

            

Reported by Pylint.

Unable to import 'xarray'
Error

Line: 108 Column: 9

                      tm.assert_series_equal(result.to_series(), ser)

    def test_to_xarray_empty(self):
        from xarray import DataArray

        ser = Series([], dtype=object)
        ser.index.name = "foo"
        result = ser.to_xarray()
        assert len(result) == 0

            

Reported by Pylint.

Unable to import 'xarray'
Error

Line: 119 Column: 9

                      assert isinstance(result, DataArray)

    def test_to_xarray_with_multiindex(self):
        from xarray import DataArray

        mi = MultiIndex.from_product([["a", "b"], range(3)], names=["one", "two"])
        ser = Series(range(6), dtype="int64", index=mi)
        result = ser.to_xarray()
        assert len(result) == 2

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

import pandas.util._test_decorators as td

from pandas import (
    Categorical,
    DataFrame,
    MultiIndex,

            

Reported by Pylint.

Missing class docstring
Error

Line: 17 Column: 1

              

@td.skip_if_no("xarray")
class TestDataFrameToXArray:
    @pytest.fixture
    def df(self):
        return DataFrame(
            {
                "a": list("abc"),

            

Reported by Pylint.

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

Line: 19 Column: 5

              @td.skip_if_no("xarray")
class TestDataFrameToXArray:
    @pytest.fixture
    def df(self):
        return DataFrame(
            {
                "a": list("abc"),
                "b": list(range(1, 4)),
                "c": np.arange(3, 6).astype("u1"),

            

Reported by Pylint.

pandas/tests/arrays/sparse/test_accessor.py
54 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              import string

import numpy as np
import pytest

import pandas.util._test_decorators as td

import pandas as pd
import pandas._testing as tm

            

Reported by Pylint.

Unable to import 'scipy.sparse'
Error

Line: 36 Column: 9

                  @pytest.mark.parametrize("dtype", ["float64", "int64"])
    @td.skip_if_no_scipy
    def test_from_spmatrix(self, format, labels, dtype):
        import scipy.sparse

        sp_dtype = SparseDtype(dtype, np.array(0, dtype=dtype).item())

        mat = scipy.sparse.eye(10, format=format, dtype=dtype)
        result = pd.DataFrame.sparse.from_spmatrix(mat, index=labels, columns=labels)

            

Reported by Pylint.

Unable to import 'scipy.sparse'
Error

Line: 50 Column: 9

                  @pytest.mark.parametrize("format", ["csc", "csr", "coo"])
    @td.skip_if_no_scipy
    def test_from_spmatrix_including_explicit_zero(self, format):
        import scipy.sparse

        mat = scipy.sparse.random(10, 2, density=0.5, format=format)
        mat.data[0] = 0
        result = pd.DataFrame.sparse.from_spmatrix(mat)
        dtype = SparseDtype("float64", 0.0)

            

Reported by Pylint.

Unable to import 'scipy.sparse'
Error

Line: 65 Column: 9

                  )
    @td.skip_if_no_scipy
    def test_from_spmatrix_columns(self, columns):
        import scipy.sparse

        dtype = SparseDtype("float64", 0.0)

        mat = scipy.sparse.random(10, 2, density=0.5)
        result = pd.DataFrame.sparse.from_spmatrix(mat, columns=columns)

            

Reported by Pylint.

Unable to import 'scipy.sparse'
Error

Line: 77 Column: 9

                  @pytest.mark.parametrize("colnames", [("A", "B"), (1, 2), (1, pd.NA), (0.1, 0.2)])
    @td.skip_if_no_scipy
    def test_to_coo(self, colnames):
        import scipy.sparse

        df = pd.DataFrame(
            {colnames[0]: [0, 1, 0], colnames[1]: [1, 0, 0]}, dtype="Sparse[int64, 0]"
        )
        result = df.sparse.to_coo()

            

Reported by Pylint.

Unable to import 'scipy.sparse'
Error

Line: 116 Column: 9

                  @pytest.mark.parametrize("dense_index", [True, False])
    @td.skip_if_no_scipy
    def test_series_from_coo(self, dtype, dense_index):
        import scipy.sparse

        A = scipy.sparse.eye(3, format="coo", dtype=dtype)
        result = pd.Series.sparse.from_coo(A, dense_index=dense_index)
        index = pd.MultiIndex.from_tuples([(0, 0), (1, 1), (2, 2)])
        expected = pd.Series(SparseArray(np.array([1, 1, 1], dtype=dtype)), index=index)

            

Reported by Pylint.

Unable to import 'scipy.sparse'
Error

Line: 130 Column: 9

                  @td.skip_if_no_scipy
    def test_series_from_coo_incorrect_format_raises(self):
        # gh-26554
        import scipy.sparse

        m = scipy.sparse.csr_matrix(np.array([[0, 1], [0, 0]]))
        with pytest.raises(
            TypeError, match="Expected coo_matrix. Got csr_matrix instead."
        ):

            

Reported by Pylint.

TODO: collect other Series accessor tests
Error

Line: 17 Column: 3

              

class TestSeriesAccessor:
    # TODO: collect other Series accessor tests
    def test_to_dense(self):
        s = pd.Series([0, 1, 0, 10], dtype="Sparse[int64]")
        result = s.sparse.to_dense()
        expected = pd.Series([0, 1, 0, 10])
        tm.assert_series_equal(result, expected)

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 29 Column: 13

                  def test_accessor_raises(self):
        df = pd.DataFrame({"A": [0, 1]})
        with pytest.raises(AttributeError, match="sparse"):
            df.sparse

    @pytest.mark.parametrize("format", ["csc", "csr", "coo"])
    @pytest.mark.parametrize("labels", [None, list(string.ascii_letters[:10])])
    @pytest.mark.parametrize("dtype", ["float64", "int64"])
    @td.skip_if_no_scipy

            

Reported by Pylint.

Redefining built-in 'format'
Error

Line: 35 Column: 34

                  @pytest.mark.parametrize("labels", [None, list(string.ascii_letters[:10])])
    @pytest.mark.parametrize("dtype", ["float64", "int64"])
    @td.skip_if_no_scipy
    def test_from_spmatrix(self, format, labels, dtype):
        import scipy.sparse

        sp_dtype = SparseDtype(dtype, np.array(0, dtype=dtype).item())

        mat = scipy.sparse.eye(10, format=format, dtype=dtype)

            

Reported by Pylint.

pandas/tests/indexing/test_at.py
54 issues
Unable to import 'pytest'
Error

Line: 7 Column: 1

              )

import numpy as np
import pytest

from pandas import (
    CategoricalDtype,
    CategoricalIndex,
    DataFrame,

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 76 Column: 13

              
        msg = "Invalid call for scalar access"
        with pytest.raises(ValueError, match=msg):
            df.at[[1, 2]]
        with pytest.raises(ValueError, match=msg):
            df.at[1, ["A"]]
        with pytest.raises(ValueError, match=msg):
            df.at[:, "A"]


            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 78 Column: 13

                      with pytest.raises(ValueError, match=msg):
            df.at[[1, 2]]
        with pytest.raises(ValueError, match=msg):
            df.at[1, ["A"]]
        with pytest.raises(ValueError, match=msg):
            df.at[:, "A"]

        with pytest.raises(ValueError, match=msg):
            df.at[[1, 2]] = 1

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 80 Column: 13

                      with pytest.raises(ValueError, match=msg):
            df.at[1, ["A"]]
        with pytest.raises(ValueError, match=msg):
            df.at[:, "A"]

        with pytest.raises(ValueError, match=msg):
            df.at[[1, 2]] = 1
        with pytest.raises(ValueError, match=msg):
            df.at[1, ["A"]] = 1

            

Reported by Pylint.

TODO: De-duplicate/parametrize
Error

Line: 91 Column: 3

              

class TestAtErrors:
    # TODO: De-duplicate/parametrize
    #  test_at_series_raises_key_error2, test_at_frame_raises_key_error2

    def test_at_series_raises_key_error(self, indexer_al):
        # GH#31724 .at should match .loc


            

Reported by Pylint.

Expression "indexer_al(ser)['a']" is assigned to nothing
Error

Line: 102 Column: 13

                      assert result == 3

        with pytest.raises(KeyError, match="a"):
            indexer_al(ser)["a"]

    def test_at_frame_raises_key_error(self, indexer_al):
        # GH#31724 .at should match .loc

        df = DataFrame({0: [1, 2, 3]}, index=[3, 2, 1])

            

Reported by Pylint.

Expression "indexer_al(df)['a', 0]" is assigned to nothing
Error

Line: 113 Column: 13

                      assert result == 3

        with pytest.raises(KeyError, match="a"):
            indexer_al(df)["a", 0]

        with pytest.raises(KeyError, match="a"):
            indexer_al(df)[1, "a"]

    def test_at_series_raises_key_error2(self, indexer_al):

            

Reported by Pylint.

Expression "indexer_al(df)[1, 'a']" is assigned to nothing
Error

Line: 116 Column: 13

                          indexer_al(df)["a", 0]

        with pytest.raises(KeyError, match="a"):
            indexer_al(df)[1, "a"]

    def test_at_series_raises_key_error2(self, indexer_al):
        # at should not fallback
        # GH#7814
        # GH#31724 .at should match .loc

            

Reported by Pylint.

Expression "indexer_al(ser)[0]" is assigned to nothing
Error

Line: 127 Column: 13

                      assert result == 1

        with pytest.raises(KeyError, match="^0$"):
            indexer_al(ser)[0]

    def test_at_frame_raises_key_error2(self, indexer_al):
        # GH#31724 .at should match .loc
        df = DataFrame({"A": [1, 2, 3]}, index=list("abc"))
        result = indexer_al(df)["a", "A"]

            

Reported by Pylint.

Expression "indexer_al(df)['a', 0]" is assigned to nothing
Error

Line: 136 Column: 13

                      assert result == 1

        with pytest.raises(KeyError, match="^0$"):
            indexer_al(df)["a", 0]

    def test_at_getitem_mixed_index_no_fallback(self):
        # GH#19860
        ser = Series([1, 2, 3, 4, 5], index=["a", "b", "c", 1, 2])
        with pytest.raises(KeyError, match="^0$"):

            

Reported by Pylint.

pandas/io/parsers/python_parser.py
54 issues
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 FilePathOrBuffer
from pandas.errors import (
    EmptyDataError,
    ParserError,
)

            

Reported by Pylint.

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 FilePathOrBuffer
from pandas.errors import (
    EmptyDataError,
    ParserError,
)

            

Reported by Pylint.

Instance of 'PythonParser' has no 'chunksize' member
Error

Line: 307 Column: 20

                  def get_chunk(self, size=None):
        if size is None:
            # error: "PythonParser" has no attribute "chunksize"
            size = self.chunksize  # type: ignore[attr-defined]
        return self.read(rows=size)

    def _convert_data(self, data):
        # apply converters
        def _clean_mapping(mapping):

            

Reported by Pylint.

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

Line: 672 Column: 21

                                          line = ret[0]
                            break
                except IndexError:
                    raise StopIteration
        else:
            while self.skipfunc(self.pos):
                self.pos += 1
                # assert for mypy, data is Iterator[str] or None, would error in next
                assert self.data is not None

            

Reported by Pylint.

Unused variable 'columns_'
Error

Line: 916 Column: 26

              
        else:
            # Case 2
            (index_name, columns_, self.index_col) = self._clean_index_names(
                columns, self.index_col, self.unnamed_cols
            )

        return index_name, orig_names, columns


            

Reported by Pylint.

Too many lines in module (1260/1000)
Error

Line: 1 Column: 1

              from __future__ import annotations

from collections import (
    abc,
    defaultdict,
)
from copy import copy
import csv
from io import StringIO

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from __future__ import annotations

from collections import (
    abc,
    defaultdict,
)
from copy import copy
import csv
from io import StringIO

            

Reported by Pylint.

Too many instance attributes (36/7)
Error

Line: 43 Column: 1

              _BOM = "\ufeff"


class PythonParser(ParserBase):
    def __init__(self, f: FilePathOrBuffer | list, **kwds):
        """
        Workhorse function for processing nested list into DataFrame
        """
        ParserBase.__init__(self, kwds)

            

Reported by Pylint.

Missing class docstring
Error

Line: 43 Column: 1

              _BOM = "\ufeff"


class PythonParser(ParserBase):
    def __init__(self, f: FilePathOrBuffer | list, **kwds):
        """
        Workhorse function for processing nested list into DataFrame
        """
        ParserBase.__init__(self, kwds)

            

Reported by Pylint.

Too many statements (76/50)
Error

Line: 44 Column: 5

              

class PythonParser(ParserBase):
    def __init__(self, f: FilePathOrBuffer | list, **kwds):
        """
        Workhorse function for processing nested list into DataFrame
        """
        ParserBase.__init__(self, kwds)


            

Reported by Pylint.

pandas/tests/indexes/datetimes/methods/test_insert.py
54 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              from datetime import datetime

import numpy as np
import pytest
import pytz

from pandas import (
    NA,
    DatetimeIndex,

            

Reported by Pylint.

Unable to import 'pytz'
Error

Line: 5 Column: 1

              
import numpy as np
import pytest
import pytz

from pandas import (
    NA,
    DatetimeIndex,
    Index,

            

Reported by Pylint.

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

Line: 48 Column: 31

                      item = Timestamp("2017-04-05").tz_localize(tz)

        result = dti.insert(0, item)
        assert result.freq == dti.freq

        # But not when we insert an item that doesn't conform to freq
        dti = DatetimeIndex([], tz=tz, freq="W-THU")
        result = dti.insert(0, item)
        assert result.freq is None

            

Reported by Pylint.

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

Line: 117 Column: 35

                          result = idx.insert(n, d)
            tm.assert_index_equal(result, expected)
            assert result.name == expected.name
            assert result.freq == expected.freq

        # reset freq to None
        result = idx.insert(3, datetime(2000, 1, 2))
        expected = DatetimeIndex(
            ["2000-01-31", "2000-02-29", "2000-03-31", "2000-01-02"],

            

Reported by Pylint.

TODO: also changes DataFrame.__setitem__ with expansion
Error

Line: 172 Column: 3

                              assert result.tz == expected.tz
                assert result.freq is None

    # TODO: also changes DataFrame.__setitem__ with expansion
    def test_insert_mismatched_tzawareness(self):
        # see GH#7299
        idx = date_range("1/1/2000", periods=3, freq="D", tz="Asia/Tokyo", name="idx")

        # mismatched tz-awareness

            

Reported by Pylint.

TODO: also changes DataFrame.__setitem__ with expansion
Error

Line: 193 Column: 3

                      )
        tm.assert_index_equal(result, expected)

    # TODO: also changes DataFrame.__setitem__ with expansion
    def test_insert_mismatched_tz(self):
        # see GH#7299
        idx = date_range("1/1/2000", periods=3, freq="D", tz="Asia/Tokyo", name="idx")

        # mismatched tz -> cast to object (could reasonably cast to same tz or UTC)

            

Reported by Pylint.

FIXME: without doing .item() here this segfaults
Error

Line: 225 Column: 3

                      result = dti.insert(1, item)

        if isinstance(item, np.ndarray):
            # FIXME: without doing .item() here this segfaults
            assert item.item() == 0
            expected = Index([dti[0], 0] + list(dti[1:]), dtype=object, name=9)
        else:
            expected = Index([dti[0], item] + list(dti[1:]), dtype=object, name=9)


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from datetime import datetime

import numpy as np
import pytest
import pytz

from pandas import (
    NA,
    DatetimeIndex,

            

Reported by Pylint.

Missing class docstring
Error

Line: 18 Column: 1

              import pandas._testing as tm


class TestInsert:
    @pytest.mark.parametrize("null", [None, np.nan, np.datetime64("NaT"), NaT, NA])
    @pytest.mark.parametrize("tz", [None, "UTC", "US/Eastern"])
    def test_insert_nat(self, tz, null):
        # GH#16537, GH#18295 (test missing)


            

Reported by Pylint.

Method could be a function
Error

Line: 21 Column: 5

              class TestInsert:
    @pytest.mark.parametrize("null", [None, np.nan, np.datetime64("NaT"), NaT, NA])
    @pytest.mark.parametrize("tz", [None, "UTC", "US/Eastern"])
    def test_insert_nat(self, tz, null):
        # GH#16537, GH#18295 (test missing)

        idx = DatetimeIndex(["2017-01-01"], tz=tz)
        expected = DatetimeIndex(["NaT", "2017-01-01"], tz=tz)
        if tz is not None and isinstance(null, np.datetime64):

            

Reported by Pylint.

pandas/core/arrays/timedeltas.py
54 issues
No name 'lib' in module 'pandas._libs'
Error

Line: 8 Column: 1

              
import numpy as np

from pandas._libs import (
    lib,
    tslibs,
)
from pandas._libs.arrays import NDArrayBacked
from pandas._libs.tslibs import (

            

Reported by Pylint.

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

Line: 12 Column: 1

                  lib,
    tslibs,
)
from pandas._libs.arrays import NDArrayBacked
from pandas._libs.tslibs import (
    BaseOffset,
    NaT,
    NaTType,
    Period,

            

Reported by Pylint.

Unable to import 'pandas._libs.arrays'
Error

Line: 12 Column: 1

                  lib,
    tslibs,
)
from pandas._libs.arrays import NDArrayBacked
from pandas._libs.tslibs import (
    BaseOffset,
    NaT,
    NaTType,
    Period,

            

Reported by Pylint.

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

Line: 24 Column: 1

                  iNaT,
    to_offset,
)
from pandas._libs.tslibs.conversion import (
    ensure_timedelta64ns,
    precision_from_unit,
)
from pandas._libs.tslibs.fields import get_timedelta_field
from pandas._libs.tslibs.timedeltas import (

            

Reported by Pylint.

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

Line: 24 Column: 1

                  iNaT,
    to_offset,
)
from pandas._libs.tslibs.conversion import (
    ensure_timedelta64ns,
    precision_from_unit,
)
from pandas._libs.tslibs.fields import get_timedelta_field
from pandas._libs.tslibs.timedeltas import (

            

Reported by Pylint.

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

Line: 28 Column: 1

                  ensure_timedelta64ns,
    precision_from_unit,
)
from pandas._libs.tslibs.fields import get_timedelta_field
from pandas._libs.tslibs.timedeltas import (
    array_to_timedelta64,
    ints_to_pytimedelta,
    parse_timedelta_unit,
)

            

Reported by Pylint.

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

Line: 28 Column: 1

                  ensure_timedelta64ns,
    precision_from_unit,
)
from pandas._libs.tslibs.fields import get_timedelta_field
from pandas._libs.tslibs.timedeltas import (
    array_to_timedelta64,
    ints_to_pytimedelta,
    parse_timedelta_unit,
)

            

Reported by Pylint.

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

Line: 29 Column: 1

                  precision_from_unit,
)
from pandas._libs.tslibs.fields import get_timedelta_field
from pandas._libs.tslibs.timedeltas import (
    array_to_timedelta64,
    ints_to_pytimedelta,
    parse_timedelta_unit,
)
from pandas._typing import (

            

Reported by Pylint.

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

Line: 29 Column: 1

                  precision_from_unit,
)
from pandas._libs.tslibs.fields import get_timedelta_field
from pandas._libs.tslibs.timedeltas import (
    array_to_timedelta64,
    ints_to_pytimedelta,
    parse_timedelta_unit,
)
from pandas._typing import (

            

Reported by Pylint.

Access to a protected member _hasnans of a client class
Error

Line: 84 Column: 12

                  def f(self) -> np.ndarray:
        values = self.asi8
        result = get_timedelta_field(values, alias)
        if self._hasnans:
            result = self._maybe_mask_results(
                result, fill_value=None, convert="float64"
            )

        return result

            

Reported by Pylint.