The following issues were found

pandas/tests/window/moments/test_moments_rolling_apply.py
24 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              import warnings

import numpy as np
import pytest

from pandas import (
    DataFrame,
    Series,
    concat,

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import warnings

import numpy as np
import pytest

from pandas import (
    DataFrame,
    Series,
    concat,

            

Reported by Pylint.

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

Line: 18 Column: 1

              import pandas.tseries.offsets as offsets


def f(x):
    # suppress warnings about empty slices, as we are deliberately testing
    # with a 0-length Series
    with warnings.catch_warnings():
        warnings.filterwarnings(
            "ignore",

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 18 Column: 1

              import pandas.tseries.offsets as offsets


def f(x):
    # suppress warnings about empty slices, as we are deliberately testing
    # with a 0-length Series
    with warnings.catch_warnings():
        warnings.filterwarnings(
            "ignore",

            

Reported by Pylint.

Function name "f" doesn't conform to snake_case naming style
Error

Line: 18 Column: 1

              import pandas.tseries.offsets as offsets


def f(x):
    # suppress warnings about empty slices, as we are deliberately testing
    # with a 0-length Series
    with warnings.catch_warnings():
        warnings.filterwarnings(
            "ignore",

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 30 Column: 1

                      return x[np.isfinite(x)].mean()


def test_series(raw, series):
    result = series.rolling(50).apply(f, raw=raw)
    assert isinstance(result, Series)
    tm.assert_almost_equal(result.iloc[-1], np.mean(series[-50:]))



            

Reported by Pylint.

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

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

              
def test_series(raw, series):
    result = series.rolling(50).apply(f, raw=raw)
    assert isinstance(result, Series)
    tm.assert_almost_equal(result.iloc[-1], np.mean(series[-50:]))


def test_frame(raw, frame):
    result = frame.rolling(50).apply(f, raw=raw)

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 36 Column: 1

                  tm.assert_almost_equal(result.iloc[-1], np.mean(series[-50:]))


def test_frame(raw, frame):
    result = frame.rolling(50).apply(f, raw=raw)
    assert isinstance(result, DataFrame)
    tm.assert_series_equal(
        result.iloc[-1, :],
        frame.iloc[-50:, :].apply(np.mean, axis=0, raw=raw),

            

Reported by Pylint.

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

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

              
def test_frame(raw, frame):
    result = frame.rolling(50).apply(f, raw=raw)
    assert isinstance(result, DataFrame)
    tm.assert_series_equal(
        result.iloc[-1, :],
        frame.iloc[-50:, :].apply(np.mean, axis=0, raw=raw),
        check_names=False,
    )

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 46 Column: 1

                  )


def test_time_rule_series(raw, series):
    win = 25
    minp = 10
    ser = series[::2].resample("B").mean()
    series_result = ser.rolling(window=win, min_periods=minp).apply(f, raw=raw)
    last_date = series_result.index[-1]

            

Reported by Pylint.

pandas/tests/indexes/numeric/test_astype.py
24 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              import re

import numpy as np
import pytest

from pandas.core.dtypes.common import pandas_dtype

from pandas import (
    Float64Index,

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import re

import numpy as np
import pytest

from pandas.core.dtypes.common import pandas_dtype

from pandas import (
    Float64Index,

            

Reported by Pylint.

Missing class docstring
Error

Line: 16 Column: 1

              import pandas._testing as tm


class TestAstype:
    def test_astype_float64_to_object(self):
        float_index = Float64Index([0.0, 2.5, 5.0, 7.5, 10.0])
        result = float_index.astype(object)
        assert result.equals(float_index)
        assert float_index.equals(result)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 5

              

class TestAstype:
    def test_astype_float64_to_object(self):
        float_index = Float64Index([0.0, 2.5, 5.0, 7.5, 10.0])
        result = float_index.astype(object)
        assert result.equals(float_index)
        assert float_index.equals(result)
        assert isinstance(result, Index) and not isinstance(result, Float64Index)

            

Reported by Pylint.

Method could be a function
Error

Line: 17 Column: 5

              

class TestAstype:
    def test_astype_float64_to_object(self):
        float_index = Float64Index([0.0, 2.5, 5.0, 7.5, 10.0])
        result = float_index.astype(object)
        assert result.equals(float_index)
        assert float_index.equals(result)
        assert isinstance(result, Index) and not isinstance(result, Float64Index)

            

Reported by Pylint.

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

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

                  def test_astype_float64_to_object(self):
        float_index = Float64Index([0.0, 2.5, 5.0, 7.5, 10.0])
        result = float_index.astype(object)
        assert result.equals(float_index)
        assert float_index.equals(result)
        assert isinstance(result, Index) and not isinstance(result, Float64Index)

    def test_astype_float64_mixed_to_object(self):
        # mixed int-float

            

Reported by Bandit.

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

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

                      float_index = Float64Index([0.0, 2.5, 5.0, 7.5, 10.0])
        result = float_index.astype(object)
        assert result.equals(float_index)
        assert float_index.equals(result)
        assert isinstance(result, Index) and not isinstance(result, Float64Index)

    def test_astype_float64_mixed_to_object(self):
        # mixed int-float
        idx = Float64Index([1.5, 2, 3, 4, 5])

            

Reported by Bandit.

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

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

                      result = float_index.astype(object)
        assert result.equals(float_index)
        assert float_index.equals(result)
        assert isinstance(result, Index) and not isinstance(result, Float64Index)

    def test_astype_float64_mixed_to_object(self):
        # mixed int-float
        idx = Float64Index([1.5, 2, 3, 4, 5])
        idx.name = "foo"

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 24 Column: 5

                      assert float_index.equals(result)
        assert isinstance(result, Index) and not isinstance(result, Float64Index)

    def test_astype_float64_mixed_to_object(self):
        # mixed int-float
        idx = Float64Index([1.5, 2, 3, 4, 5])
        idx.name = "foo"
        result = idx.astype(object)
        assert result.equals(idx)

            

Reported by Pylint.

Method could be a function
Error

Line: 24 Column: 5

                      assert float_index.equals(result)
        assert isinstance(result, Index) and not isinstance(result, Float64Index)

    def test_astype_float64_mixed_to_object(self):
        # mixed int-float
        idx = Float64Index([1.5, 2, 3, 4, 5])
        idx.name = "foo"
        result = idx.astype(object)
        assert result.equals(idx)

            

Reported by Pylint.

pandas/tests/io/formats/test_to_markdown.py
24 issues
Unable to import 'pytest'
Error

Line: 3 Column: 1

              from io import StringIO

import pytest

import pandas as pd
import pandas._testing as tm

pytest.importorskip("tabulate")


            

Reported by Pylint.

Unused argument 'capsys'
Error

Line: 62 Column: 17

                  )


def test_no_buf(capsys):
    df = pd.DataFrame([1, 2, 3])
    result = df.to_markdown()
    assert (
        result == "|    |   0 |\n|---:|----:|\n|  0 |   1 |\n|  1 |   2 |\n|  2 |   3 |"
    )

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from io import StringIO

import pytest

import pandas as pd
import pandas._testing as tm

pytest.importorskip("tabulate")


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 11 Column: 1

              pytest.importorskip("tabulate")


def test_simple():
    buf = StringIO()
    df = pd.DataFrame([1, 2, 3])
    df.to_markdown(buf=buf)
    result = buf.getvalue()
    assert (

            

Reported by Pylint.

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

Line: 13 Column: 5

              
def test_simple():
    buf = StringIO()
    df = pd.DataFrame([1, 2, 3])
    df.to_markdown(buf=buf)
    result = buf.getvalue()
    assert (
        result == "|    |   0 |\n|---:|----:|\n|  0 |   1 |\n|  1 |   2 |\n|  2 |   3 |"
    )

            

Reported by Pylint.

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

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

                  df = pd.DataFrame([1, 2, 3])
    df.to_markdown(buf=buf)
    result = buf.getvalue()
    assert (
        result == "|    |   0 |\n|---:|----:|\n|  0 |   1 |\n|  1 |   2 |\n|  2 |   3 |"
    )


def test_empty_frame():

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 21 Column: 1

                  )


def test_empty_frame():
    buf = StringIO()
    df = pd.DataFrame({"id": [], "first_name": [], "last_name": []}).set_index("id")
    df.to_markdown(buf=buf)
    result = buf.getvalue()
    assert result == (

            

Reported by Pylint.

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

Line: 23 Column: 5

              
def test_empty_frame():
    buf = StringIO()
    df = pd.DataFrame({"id": [], "first_name": [], "last_name": []}).set_index("id")
    df.to_markdown(buf=buf)
    result = buf.getvalue()
    assert result == (
        "| id   | first_name   | last_name   |\n"
        "|------|--------------|-------------|"

            

Reported by Pylint.

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

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

                  df = pd.DataFrame({"id": [], "first_name": [], "last_name": []}).set_index("id")
    df.to_markdown(buf=buf)
    result = buf.getvalue()
    assert result == (
        "| id   | first_name   | last_name   |\n"
        "|------|--------------|-------------|"
    )



            

Reported by Bandit.

Missing function or method docstring
Error

Line: 32 Column: 1

                  )


def test_other_tablefmt():
    buf = StringIO()
    df = pd.DataFrame([1, 2, 3])
    df.to_markdown(buf=buf, tablefmt="jira")
    result = buf.getvalue()
    assert result == "||    ||   0 ||\n|  0 |   1 |\n|  1 |   2 |\n|  2 |   3 |"

            

Reported by Pylint.

pandas/tests/util/test_deprecate_kwarg.py
24 issues
Unable to import 'pytest'
Error

Line: 1 Column: 1

              import pytest

from pandas.util._decorators import deprecate_kwarg

import pandas._testing as tm


@deprecate_kwarg("old", "new")
def _f1(new=False):

            

Reported by Pylint.

Unexpected keyword argument 'old' in function call
Error

Line: 41 Column: 16

              @pytest.mark.parametrize("key", list(_f2_mappings.keys()))
def test_dict_deprecate_kwarg(key):
    with tm.assert_produces_warning(FutureWarning):
        assert _f2(old=key) == _f2_mappings[key]


@pytest.mark.parametrize("key", ["bogus", 12345, -1.23])
def test_missing_deprecate_kwarg(key):
    with tm.assert_produces_warning(FutureWarning):

            

Reported by Pylint.

Unexpected keyword argument 'old' in function call
Error

Line: 47 Column: 16

              @pytest.mark.parametrize("key", ["bogus", 12345, -1.23])
def test_missing_deprecate_kwarg(key):
    with tm.assert_produces_warning(FutureWarning):
        assert _f2(old=key) == key


@pytest.mark.parametrize("x", [1, -1.4, 0])
def test_callable_deprecate_kwarg(x):
    with tm.assert_produces_warning(FutureWarning):

            

Reported by Pylint.

Unexpected keyword argument 'old' in function call
Error

Line: 53 Column: 16

              @pytest.mark.parametrize("x", [1, -1.4, 0])
def test_callable_deprecate_kwarg(x):
    with tm.assert_produces_warning(FutureWarning):
        assert _f3(old=x) == _f3_mapping(x)


def test_callable_deprecate_kwarg_fail():
    msg = "((can only|cannot) concatenate)|(must be str)|(Can't convert)"


            

Reported by Pylint.

Unexpected keyword argument 'old' in function call
Error

Line: 60 Column: 9

                  msg = "((can only|cannot) concatenate)|(must be str)|(Can't convert)"

    with pytest.raises(TypeError, match=msg):
        _f3(old="hello")


def test_bad_deprecate_kwarg():
    msg = "mapping from old to new argument values must be dict or callable!"


            

Reported by Pylint.

Unused variable 'f4'
Error

Line: 69 Column: 9

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

        @deprecate_kwarg("old", "new", 0)
        def f4(new=None):
            return new


@deprecate_kwarg("old", None)
def _f4(old=True, unchanged=True):

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import pytest

from pandas.util._decorators import deprecate_kwarg

import pandas._testing as tm


@deprecate_kwarg("old", "new")
def _f1(new=False):

            

Reported by Pylint.

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

Line: 21 Column: 1

                  return new


def _f3_mapping(x):
    return x + 1


@deprecate_kwarg("old", "new", _f3_mapping)
def _f3(new=0):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 31 Column: 1

              

@pytest.mark.parametrize("key,klass", [("old", FutureWarning), ("new", None)])
def test_deprecate_kwarg(key, klass):
    x = 78

    with tm.assert_produces_warning(klass):
        assert _f1(**{key: x}) == x


            

Reported by Pylint.

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

Line: 32 Column: 5

              
@pytest.mark.parametrize("key,klass", [("old", FutureWarning), ("new", None)])
def test_deprecate_kwarg(key, klass):
    x = 78

    with tm.assert_produces_warning(klass):
        assert _f1(**{key: x}) == x



            

Reported by Pylint.

pandas/tests/test_aggregation.py
24 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

from pandas.core.aggregation import (
    _make_unique_kwarg_list,
    maybe_mangle_lambdas,
)



            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

from pandas.core.aggregation import (
    _make_unique_kwarg_list,
    maybe_mangle_lambdas,
)



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 10 Column: 1

              )


def test_maybe_mangle_lambdas_passthrough():
    assert maybe_mangle_lambdas("mean") == "mean"
    assert maybe_mangle_lambdas(lambda x: x).__name__ == "<lambda>"
    # don't mangel single lambda.
    assert maybe_mangle_lambdas([lambda x: x])[0].__name__ == "<lambda>"


            

Reported by Pylint.

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

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

              

def test_maybe_mangle_lambdas_passthrough():
    assert maybe_mangle_lambdas("mean") == "mean"
    assert maybe_mangle_lambdas(lambda x: x).__name__ == "<lambda>"
    # don't mangel single lambda.
    assert maybe_mangle_lambdas([lambda x: x])[0].__name__ == "<lambda>"



            

Reported by Bandit.

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

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

              
def test_maybe_mangle_lambdas_passthrough():
    assert maybe_mangle_lambdas("mean") == "mean"
    assert maybe_mangle_lambdas(lambda x: x).__name__ == "<lambda>"
    # don't mangel single lambda.
    assert maybe_mangle_lambdas([lambda x: x])[0].__name__ == "<lambda>"


def test_maybe_mangle_lambdas_listlike():

            

Reported by Bandit.

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

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

                  assert maybe_mangle_lambdas("mean") == "mean"
    assert maybe_mangle_lambdas(lambda x: x).__name__ == "<lambda>"
    # don't mangel single lambda.
    assert maybe_mangle_lambdas([lambda x: x])[0].__name__ == "<lambda>"


def test_maybe_mangle_lambdas_listlike():
    aggfuncs = [lambda x: 1, lambda x: 2]
    result = maybe_mangle_lambdas(aggfuncs)

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 17 Column: 1

                  assert maybe_mangle_lambdas([lambda x: x])[0].__name__ == "<lambda>"


def test_maybe_mangle_lambdas_listlike():
    aggfuncs = [lambda x: 1, lambda x: 2]
    result = maybe_mangle_lambdas(aggfuncs)
    assert result[0].__name__ == "<lambda_0>"
    assert result[1].__name__ == "<lambda_1>"
    assert aggfuncs[0](None) == result[0](None)

            

Reported by Pylint.

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

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

              def test_maybe_mangle_lambdas_listlike():
    aggfuncs = [lambda x: 1, lambda x: 2]
    result = maybe_mangle_lambdas(aggfuncs)
    assert result[0].__name__ == "<lambda_0>"
    assert result[1].__name__ == "<lambda_1>"
    assert aggfuncs[0](None) == result[0](None)
    assert aggfuncs[1](None) == result[1](None)



            

Reported by Bandit.

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

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

                  aggfuncs = [lambda x: 1, lambda x: 2]
    result = maybe_mangle_lambdas(aggfuncs)
    assert result[0].__name__ == "<lambda_0>"
    assert result[1].__name__ == "<lambda_1>"
    assert aggfuncs[0](None) == result[0](None)
    assert aggfuncs[1](None) == result[1](None)


def test_maybe_mangle_lambdas():

            

Reported by Bandit.

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

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

                  result = maybe_mangle_lambdas(aggfuncs)
    assert result[0].__name__ == "<lambda_0>"
    assert result[1].__name__ == "<lambda_1>"
    assert aggfuncs[0](None) == result[0](None)
    assert aggfuncs[1](None) == result[1](None)


def test_maybe_mangle_lambdas():
    func = {"A": [lambda x: 0, lambda x: 1]}

            

Reported by Bandit.

pandas/tests/series/methods/test_combine_first.py
24 issues
Missing module docstring
Error

Line: 1 Column: 1

              from datetime import datetime

import numpy as np

import pandas as pd
from pandas import (
    Period,
    Series,
    date_range,

            

Reported by Pylint.

Missing class docstring
Error

Line: 16 Column: 1

              import pandas._testing as tm


class TestCombineFirst:
    def test_combine_first_period_datetime(self):
        # GH#3367
        didx = date_range(start="1950-01-31", end="1950-07-31", freq="M")
        pidx = period_range(start=Period("1950-1"), end=Period("1950-7"), freq="M")
        # check to be consistent with DatetimeIndex

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 5

              

class TestCombineFirst:
    def test_combine_first_period_datetime(self):
        # GH#3367
        didx = date_range(start="1950-01-31", end="1950-07-31", freq="M")
        pidx = period_range(start=Period("1950-1"), end=Period("1950-7"), freq="M")
        # check to be consistent with DatetimeIndex
        for idx in [didx, pidx]:

            

Reported by Pylint.

Method could be a function
Error

Line: 17 Column: 5

              

class TestCombineFirst:
    def test_combine_first_period_datetime(self):
        # GH#3367
        didx = date_range(start="1950-01-31", end="1950-07-31", freq="M")
        pidx = period_range(start=Period("1950-1"), end=Period("1950-7"), freq="M")
        # check to be consistent with DatetimeIndex
        for idx in [didx, pidx]:

            

Reported by Pylint.

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

Line: 23 Column: 13

                      pidx = period_range(start=Period("1950-1"), end=Period("1950-7"), freq="M")
        # check to be consistent with DatetimeIndex
        for idx in [didx, pidx]:
            a = Series([1, np.nan, np.nan, 4, 5, np.nan, 7], index=idx)
            b = Series([9, 9, 9, 9, 9, 9, 9], index=idx)

            result = a.combine_first(b)
            expected = Series([1, 9, 9, 4, 5, 9, 7], index=idx, dtype=np.float64)
            tm.assert_series_equal(result, expected)

            

Reported by Pylint.

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

Line: 24 Column: 13

                      # check to be consistent with DatetimeIndex
        for idx in [didx, pidx]:
            a = Series([1, np.nan, np.nan, 4, 5, np.nan, 7], index=idx)
            b = Series([9, 9, 9, 9, 9, 9, 9], index=idx)

            result = a.combine_first(b)
            expected = Series([1, 9, 9, 4, 5, 9, 7], index=idx, dtype=np.float64)
            tm.assert_series_equal(result, expected)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 30 Column: 5

                          expected = Series([1, 9, 9, 4, 5, 9, 7], index=idx, dtype=np.float64)
            tm.assert_series_equal(result, expected)

    def test_combine_first_name(self, datetime_series):
        result = datetime_series.combine_first(datetime_series[:5])
        assert result.name == datetime_series.name

    def test_combine_first(self):
        values = tm.makeIntIndex(20).values.astype(float)

            

Reported by Pylint.

Method could be a function
Error

Line: 30 Column: 5

                          expected = Series([1, 9, 9, 4, 5, 9, 7], index=idx, dtype=np.float64)
            tm.assert_series_equal(result, expected)

    def test_combine_first_name(self, datetime_series):
        result = datetime_series.combine_first(datetime_series[:5])
        assert result.name == datetime_series.name

    def test_combine_first(self):
        values = tm.makeIntIndex(20).values.astype(float)

            

Reported by Pylint.

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

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

              
    def test_combine_first_name(self, datetime_series):
        result = datetime_series.combine_first(datetime_series[:5])
        assert result.name == datetime_series.name

    def test_combine_first(self):
        values = tm.makeIntIndex(20).values.astype(float)
        series = Series(values, index=tm.makeIntIndex(20))


            

Reported by Bandit.

Method could be a function
Error

Line: 34 Column: 5

                      result = datetime_series.combine_first(datetime_series[:5])
        assert result.name == datetime_series.name

    def test_combine_first(self):
        values = tm.makeIntIndex(20).values.astype(float)
        series = Series(values, index=tm.makeIntIndex(20))

        series_copy = series * 2
        series_copy[::2] = np.NaN

            

Reported by Pylint.

pandas/tests/window/moments/test_moments_rolling_functions.py
24 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

from pandas import (
    DataFrame,
    Series,
    concat,
    isna,
    notna,

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

from pandas import (
    DataFrame,
    Series,
    concat,
    isna,
    notna,

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 34 Column: 1

                      [lambda x: np.std(x, ddof=0), "std", {"ddof": 0}],
        [lambda x: np.var(x, ddof=1), "var", {}],
        [lambda x: np.var(x, ddof=0), "var", {"ddof": 0}],
    ],
)
def test_series(series, compare_func, roll_func, kwargs):
    result = getattr(series.rolling(50), roll_func)(**kwargs)
    assert isinstance(result, Series)
    tm.assert_almost_equal(result.iloc[-1], compare_func(series[-50:]))

            

Reported by Pylint.

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

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

              )
def test_series(series, compare_func, roll_func, kwargs):
    result = getattr(series.rolling(50), roll_func)(**kwargs)
    assert isinstance(result, Series)
    tm.assert_almost_equal(result.iloc[-1], compare_func(series[-50:]))


@pytest.mark.parametrize(
    "compare_func, roll_func, kwargs",

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 60 Column: 1

                      [lambda x: np.std(x, ddof=0), "std", {"ddof": 0}],
        [lambda x: np.var(x, ddof=1), "var", {}],
        [lambda x: np.var(x, ddof=0), "var", {"ddof": 0}],
    ],
)
def test_frame(raw, frame, compare_func, roll_func, kwargs):
    result = getattr(frame.rolling(50), roll_func)(**kwargs)
    assert isinstance(result, DataFrame)
    tm.assert_series_equal(

            

Reported by Pylint.

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

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

              )
def test_frame(raw, frame, compare_func, roll_func, kwargs):
    result = getattr(frame.rolling(50), roll_func)(**kwargs)
    assert isinstance(result, DataFrame)
    tm.assert_series_equal(
        result.iloc[-1, :],
        frame.iloc[-50:, :].apply(compare_func, axis=0, raw=raw),
        check_names=False,
    )

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 85 Column: 1

                      [lambda x: np.std(x, ddof=0), "std", {"ddof": 0}, 10],
        [lambda x: np.var(x, ddof=1), "var", {}, 10],
        [lambda x: np.var(x, ddof=0), "var", {"ddof": 0}, 10],
    ],
)
def test_time_rule_series(series, compare_func, roll_func, kwargs, minp):
    win = 25
    ser = series[::2].resample("B").mean()
    series_result = getattr(ser.rolling(window=win, min_periods=minp), roll_func)(

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 113 Column: 1

                      [lambda x: np.std(x, ddof=0), "std", {"ddof": 0}, 10],
        [lambda x: np.var(x, ddof=1), "var", {}, 10],
        [lambda x: np.var(x, ddof=0), "var", {"ddof": 0}, 10],
    ],
)
def test_time_rule_frame(raw, frame, compare_func, roll_func, kwargs, minp):
    win = 25
    frm = frame[::2].resample("B").mean()
    frame_result = getattr(frm.rolling(window=win, min_periods=minp), roll_func)(

            

Reported by Pylint.

Too many arguments (6/5)
Error

Line: 113 Column: 1

                      [lambda x: np.std(x, ddof=0), "std", {"ddof": 0}, 10],
        [lambda x: np.var(x, ddof=1), "var", {}, 10],
        [lambda x: np.var(x, ddof=0), "var", {"ddof": 0}, 10],
    ],
)
def test_time_rule_frame(raw, frame, compare_func, roll_func, kwargs, minp):
    win = 25
    frm = frame[::2].resample("B").mean()
    frame_result = getattr(frm.rolling(window=win, min_periods=minp), roll_func)(

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 144 Column: 1

                      [lambda x: np.std(x, ddof=0), "std", {"ddof": 0}],
        [lambda x: np.var(x, ddof=1), "var", {}],
        [lambda x: np.var(x, ddof=0), "var", {"ddof": 0}],
    ],
)
def test_nans(compare_func, roll_func, kwargs):
    obj = Series(np.random.randn(50))
    obj[:10] = np.NaN
    obj[-10:] = np.NaN

            

