The following issues were found

pandas/tests/indexes/timedeltas/test_constructors.py
62 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              from datetime import timedelta

import numpy as np
import pytest

import pandas as pd
from pandas import (
    Timedelta,
    TimedeltaIndex,

            

Reported by Pylint.

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

Line: 57 Column: 31

                      tdi = timedelta_range("1 second", periods=10 ** 7, freq="1s")

        result = TimedeltaIndex(tdi, freq="infer")
        assert result.freq == tdi.freq

        # check that inferred_freq was not called by checking that the
        #  value has not been cached
        assert "inferred_freq" not in getattr(result, "_cache", {})


            

Reported by Pylint.

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

Line: 57 Column: 31

                      tdi = timedelta_range("1 second", periods=10 ** 7, freq="1s")

        result = TimedeltaIndex(tdi, freq="infer")
        assert result.freq == tdi.freq

        # check that inferred_freq was not called by checking that the
        #  value has not been cached
        assert "inferred_freq" not in getattr(result, "_cache", {})


            

Reported by Pylint.

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

Line: 57 Column: 16

                      tdi = timedelta_range("1 second", periods=10 ** 7, freq="1s")

        result = TimedeltaIndex(tdi, freq="infer")
        assert result.freq == tdi.freq

        # check that inferred_freq was not called by checking that the
        #  value has not been cached
        assert "inferred_freq" not in getattr(result, "_cache", {})


            

Reported by Pylint.

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

Line: 94 Column: 28

              
        msg = "cannot be converted to timedelta64"
        with pytest.raises(TypeError, match=msg):
            TimedeltaIndex(dti.tz_localize("Europe/Brussels"))

        with pytest.raises(TypeError, match=msg):
            TimedeltaIndex(dti)

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

            

Reported by Pylint.

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

Line: 94 Column: 28

              
        msg = "cannot be converted to timedelta64"
        with pytest.raises(TypeError, match=msg):
            TimedeltaIndex(dti.tz_localize("Europe/Brussels"))

        with pytest.raises(TypeError, match=msg):
            TimedeltaIndex(dti)

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

            

Reported by Pylint.

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

Line: 258 Column: 16

                  def test_explicit_none_freq(self):
        # Explicitly passing freq=None is respected
        tdi = timedelta_range(1, periods=5)
        assert tdi.freq is not None

        result = TimedeltaIndex(tdi, freq=None)
        assert result.freq is None

        result = TimedeltaIndex(tdi._data, freq=None)

            

Reported by Pylint.

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

Line: 258 Column: 16

                  def test_explicit_none_freq(self):
        # Explicitly passing freq=None is respected
        tdi = timedelta_range(1, periods=5)
        assert tdi.freq is not None

        result = TimedeltaIndex(tdi, freq=None)
        assert result.freq is None

        result = TimedeltaIndex(tdi._data, freq=None)

            

Reported by Pylint.

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

Line: 261 Column: 16

                      assert tdi.freq is not None

        result = TimedeltaIndex(tdi, freq=None)
        assert result.freq is None

        result = TimedeltaIndex(tdi._data, freq=None)
        assert result.freq is None

    def test_from_categorical(self):

            

Reported by Pylint.

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

Line: 264 Column: 16

                      assert result.freq is None

        result = TimedeltaIndex(tdi._data, freq=None)
        assert result.freq is None

    def test_from_categorical(self):
        tdi = timedelta_range(1, periods=5)

        cat = pd.Categorical(tdi)

            

Reported by Pylint.

pandas/core/api.py
62 issues
No name 'missing' in module 'pandas._libs'
Error

Line: 9 Column: 1

                  Timedelta,
    Timestamp,
)
from pandas._libs.missing import NA

from pandas.core.dtypes.dtypes import (
    CategoricalDtype,
    DatetimeTZDtype,
    IntervalDtype,

            

Reported by Pylint.

Unable to import 'pandas._libs.missing'
Error

Line: 9 Column: 1

                  Timedelta,
    Timestamp,
)
from pandas._libs.missing import NA

from pandas.core.dtypes.dtypes import (
    CategoricalDtype,
    DatetimeTZDtype,
    IntervalDtype,

            

Reported by Pylint.

Unused Timedelta imported from pandas._libs
Error

Line: 3 Column: 1

              # flake8: noqa

from pandas._libs import (
    NaT,
    Period,
    Timedelta,
    Timestamp,
)
from pandas._libs.missing import NA

            

Reported by Pylint.

Unused NaT imported from pandas._libs
Error

Line: 3 Column: 1

              # flake8: noqa

from pandas._libs import (
    NaT,
    Period,
    Timedelta,
    Timestamp,
)
from pandas._libs.missing import NA

            

Reported by Pylint.

Unused Period imported from pandas._libs
Error

Line: 3 Column: 1

              # flake8: noqa

from pandas._libs import (
    NaT,
    Period,
    Timedelta,
    Timestamp,
)
from pandas._libs.missing import NA

            

Reported by Pylint.

Unused Timestamp imported from pandas._libs
Error

Line: 3 Column: 1

              # flake8: noqa

from pandas._libs import (
    NaT,
    Period,
    Timedelta,
    Timestamp,
)
from pandas._libs.missing import NA

            

Reported by Pylint.

Unused NA imported from pandas._libs.missing
Error

Line: 9 Column: 1

                  Timedelta,
    Timestamp,
)
from pandas._libs.missing import NA

from pandas.core.dtypes.dtypes import (
    CategoricalDtype,
    DatetimeTZDtype,
    IntervalDtype,

            

Reported by Pylint.

Unused CategoricalDtype imported from pandas.core.dtypes.dtypes
Error

Line: 11 Column: 1

              )
from pandas._libs.missing import NA

from pandas.core.dtypes.dtypes import (
    CategoricalDtype,
    DatetimeTZDtype,
    IntervalDtype,
    PeriodDtype,
)

            

Reported by Pylint.

Unused PeriodDtype imported from pandas.core.dtypes.dtypes
Error

Line: 11 Column: 1

              )
from pandas._libs.missing import NA

from pandas.core.dtypes.dtypes import (
    CategoricalDtype,
    DatetimeTZDtype,
    IntervalDtype,
    PeriodDtype,
)

            

Reported by Pylint.

Unused IntervalDtype imported from pandas.core.dtypes.dtypes
Error

Line: 11 Column: 1

              )
from pandas._libs.missing import NA

from pandas.core.dtypes.dtypes import (
    CategoricalDtype,
    DatetimeTZDtype,
    IntervalDtype,
    PeriodDtype,
)

            

Reported by Pylint.

pandas/tests/io/formats/style/test_highlight.py
62 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

from pandas import (
    NA,
    DataFrame,
    IndexSlice,
)


            

Reported by Pylint.

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

Line: 21 Column: 12

              

@pytest.fixture
def styler(df):
    return Styler(df, uuid_len=0)


def test_highlight_null(styler):
    result = styler.highlight_null()._compute().ctx

            

Reported by Pylint.

Redefining name 'styler' from outer scope (line 21)
Error

Line: 25 Column: 25

                  return Styler(df, uuid_len=0)


def test_highlight_null(styler):
    result = styler.highlight_null()._compute().ctx
    expected = {
        (1, 0): [("background-color", "red")],
        (1, 1): [("background-color", "red")],
    }

            

Reported by Pylint.

Access to a protected member _compute of a client class
Error

Line: 26 Column: 14

              

def test_highlight_null(styler):
    result = styler.highlight_null()._compute().ctx
    expected = {
        (1, 0): [("background-color", "red")],
        (1, 1): [("background-color", "red")],
    }
    assert result == expected

            

Reported by Pylint.

Redefining name 'styler' from outer scope (line 21)
Error

Line: 34 Column: 32

                  assert result == expected


def test_highlight_null_subset(styler):
    # GH 31345
    result = (
        styler.highlight_null(null_color="red", subset=["A"])
        .highlight_null(null_color="green", subset=["B"])
        ._compute()

            

Reported by Pylint.

Access to a protected member _compute of a client class
Error

Line: 37 Column: 9

              def test_highlight_null_subset(styler):
    # GH 31345
    result = (
        styler.highlight_null(null_color="red", subset=["A"])
        .highlight_null(null_color="green", subset=["B"])
        ._compute()
        .ctx
    )
    expected = {

            

Reported by Pylint.

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

Line: 50 Column: 33

              

@pytest.mark.parametrize("f", ["highlight_min", "highlight_max"])
def test_highlight_minmax_basic(df, f):
    expected = {
        (0, 1): [("background-color", "red")],
        # ignores NaN row,
        (2, 0): [("background-color", "red")],
    }

            

Reported by Pylint.

Access to a protected member _compute of a client class
Error

Line: 58 Column: 14

                  }
    if f == "highlight_min":
        df = -df
    result = getattr(df.style, f)(axis=1, color="red")._compute().ctx
    assert result == expected


@pytest.mark.parametrize("f", ["highlight_min", "highlight_max"])
@pytest.mark.parametrize(

            

Reported by Pylint.

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

Line: 71 Column: 31

                      {"axis": None, "props": "background-color: red"},  # test props
    ],
)
def test_highlight_minmax_ext(df, f, kwargs):
    expected = {(2, 0): [("background-color", "red")]}
    if f == "highlight_min":
        df = -df
    result = getattr(df.style, f)(**kwargs)._compute().ctx
    assert result == expected

            