Reported by Pylint.

pandas/tests/io/sas/test_xport.py
24 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              import os

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.

Attribute 'dirpath' defined outside __init__
Error

Line: 28 Column: 9

              class TestXport:
    @pytest.fixture(autouse=True)
    def setup_method(self, datapath):
        self.dirpath = datapath("io", "sas", "data")
        self.file01 = os.path.join(self.dirpath, "DEMO_G.xpt")
        self.file02 = os.path.join(self.dirpath, "SSHSV1_A.xpt")
        self.file03 = os.path.join(self.dirpath, "DRXFCD_G.xpt")
        self.file04 = os.path.join(self.dirpath, "paxraw_d_short.xpt")


            

Reported by Pylint.

Attribute 'file01' defined outside __init__
Error

Line: 29 Column: 9

                  @pytest.fixture(autouse=True)
    def setup_method(self, datapath):
        self.dirpath = datapath("io", "sas", "data")
        self.file01 = os.path.join(self.dirpath, "DEMO_G.xpt")
        self.file02 = os.path.join(self.dirpath, "SSHSV1_A.xpt")
        self.file03 = os.path.join(self.dirpath, "DRXFCD_G.xpt")
        self.file04 = os.path.join(self.dirpath, "paxraw_d_short.xpt")

        with td.file_leak_context():

            

Reported by Pylint.

Attribute 'file02' defined outside __init__
Error

Line: 30 Column: 9

                  def setup_method(self, datapath):
        self.dirpath = datapath("io", "sas", "data")
        self.file01 = os.path.join(self.dirpath, "DEMO_G.xpt")
        self.file02 = os.path.join(self.dirpath, "SSHSV1_A.xpt")
        self.file03 = os.path.join(self.dirpath, "DRXFCD_G.xpt")
        self.file04 = os.path.join(self.dirpath, "paxraw_d_short.xpt")

        with td.file_leak_context():
            yield

            

Reported by Pylint.

Attribute 'file03' defined outside __init__
Error

Line: 31 Column: 9

                      self.dirpath = datapath("io", "sas", "data")
        self.file01 = os.path.join(self.dirpath, "DEMO_G.xpt")
        self.file02 = os.path.join(self.dirpath, "SSHSV1_A.xpt")
        self.file03 = os.path.join(self.dirpath, "DRXFCD_G.xpt")
        self.file04 = os.path.join(self.dirpath, "paxraw_d_short.xpt")

        with td.file_leak_context():
            yield


            

Reported by Pylint.

Attribute 'file04' defined outside __init__
Error

Line: 32 Column: 9

                      self.file01 = os.path.join(self.dirpath, "DEMO_G.xpt")
        self.file02 = os.path.join(self.dirpath, "SSHSV1_A.xpt")
        self.file03 = os.path.join(self.dirpath, "DRXFCD_G.xpt")
        self.file04 = os.path.join(self.dirpath, "paxraw_d_short.xpt")

        with td.file_leak_context():
            yield

    @pytest.mark.slow

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import os

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.