Reported by Pylint.

Access to a protected member _compute of a client class
Error

Line: 75 Column: 14

                  expected = {(2, 0): [("background-color", "red")]}
    if f == "highlight_min":
        df = -df
    result = getattr(df.style, f)(**kwargs)._compute().ctx
    assert result == expected


@pytest.mark.parametrize("f", ["highlight_min", "highlight_max"])
@pytest.mark.parametrize("axis", [None, 0, 1])

            

Reported by Pylint.

pandas/tests/arrays/categorical/test_analytics.py
62 issues
Unable to import 'pytest'
Error

Line: 5 Column: 1

              import sys

import numpy as np
import pytest

from pandas.compat import PYPY

from pandas import (
    Categorical,

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import re
import sys

import numpy as np
import pytest

from pandas.compat import PYPY

from pandas import (

            

Reported by Pylint.

Missing class docstring
Error

Line: 21 Column: 1

              from pandas.api.types import is_scalar


class TestCategoricalAnalytics:
    @pytest.mark.parametrize("aggregation", ["min", "max"])
    def test_min_max_not_ordered_raises(self, aggregation):
        # unordered cats have no min/max
        cat = Categorical(["a", "b", "c", "d"], ordered=False)
        msg = f"Categorical is not ordered for operation {aggregation}"

            

Reported by Pylint.

Method could be a function
Error

Line: 23 Column: 5

              
class TestCategoricalAnalytics:
    @pytest.mark.parametrize("aggregation", ["min", "max"])
    def test_min_max_not_ordered_raises(self, aggregation):
        # unordered cats have no min/max
        cat = Categorical(["a", "b", "c", "d"], ordered=False)
        msg = f"Categorical is not ordered for operation {aggregation}"
        agg_func = getattr(cat, aggregation)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 23 Column: 5

              
class TestCategoricalAnalytics:
    @pytest.mark.parametrize("aggregation", ["min", "max"])
    def test_min_max_not_ordered_raises(self, aggregation):
        # unordered cats have no min/max
        cat = Categorical(["a", "b", "c", "d"], ordered=False)
        msg = f"Categorical is not ordered for operation {aggregation}"
        agg_func = getattr(cat, aggregation)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 32 Column: 5

                      with pytest.raises(TypeError, match=msg):
            agg_func()

    def test_min_max_ordered(self):
        cat = Categorical(["a", "b", "c", "d"], ordered=True)
        _min = cat.min()
        _max = cat.max()
        assert _min == "a"
        assert _max == "d"

            

Reported by Pylint.

Method could be a function
Error

Line: 32 Column: 5

                      with pytest.raises(TypeError, match=msg):
            agg_func()

    def test_min_max_ordered(self):
        cat = Categorical(["a", "b", "c", "d"], ordered=True)
        _min = cat.min()
        _max = cat.max()
        assert _min == "a"
        assert _max == "d"

            

Reported by Pylint.

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

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

                      cat = Categorical(["a", "b", "c", "d"], ordered=True)
        _min = cat.min()
        _max = cat.max()
        assert _min == "a"
        assert _max == "d"

        cat = Categorical(
            ["a", "b", "c", "d"], categories=["d", "c", "b", "a"], ordered=True
        )

            

Reported by Bandit.

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

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

                      _min = cat.min()
        _max = cat.max()
        assert _min == "a"
        assert _max == "d"

        cat = Categorical(
            ["a", "b", "c", "d"], categories=["d", "c", "b", "a"], ordered=True
        )
        _min = cat.min()

            

Reported by Bandit.

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

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

                      )
        _min = cat.min()
        _max = cat.max()
        assert _min == "d"
        assert _max == "a"

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

            

Reported by Bandit.

pandas/tests/io/formats/style/test_deprecated.py
62 issues
Unable to import 'pytest'
Error

Line: 5 Column: 1

              modules collects tests for Styler methods which have been deprecated
"""
import numpy as np
import pytest

jinja2 = pytest.importorskip("jinja2")

from pandas import (
    DataFrame,

            

Reported by Pylint.

Redefining name 'df' from outer scope (line 19)
Error

Line: 25 Column: 5

              
def test_set_non_numeric_na():
    # GH 21527 28358
    df = DataFrame(
        {
            "object": [None, np.nan, "foo"],
            "datetime": [None, NaT, Timestamp("20120101")],
        }
    )

            

Reported by Pylint.

Access to a protected member _translate of a client class
Error

Line: 33 Column: 15

                  )

    with tm.assert_produces_warning(FutureWarning):
        ctx = df.style.set_na_rep("NA")._translate(True, True)
    assert ctx["body"][0][1]["display_value"] == "NA"
    assert ctx["body"][0][2]["display_value"] == "NA"
    assert ctx["body"][1][1]["display_value"] == "NA"
    assert ctx["body"][1][2]["display_value"] == "NA"


            

Reported by Pylint.

Redefining name 'df' from outer scope (line 19)
Error

Line: 40 Column: 31

                  assert ctx["body"][1][2]["display_value"] == "NA"


def test_where_with_one_style(df):
    # GH 17474
    def f(x):
        return x > 0.5

    style1 = "foo: bar"

            

Reported by Pylint.

Access to a protected member _compute of a client class
Error

Line: 48 Column: 18

                  style1 = "foo: bar"

    with tm.assert_produces_warning(FutureWarning):
        result = df.style.where(f, style1)._compute().ctx
    expected = {
        (r, c): [("foo", "bar")]
        for r, row in enumerate(df.index)
        for c, col in enumerate(df.columns)
        if f(df.loc[row, col])

            

Reported by Pylint.

Redefining name 'df' from outer scope (line 19)
Error

Line: 68 Column: 23

                      IndexSlice[:2, ["A", "B"]],
    ],
)
def test_where_subset(df, slice_):
    # GH 17474
    def f(x):
        return x > 0.5

    style1 = "foo: bar"

            

Reported by Pylint.

Access to a protected member _compute of a client class
Error

Line: 77 Column: 15

                  style2 = "baz: foo"

    with tm.assert_produces_warning(FutureWarning):
        res = df.style.where(f, style1, style2, subset=slice_)._compute().ctx
    expected = {
        (r, c): [("foo", "bar") if f(df.loc[row, col]) else ("baz", "foo")]
        for r, row in enumerate(df.index)
        for c, col in enumerate(df.columns)
        if row in df.loc[slice_].index and col in df.loc[slice_].columns

            

Reported by Pylint.

Redefining name 'df' from outer scope (line 19)
Error

Line: 87 Column: 45

                  assert res == expected


def test_where_subset_compare_with_applymap(df):
    # GH 17474
    def f(x):
        return x > 0.5

    style1 = "foo: bar"

            

Reported by Pylint.

Access to a protected member _compute of a client class
Error

Line: 108 Column: 22

              
    for slice_ in slices:
        with tm.assert_produces_warning(FutureWarning):
            result = df.style.where(f, style1, style2, subset=slice_)._compute().ctx
        expected = df.style.applymap(g, subset=slice_)._compute().ctx
        assert result == expected


def test_where_kwargs():

            

Reported by Pylint.

Access to a protected member _compute of a client class
Error

Line: 109 Column: 20

                  for slice_ in slices:
        with tm.assert_produces_warning(FutureWarning):
            result = df.style.where(f, style1, style2, subset=slice_)._compute().ctx
        expected = df.style.applymap(g, subset=slice_)._compute().ctx
        assert result == expected


def test_where_kwargs():
    df = DataFrame([[1, 2], [3, 4]])

            

Reported by Pylint.

pandas/tests/series/methods/test_reindex.py
61 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

from pandas import (
    Categorical,
    Index,
    MultiIndex,
    NaT,
    Period,

            

Reported by Pylint.

Access to a protected member _with_freq of a client class
Error

Line: 87 Column: 22

              
    result = ts.reindex(list(ts.index[5:10]))
    expected = ts[5:10]
    expected.index = expected.index._with_freq(None)
    tm.assert_series_equal(result, expected)

    result = ts[list(ts.index[5:10])]
    tm.assert_series_equal(result, expected)


            

Reported by Pylint.

Access to a protected member _with_freq of a client class
Error

Line: 104 Column: 29

              
    # pass non-Index
    reindexed = datetime_series.reindex(list(datetime_series.index))
    datetime_series.index = datetime_series.index._with_freq(None)
    tm.assert_series_equal(datetime_series, reindexed)

    # bad fill method
    ts = datetime_series[::2]
    msg = (

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

from pandas import (
    Categorical,
    Index,
    MultiIndex,
    NaT,
    Period,

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 18 Column: 1

              import pandas._testing as tm


def test_reindex(datetime_series, string_series):
    identity = string_series.reindex(string_series.index)

    # __array_interface__ is not defined for older numpies
    # and on some pythons
    try:

            

Reported by Pylint.

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

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

                  # __array_interface__ is not defined for older numpies
    # and on some pythons
    try:
        assert np.may_share_memory(string_series.index, identity.index)
    except AttributeError:
        pass

    assert identity.index.is_(string_series.index)
    assert identity.index.identical(string_series.index)

            

Reported by Bandit.

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

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

                  except AttributeError:
        pass

    assert identity.index.is_(string_series.index)
    assert identity.index.identical(string_series.index)

    subIndex = string_series.index[10:20]
    subSeries = string_series.reindex(subIndex)


            

Reported by Bandit.

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

                      pass

    assert identity.index.is_(string_series.index)
    assert identity.index.identical(string_series.index)

    subIndex = string_series.index[10:20]
    subSeries = string_series.reindex(subIndex)

    for idx, val in subSeries.items():

            

Reported by Bandit.

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

Line: 31 Column: 5

                  assert identity.index.is_(string_series.index)
    assert identity.index.identical(string_series.index)

    subIndex = string_series.index[10:20]
    subSeries = string_series.reindex(subIndex)

    for idx, val in subSeries.items():
        assert val == string_series[idx]


            

Reported by Pylint.

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

Line: 32 Column: 5

                  assert identity.index.identical(string_series.index)

    subIndex = string_series.index[10:20]
    subSeries = string_series.reindex(subIndex)

    for idx, val in subSeries.items():
        assert val == string_series[idx]

    subIndex2 = datetime_series.index[10:20]

            

Reported by Pylint.

pandas/tests/generic/test_frame.py
61 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,
    MultiIndex,

            

Reported by Pylint.

function already defined line 103
Error

Line: 125 Column: 9

                      df1 = DataFrame(np.random.randint(0, 4, (3, 2)), columns=list("ab"))
        df1.filename = "foo"

        def finalize(self, other, method=None, **kwargs):
            for name in self._metadata:
                if method == "concat":
                    value = "+".join(
                        [getattr(o, name) for o in other.objs if getattr(o, name, None)]
                    )

            

Reported by Pylint.

Bad first argument 'DataFrame' given to super()
Error

Line: 175 Column: 13

              
        msg = 'For argument "inplace" expected type bool, received type'
        with pytest.raises(ValueError, match=msg):
            super(DataFrame, df).rename_axis(
                mapper={"a": "x", "b": "y"}, axis=1, inplace=value
            )

        with pytest.raises(ValueError, match=msg):
            super(DataFrame, df).drop("a", axis=1, inplace=value)

            

Reported by Pylint.

Bad first argument 'DataFrame' given to super()
Error

Line: 180 Column: 13

                          )

        with pytest.raises(ValueError, match=msg):
            super(DataFrame, df).drop("a", axis=1, inplace=value)

        with pytest.raises(ValueError, match=msg):
            super(DataFrame, df).fillna(value=0, inplace=value)

        with pytest.raises(ValueError, match=msg):

            

Reported by Pylint.

Bad first argument 'DataFrame' given to super()
Error

Line: 183 Column: 13

                          super(DataFrame, df).drop("a", axis=1, inplace=value)

        with pytest.raises(ValueError, match=msg):
            super(DataFrame, df).fillna(value=0, inplace=value)

        with pytest.raises(ValueError, match=msg):
            super(DataFrame, df).replace(to_replace=1, value=7, inplace=value)

        with pytest.raises(ValueError, match=msg):

            

Reported by Pylint.

Bad first argument 'DataFrame' given to super()
Error

Line: 186 Column: 13

                          super(DataFrame, df).fillna(value=0, inplace=value)

        with pytest.raises(ValueError, match=msg):
            super(DataFrame, df).replace(to_replace=1, value=7, inplace=value)

        with pytest.raises(ValueError, match=msg):
            super(DataFrame, df).interpolate(inplace=value)

        with pytest.raises(ValueError, match=msg):

            

Reported by Pylint.

Bad first argument 'DataFrame' given to super()
Error

Line: 189 Column: 13

                          super(DataFrame, df).replace(to_replace=1, value=7, inplace=value)

        with pytest.raises(ValueError, match=msg):
            super(DataFrame, df).interpolate(inplace=value)

        with pytest.raises(ValueError, match=msg):
            super(DataFrame, df)._where(cond=df.a > 2, inplace=value)

        with pytest.raises(ValueError, match=msg):

            

Reported by Pylint.

Bad first argument 'DataFrame' given to super()
Error

Line: 192 Column: 13

                          super(DataFrame, df).interpolate(inplace=value)

        with pytest.raises(ValueError, match=msg):
            super(DataFrame, df)._where(cond=df.a > 2, inplace=value)

        with pytest.raises(ValueError, match=msg):
            super(DataFrame, df).mask(cond=df.a > 2, inplace=value)

    def test_unexpected_keyword(self):

            

Reported by Pylint.

Bad first argument 'DataFrame' given to super()
Error

Line: 195 Column: 13

                          super(DataFrame, df)._where(cond=df.a > 2, inplace=value)

        with pytest.raises(ValueError, match=msg):
            super(DataFrame, df).mask(cond=df.a > 2, inplace=value)

    def test_unexpected_keyword(self):
        # GH8597
        df = DataFrame(np.random.randn(5, 2), columns=["jim", "joe"])
        ca = pd.Categorical([0, 0, 2, 2, 3, np.nan])

            

Reported by Pylint.

Unexpected keyword argument 'in_place' in method call
Error

Line: 206 Column: 13

              
        msg = "unexpected keyword"
        with pytest.raises(TypeError, match=msg):
            df.drop("joe", axis=1, in_place=True)

        with pytest.raises(TypeError, match=msg):
            df.reindex([1, 0], inplace=True)

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

            

Reported by Pylint.

pandas/tests/series/methods/test_append.py
61 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

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

            

Reported by Pylint.

Unable to import 'pytz'
Error

Line: 133 Column: 9

              
    def test_append_tz_explicit_pytz(self):
        # see gh-2938
        from pytz import timezone as timezone

        rng = date_range(
            "5/8/2012 1:45", periods=10, freq="5T", tz=timezone("US/Eastern")
        )
        rng2 = date_range(

            

Reported by Pylint.

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

Line: 193 Column: 38

                      )
        exp = Series([1, 2], index=exp_index)
        tm.assert_series_equal(ts_result, exp)
        assert ts_result.index.tz == rng1.tz

        rng1 = date_range("1/1/2011 01:00", periods=1, freq="H", tz="UTC")
        rng2 = date_range("1/1/2011 02:00", periods=1, freq="H", tz="UTC")
        ser1 = Series([1], index=rng1)
        ser2 = Series([2], index=rng2)

            

Reported by Pylint.

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

Line: 193 Column: 38

                      )
        exp = Series([1, 2], index=exp_index)
        tm.assert_series_equal(ts_result, exp)
        assert ts_result.index.tz == rng1.tz

        rng1 = date_range("1/1/2011 01:00", periods=1, freq="H", tz="UTC")
        rng2 = date_range("1/1/2011 02:00", periods=1, freq="H", tz="UTC")
        ser1 = Series([1], index=rng1)
        ser2 = Series([2], index=rng2)

            

Reported by Pylint.

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

Line: 206 Column: 15

                      )
        exp = Series([1, 2], index=exp_index)
        tm.assert_series_equal(ts_result, exp)
        utc = rng1.tz
        assert utc == ts_result.index.tz

        # GH#7795
        # different tz coerces to object dtype, not UTC
        rng1 = date_range("1/1/2011 01:00", periods=1, freq="H", tz="US/Eastern")

            

Reported by Pylint.

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

Line: 206 Column: 15

                      )
        exp = Series([1, 2], index=exp_index)
        tm.assert_series_equal(ts_result, exp)
        utc = rng1.tz
        assert utc == ts_result.index.tz

        # GH#7795
        # different tz coerces to object dtype, not UTC
        rng1 = date_range("1/1/2011 01:00", periods=1, freq="H", tz="US/Eastern")

            

Reported by Pylint.

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

Line: 265 Column: 38

                      )
        exp = Series([1, 2, 3, 10, 11, 12], index=exp_index)
        tm.assert_series_equal(ts_result, exp)
        assert ts_result.index.tz == rng1.tz

            

Reported by Pylint.

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

Line: 265 Column: 38

                      )
        exp = Series([1, 2, 3, 10, 11, 12], index=exp_index)
        tm.assert_series_equal(ts_result, exp)
        assert ts_result.index.tz == rng1.tz

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

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

            

Reported by Pylint.

Missing class docstring
Error

Line: 16 Column: 1

              import pandas._testing as tm


class TestSeriesAppend:
    def test_append_preserve_name(self, datetime_series):
        result = datetime_series[:5].append(datetime_series[5:])
        assert result.name == datetime_series.name

    def test_append(self, datetime_series, string_series, object_series):

            

Reported by Pylint.

pandas/tests/io/excel/test_openpyxl.py
61 issues
Unable to import 'pytest'
Error

Line: 5 Column: 1

              import re

import numpy as np
import pytest

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


            

Reported by Pylint.

Unable to import 'openpyxl'
Error

Line: 22 Column: 5

              

def test_to_excel_styleconverter(ext):
    from openpyxl import styles

    hstyle = {
        "font": {"color": "00FF0000", "bold": True},
        "borders": {"top": "thin", "right": "thin", "bottom": "thin", "left": "thin"},
        "alignment": {"horizontal": "center", "vertical": "top"},

            

Reported by Pylint.

Abstract class 'ExcelWriter' with abstract methods instantiated
Error

Line: 96 Column: 18

                  with tm.ensure_clean(ext) as f:
        msg = re.escape("Use of **kwargs is deprecated")
        with tm.assert_produces_warning(FutureWarning, match=msg):
            with ExcelWriter(f, engine="openpyxl", **kwargs) as writer:
                # ExcelWriter won't allow us to close without writing something
                DataFrame().to_excel(writer)


@pytest.mark.parametrize("write_only", [True, False])

            

Reported by Pylint.

Abstract class 'ExcelWriter' with abstract methods instantiated
Error

Line: 107 Column: 14

                  # openpyxl doesn't utilize kwargs, only test that supplying a engine_kwarg works
    engine_kwargs = {"write_only": write_only}
    with tm.ensure_clean(ext) as f:
        with ExcelWriter(f, engine="openpyxl", engine_kwargs=engine_kwargs) as writer:
            # ExcelWriter won't allow us to close without writing something
            DataFrame().to_excel(writer)


@pytest.mark.parametrize(

            

Reported by Pylint.

Abstract class 'ExcelWriter' with abstract methods instantiated
Error

Line: 126 Column: 14

                      wb.worksheets[1]["A1"].value = "bar"
        wb.save(f)

        with ExcelWriter(f, engine="openpyxl", mode=mode) as writer:
            df.to_excel(writer, sheet_name="baz", index=False)

        wb2 = openpyxl.load_workbook(f)
        result = [sheet.title for sheet in wb2.worksheets]
        assert result == expected

            

Reported by Pylint.

Abstract class 'ExcelWriter' with abstract methods instantiated
Error

Line: 151 Column: 14

              
    with tm.ensure_clean(ext) as f:
        df1.to_excel(f, engine="openpyxl", sheet_name="foo", index=False)
        with ExcelWriter(
            f, engine="openpyxl", mode="a", if_sheet_exists=if_sheet_exists
        ) as writer:
            df2.to_excel(writer, sheet_name="foo", index=False)

        wb = openpyxl.load_workbook(f)

            

Reported by Pylint.

Abstract class 'ExcelWriter' with abstract methods instantiated
Error

Line: 191 Column: 18

                  with tm.ensure_clean(ext) as f:
        with pytest.raises(ValueError, match=re.escape(msg)):
            df.to_excel(f, "foo", engine="openpyxl")
            with ExcelWriter(
                f, engine="openpyxl", mode="a", if_sheet_exists=if_sheet_exists
            ) as writer:
                df.to_excel(writer, sheet_name="foo")



            

Reported by Pylint.

Abstract class 'ExcelWriter' with abstract methods instantiated
Error

Line: 263 Column: 14

                  with tm.ensure_clean(ext) as f:
        df.to_excel(f, engine="openpyxl")

        with ExcelWriter(
            f, mode="a", engine="openpyxl", if_sheet_exists="new"
        ) as writer:
            df.to_excel(writer)

        # make sure that zip files are not concatenated by making sure that

            

Reported by Pylint.

Unused argument 'ext'
Error

Line: 21 Column: 34

              pytestmark = pytest.mark.parametrize("ext", [".xlsx"])


def test_to_excel_styleconverter(ext):
    from openpyxl import styles

    hstyle = {
        "font": {"color": "00FF0000", "bold": True},
        "borders": {"top": "thin", "right": "thin", "bottom": "thin", "left": "thin"},

            

Reported by Pylint.

Access to a protected member _convert_to_style_kwargs of a client class
Error

Line: 45 Column: 10

              
    protection = styles.Protection(locked=True, hidden=False)

    kw = _OpenpyxlWriter._convert_to_style_kwargs(hstyle)
    assert kw["font"] == font
    assert kw["border"] == border
    assert kw["alignment"] == alignment
    assert kw["fill"] == fill
    assert kw["number_format"] == number_format

            

Reported by Pylint.

pandas/tests/frame/methods/test_between_time.py
61 issues
Unable to import 'pytest'
Error

Line: 7 Column: 1

              )

import numpy as np
import pytest

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

from pandas import (

            

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 import timezones
import pandas.util._test_decorators as td

from pandas import (
    DataFrame,
    Series,

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from datetime import (
    datetime,
    time,
)

import numpy as np
import pytest

from pandas._libs.tslibs import timezones

            

Reported by Pylint.

Missing class docstring
Error

Line: 20 Column: 1

              import pandas._testing as tm


class TestBetweenTime:
    @td.skip_if_has_locale
    def test_between_time_formats(self, frame_or_series):
        # GH#11818
        rng = date_range("1/1/2000", "1/5/2000", freq="5min")
        ts = DataFrame(np.random.randn(len(rng), 2), index=rng)

            

Reported by Pylint.

Method could be a function
Error

Line: 22 Column: 5

              
class TestBetweenTime:
    @td.skip_if_has_locale
    def test_between_time_formats(self, frame_or_series):
        # GH#11818
        rng = date_range("1/1/2000", "1/5/2000", freq="5min")
        ts = DataFrame(np.random.randn(len(rng), 2), index=rng)
        if frame_or_series is Series:
            ts = ts[0]

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 22 Column: 5

              
class TestBetweenTime:
    @td.skip_if_has_locale
    def test_between_time_formats(self, frame_or_series):
        # GH#11818
        rng = date_range("1/1/2000", "1/5/2000", freq="5min")
        ts = DataFrame(np.random.randn(len(rng), 2), index=rng)
        if frame_or_series is Series:
            ts = ts[0]

            

Reported by Pylint.

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

Line: 25 Column: 9

                  def test_between_time_formats(self, frame_or_series):
        # GH#11818
        rng = date_range("1/1/2000", "1/5/2000", freq="5min")
        ts = DataFrame(np.random.randn(len(rng), 2), index=rng)
        if frame_or_series is Series:
            ts = ts[0]

        strings = [
            ("2:00", "2:30"),

            

Reported by Pylint.

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

Line: 27 Column: 13

                      rng = date_range("1/1/2000", "1/5/2000", freq="5min")
        ts = DataFrame(np.random.randn(len(rng), 2), index=rng)
        if frame_or_series is Series:
            ts = ts[0]

        strings = [
            ("2:00", "2:30"),
            ("0200", "0230"),
            ("2:00am", "2:30am"),

            

Reported by Pylint.

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

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

                      expected_length = 28

        for time_string in strings:
            assert len(ts.between_time(*time_string)) == expected_length

    @pytest.mark.parametrize("tzstr", ["US/Eastern", "dateutil/US/Eastern"])
    def test_localized_between_time(self, tzstr, frame_or_series):
        tz = timezones.maybe_get_tz(tzstr)


            

Reported by Bandit.

Method could be a function
Error

Line: 45 Column: 5

                          assert len(ts.between_time(*time_string)) == expected_length

    @pytest.mark.parametrize("tzstr", ["US/Eastern", "dateutil/US/Eastern"])
    def test_localized_between_time(self, tzstr, frame_or_series):
        tz = timezones.maybe_get_tz(tzstr)

        rng = date_range("4/16/2012", "5/1/2012", freq="H")
        ts = Series(np.random.randn(len(rng)), index=rng)
        if frame_or_series is DataFrame:

            

Reported by Pylint.