Missing function or method docstring
Error

Line: 19 Column: 1

              # before making comparisons.


def numeric_as_float(data):
    for v in data.columns:
        if data[v].dtype is np.dtype("int64"):
            data[v] = data[v].astype(np.float64)



            

Reported by Pylint.

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

Line: 20 Column: 9

              

def numeric_as_float(data):
    for v in data.columns:
        if data[v].dtype is np.dtype("int64"):
            data[v] = data[v].astype(np.float64)


class TestXport:

            

Reported by Pylint.

Missing class docstring
Error

Line: 25 Column: 1

                          data[v] = data[v].astype(np.float64)


class TestXport:
    @pytest.fixture(autouse=True)
    def setup_method(self, datapath):
        self.dirpath = datapath("io", "sas", "data")
        self.file01 = os.path.join(self.dirpath, "DEMO_G.xpt")
        self.file02 = os.path.join(self.dirpath, "SSHSV1_A.xpt")

            

Reported by Pylint.

pandas/tests/io/pytables/test_complex.py
24 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              from warnings import catch_warnings

import numpy as np
import pytest

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

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from warnings import catch_warnings

import numpy as np
import pytest

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

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 20 Column: 1

              from pandas.io.pytables import read_hdf


def test_complex_fixed(setup_path):
    df = DataFrame(
        np.random.rand(4, 5).astype(np.complex64),
        index=list("abcd"),
        columns=list("ABCDE"),
    )

            

Reported by Pylint.

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

Line: 21 Column: 5

              

def test_complex_fixed(setup_path):
    df = DataFrame(
        np.random.rand(4, 5).astype(np.complex64),
        index=list("abcd"),
        columns=list("ABCDE"),
    )


            

Reported by Pylint.

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

Line: 32 Column: 5

                      reread = read_hdf(path, "df")
        tm.assert_frame_equal(df, reread)

    df = DataFrame(
        np.random.rand(4, 5).astype(np.complex128),
        index=list("abcd"),
        columns=list("ABCDE"),
    )
    with ensure_clean_path(setup_path) as path:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 43 Column: 1

                      tm.assert_frame_equal(df, reread)


def test_complex_table(setup_path):
    df = DataFrame(
        np.random.rand(4, 5).astype(np.complex64),
        index=list("abcd"),
        columns=list("ABCDE"),
    )

            

Reported by Pylint.

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

Line: 44 Column: 5

              

def test_complex_table(setup_path):
    df = DataFrame(
        np.random.rand(4, 5).astype(np.complex64),
        index=list("abcd"),
        columns=list("ABCDE"),
    )


            

Reported by Pylint.

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

Line: 55 Column: 5

                      reread = read_hdf(path, "df")
        tm.assert_frame_equal(df, reread)

    df = DataFrame(
        np.random.rand(4, 5).astype(np.complex128),
        index=list("abcd"),
        columns=list("ABCDE"),
    )


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 67 Column: 1

                      tm.assert_frame_equal(df, reread)


def test_complex_mixed_fixed(setup_path):
    complex64 = np.array(
        [1.0 + 1.0j, 1.0 + 1.0j, 1.0 + 1.0j, 1.0 + 1.0j], dtype=np.complex64
    )
    complex128 = np.array(
        [1.0 + 1.0j, 1.0 + 1.0j, 1.0 + 1.0j, 1.0 + 1.0j], dtype=np.complex128

            

Reported by Pylint.

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

Line: 74 Column: 5

                  complex128 = np.array(
        [1.0 + 1.0j, 1.0 + 1.0j, 1.0 + 1.0j, 1.0 + 1.0j], dtype=np.complex128
    )
    df = DataFrame(
        {
            "A": [1, 2, 3, 4],
            "B": ["a", "b", "c", "d"],
            "C": complex64,
            "D": complex128,

            

Reported by Pylint.

pandas/tests/tseries/offsets/test_business_year.py
24 issues
Unable to import 'pytest'
Error

Line: 8 Column: 1

              """
from datetime import datetime

import pytest

from pandas.tests.tseries.offsets.common import (
    Base,
    assert_is_on_offset,
    assert_offset_equal,

            

Reported by Pylint.

Missing class docstring
Error

Line: 22 Column: 1

              )


class TestBYearBegin(Base):
    _offset = BYearBegin

    def test_misspecified(self):
        msg = "Month must go from 1 to 12"
        with pytest.raises(ValueError, match=msg):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 25 Column: 5

              class TestBYearBegin(Base):
    _offset = BYearBegin

    def test_misspecified(self):
        msg = "Month must go from 1 to 12"
        with pytest.raises(ValueError, match=msg):
            BYearBegin(month=13)
        with pytest.raises(ValueError, match=msg):
            BYearEnd(month=13)

            

Reported by Pylint.

Method could be a function
Error

Line: 25 Column: 5

              class TestBYearBegin(Base):
    _offset = BYearBegin

    def test_misspecified(self):
        msg = "Month must go from 1 to 12"
        with pytest.raises(ValueError, match=msg):
            BYearBegin(month=13)
        with pytest.raises(ValueError, match=msg):
            BYearEnd(month=13)

            

Reported by Pylint.

Method could be a function
Error

Line: 89 Column: 5

                  )

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



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 89 Column: 5

                  )

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



            

Reported by Pylint.

Missing class docstring
Error

Line: 95 Column: 1

                          assert_offset_equal(offset, base, expected)


class TestBYearEnd(Base):
    _offset = BYearEnd

    offset_cases = []
    offset_cases.append(
        (

            

Reported by Pylint.

Method could be a function
Error

Line: 150 Column: 5

                  )

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

    on_offset_cases = [

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 150 Column: 5

                  )

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

    on_offset_cases = [

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 163 Column: 5

                  ]

    @pytest.mark.parametrize("case", on_offset_cases)
    def test_is_on_offset(self, case):
        offset, dt, expected = case
        assert_is_on_offset(offset, dt, expected)


class TestBYearEndLagged(Base):

            

Reported by Pylint.