The following issues were found

pandas/tests/apply/test_invalid_arg.py
46 issues
Unable to import 'pytest'
Error

Line: 13 Column: 1

              import re

import numpy as np
import pytest

from pandas import (
    Categorical,
    DataFrame,
    Series,

            

Reported by Pylint.

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

Line: 77 Column: 14

              

def test_map_datetimetz_na_action():
    values = date_range("2011-01-01", "2011-01-02", freq="H").tz_localize("Asia/Tokyo")
    s = Series(values, name="XX")
    with pytest.raises(NotImplementedError, match=tm.EMPTY_STRING_PATTERN):
        s.map(lambda x: x, na_action="ignore")



            

Reported by Pylint.

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

Line: 77 Column: 14

              

def test_map_datetimetz_na_action():
    values = date_range("2011-01-01", "2011-01-02", freq="H").tz_localize("Asia/Tokyo")
    s = Series(values, name="XX")
    with pytest.raises(NotImplementedError, match=tm.EMPTY_STRING_PATTERN):
        s.map(lambda x: x, na_action="ignore")



            

Reported by Pylint.

Unused variable 'transform2'
Error

Line: 219 Column: 5

                          row["D"] = 7
        return row

    def transform2(row):
        if notna(row["C"]) and row["C"].startswith("shin") and row["A"] == "foo":
            row["D"] = 7
        return row

    msg = "'float' object has no attribute 'startswith'"

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # Tests specifically aimed at detecting bad arguments.
# This file is organized by reason for exception.
#     1. always invalid argument values
#     2. missing column(s)
#     3. incompatible ops/dtype/args/kwargs
#     4. invalid result shape/type
# If your test does not fit into one of these categories, add to this list.

from itertools import chain

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 27 Column: 1

              

@pytest.mark.parametrize("result_type", ["foo", 1])
def test_result_type_error(result_type, int_frame_const_col):
    # allowed result_type
    df = int_frame_const_col

    msg = (
        "invalid value for result_type, must be one of "

            

Reported by Pylint.

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

Line: 29 Column: 5

              @pytest.mark.parametrize("result_type", ["foo", 1])
def test_result_type_error(result_type, int_frame_const_col):
    # allowed result_type
    df = int_frame_const_col

    msg = (
        "invalid value for result_type, must be one of "
        "{None, 'reduce', 'broadcast', 'expand'}"
    )

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 39 Column: 1

                      df.apply(lambda x: [1, 2, 3], axis=1, result_type=result_type)


def test_apply_invalid_axis_value():
    df = DataFrame([[1, 2, 3], [4, 5, 6], [7, 8, 9]], index=["a", "a", "c"])
    msg = "No axis named 2 for object type DataFrame"
    with pytest.raises(ValueError, match=msg):
        df.apply(lambda x: x, 2)


            

Reported by Pylint.

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

Line: 40 Column: 5

              

def test_apply_invalid_axis_value():
    df = DataFrame([[1, 2, 3], [4, 5, 6], [7, 8, 9]], index=["a", "a", "c"])
    msg = "No axis named 2 for object type DataFrame"
    with pytest.raises(ValueError, match=msg):
        df.apply(lambda x: x, 2)



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 46 Column: 1

                      df.apply(lambda x: x, 2)


def test_applymap_invalid_na_action(float_frame):
    # GH 23803
    with pytest.raises(ValueError, match="na_action must be .*Got 'abc'"):
        float_frame.applymap(lambda x: len(str(x)), na_action="abc")



            

Reported by Pylint.

pandas/tests/api/test_api.py
46 issues
Unable to import 'pytest'
Error

Line: 6 Column: 1

              import subprocess
import sys

import pytest

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


            

Reported by Pylint.

Unused import pandas.util.testing
Error

Line: 287 Column: 13

                      sys.modules.pop("pandas.util.testing", None)

        with tm.assert_produces_warning(FutureWarning) as m:
            import pandas.util.testing  # noqa: F401

        assert "pandas.util.testing is deprecated" in str(m[0].message)
        assert "pandas.testing instead" in str(m[0].message)

    def test_util_testing_deprecated_direct(self):

            

Reported by Pylint.

Unused assert_series_equal imported from pandas.util.testing
Error

Line: 296 Column: 13

                      # avoid cache state affecting the test
        sys.modules.pop("pandas.util.testing", None)
        with tm.assert_produces_warning(FutureWarning) as m:
            from pandas.util.testing import assert_series_equal  # noqa: F401

        assert "pandas.util.testing is deprecated" in str(m[0].message)
        assert "pandas.testing instead" in str(m[0].message)

    def test_util_in_top_level(self):

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 314 Column: 13

                      assert "pandas.util.testing is deprecated" in out

        with pytest.raises(AttributeError, match="foo"):
            pd.util.foo

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from __future__ import annotations

import subprocess
import sys

import pytest

import pandas as pd
from pandas import api

            

Reported by Pylint.

Consider possible security implications associated with subprocess module.
Security blacklist

Line: 3
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess

              from __future__ import annotations

import subprocess
import sys

import pytest

import pandas as pd
from pandas import api

            

Reported by Bandit.

Missing class docstring
Error

Line: 13 Column: 1

              import pandas._testing as tm


class Base:
    def check(self, namespace, expected, ignored=None):
        # see which names are in the namespace, minus optional
        # ignored ones
        # compare vs the expected


            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 13 Column: 1

              import pandas._testing as tm


class Base:
    def check(self, namespace, expected, ignored=None):
        # see which names are in the namespace, minus optional
        # ignored ones
        # compare vs the expected


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 14 Column: 5

              

class Base:
    def check(self, namespace, expected, ignored=None):
        # see which names are in the namespace, minus optional
        # ignored ones
        # compare vs the expected

        result = sorted(f for f in dir(namespace) if not f.startswith("__"))

            

Reported by Pylint.

Method could be a function
Error

Line: 14 Column: 5

              

class Base:
    def check(self, namespace, expected, ignored=None):
        # see which names are in the namespace, minus optional
        # ignored ones
        # compare vs the expected

        result = sorted(f for f in dir(namespace) if not f.startswith("__"))

            

Reported by Pylint.

pandas/tests/tools/test_to_timedelta.py
46 issues
Unable to import 'pytest'
Error

Line: 7 Column: 1

              )

import numpy as np
import pytest

from pandas.errors import OutOfBoundsTimedelta

import pandas as pd
from pandas import (

            

Reported by Pylint.

Access to a protected member _from_sequence of a client class
Error

Line: 92 Column: 13

                          TimedeltaIndex(arr)

        with pytest.raises(OutOfBoundsTimedelta, match=msg):
            TimedeltaArray._from_sequence(arr)

    def test_to_timedelta_dataframe(self):
        # GH 11776
        arr = np.arange(10).reshape(2, 5)
        df = pd.DataFrame(np.arange(10).reshape(2, 5))

            

Reported by Pylint.

Redefining built-in 'input'
Error

Line: 264 Column: 54

                      ],
    )
    @pytest.mark.parametrize("func", [pd.Timedelta, to_timedelta])
    def test_to_timedelta_precision_over_nanos(self, input, expected, func):
        # GH: 36738
        expected = pd.Timedelta(expected)
        result = func(input)
        assert result == expected


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from datetime import (
    time,
    timedelta,
)

import numpy as np
import pytest

from pandas.errors import OutOfBoundsTimedelta

            

Reported by Pylint.

Missing class docstring
Error

Line: 22 Column: 1

              from pandas.core.arrays import TimedeltaArray


class TestTimedeltas:
    @pytest.mark.parametrize("readonly", [True, False])
    def test_to_timedelta_readonly(self, readonly):
        # GH#34857
        arr = np.array([], dtype=object)
        if readonly:

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 24 Column: 5

              
class TestTimedeltas:
    @pytest.mark.parametrize("readonly", [True, False])
    def test_to_timedelta_readonly(self, readonly):
        # GH#34857
        arr = np.array([], dtype=object)
        if readonly:
            arr.setflags(write=False)
        result = to_timedelta(arr)

            

Reported by Pylint.

Method could be a function
Error

Line: 24 Column: 5

              
class TestTimedeltas:
    @pytest.mark.parametrize("readonly", [True, False])
    def test_to_timedelta_readonly(self, readonly):
        # GH#34857
        arr = np.array([], dtype=object)
        if readonly:
            arr.setflags(write=False)
        result = to_timedelta(arr)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 33 Column: 5

                      expected = to_timedelta([])
        tm.assert_index_equal(result, expected)

    def test_to_timedelta(self):

        result = to_timedelta(["", ""])
        assert isna(result).all()

        # pass thru

            

Reported by Pylint.

Method could be a function
Error

Line: 33 Column: 5

                      expected = to_timedelta([])
        tm.assert_index_equal(result, expected)

    def test_to_timedelta(self):

        result = to_timedelta(["", ""])
        assert isna(result).all()

        # pass thru

            

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

                  def test_to_timedelta(self):

        result = to_timedelta(["", ""])
        assert isna(result).all()

        # pass thru
        result = to_timedelta(np.array([np.timedelta64(1, "s")]))
        expected = pd.Index(np.array([np.timedelta64(1, "s")]))
        tm.assert_index_equal(result, expected)

            

Reported by Bandit.

asv_bench/benchmarks/period.py
46 issues
Unable to import 'pandas'
Error

Line: 5 Column: 1

              Period benchmarks with non-tslibs dependencies.  See
benchmarks.tslibs.period for benchmarks that rely only on tslibs.
"""
from pandas import (
    DataFrame,
    Period,
    PeriodIndex,
    Series,
    date_range,

            

Reported by Pylint.

Unable to import 'pandas.tseries.frequencies'
Error

Line: 14 Column: 1

                  period_range,
)

from pandas.tseries.frequencies import to_offset


class PeriodIndexConstructor:

    params = [["D"], [True, False]]

            

Reported by Pylint.

Attribute 'rng' defined outside __init__
Error

Line: 23 Column: 9

                  param_names = ["freq", "is_offset"]

    def setup(self, freq, is_offset):
        self.rng = date_range("1985", periods=1000)
        self.rng2 = date_range("1985", periods=1000).to_pydatetime()
        self.ints = list(range(2000, 3000))
        self.daily_ints = (
            date_range("1/1/2000", periods=1000, freq=freq).strftime("%Y%m%d").map(int)
        )

            

Reported by Pylint.

Attribute 'rng2' defined outside __init__
Error

Line: 24 Column: 9

              
    def setup(self, freq, is_offset):
        self.rng = date_range("1985", periods=1000)
        self.rng2 = date_range("1985", periods=1000).to_pydatetime()
        self.ints = list(range(2000, 3000))
        self.daily_ints = (
            date_range("1/1/2000", periods=1000, freq=freq).strftime("%Y%m%d").map(int)
        )
        if is_offset:

            

Reported by Pylint.

Attribute 'ints' defined outside __init__
Error

Line: 25 Column: 9

                  def setup(self, freq, is_offset):
        self.rng = date_range("1985", periods=1000)
        self.rng2 = date_range("1985", periods=1000).to_pydatetime()
        self.ints = list(range(2000, 3000))
        self.daily_ints = (
            date_range("1/1/2000", periods=1000, freq=freq).strftime("%Y%m%d").map(int)
        )
        if is_offset:
            self.freq = to_offset(freq)

            

Reported by Pylint.

Attribute 'daily_ints' defined outside __init__
Error

Line: 26 Column: 9

                      self.rng = date_range("1985", periods=1000)
        self.rng2 = date_range("1985", periods=1000).to_pydatetime()
        self.ints = list(range(2000, 3000))
        self.daily_ints = (
            date_range("1/1/2000", periods=1000, freq=freq).strftime("%Y%m%d").map(int)
        )
        if is_offset:
            self.freq = to_offset(freq)
        else:

            

Reported by Pylint.

Attribute 'freq' defined outside __init__
Error

Line: 30 Column: 13

                          date_range("1/1/2000", periods=1000, freq=freq).strftime("%Y%m%d").map(int)
        )
        if is_offset:
            self.freq = to_offset(freq)
        else:
            self.freq = freq

    def time_from_date_range(self, freq, is_offset):
        PeriodIndex(self.rng, freq=freq)

            

Reported by Pylint.

Attribute 'freq' defined outside __init__
Error

Line: 32 Column: 13

                      if is_offset:
            self.freq = to_offset(freq)
        else:
            self.freq = freq

    def time_from_date_range(self, freq, is_offset):
        PeriodIndex(self.rng, freq=freq)

    def time_from_pydatetime(self, freq, is_offset):

            

Reported by Pylint.

Unused argument 'is_offset'
Error

Line: 34 Column: 42

                      else:
            self.freq = freq

    def time_from_date_range(self, freq, is_offset):
        PeriodIndex(self.rng, freq=freq)

    def time_from_pydatetime(self, freq, is_offset):
        PeriodIndex(self.rng2, freq=freq)


            

Reported by Pylint.

Unused argument 'is_offset'
Error

Line: 37 Column: 42

                  def time_from_date_range(self, freq, is_offset):
        PeriodIndex(self.rng, freq=freq)

    def time_from_pydatetime(self, freq, is_offset):
        PeriodIndex(self.rng2, freq=freq)

    def time_from_ints(self, freq, is_offset):
        PeriodIndex(self.ints, freq=freq)


            

Reported by Pylint.

asv_bench/benchmarks/index_cached_properties.py
46 issues
Unable to import 'pandas'
Error

Line: 1 Column: 1

              import pandas as pd


class IndexCache:
    number = 1
    repeat = (3, 100, 20)

    params = [
        [

            

Reported by Pylint.

Attribute 'idx' defined outside __init__
Error

Line: 27 Column: 13

                  def setup(self, index_type):
        N = 10 ** 5
        if index_type == "MultiIndex":
            self.idx = pd.MultiIndex.from_product(
                [pd.date_range("1/1/2000", freq="T", periods=N // 2), ["a", "b"]]
            )
        elif index_type == "DatetimeIndex":
            self.idx = pd.date_range("1/1/2000", freq="T", periods=N)
        elif index_type == "Int64Index":

            

Reported by Pylint.

Attribute 'idx' defined outside __init__
Error

Line: 31 Column: 13

                              [pd.date_range("1/1/2000", freq="T", periods=N // 2), ["a", "b"]]
            )
        elif index_type == "DatetimeIndex":
            self.idx = pd.date_range("1/1/2000", freq="T", periods=N)
        elif index_type == "Int64Index":
            self.idx = pd.Index(range(N))
        elif index_type == "PeriodIndex":
            self.idx = pd.period_range("1/1/2000", freq="T", periods=N)
        elif index_type == "RangeIndex":

            

Reported by Pylint.

Attribute 'idx' defined outside __init__
Error

Line: 33 Column: 13

                      elif index_type == "DatetimeIndex":
            self.idx = pd.date_range("1/1/2000", freq="T", periods=N)
        elif index_type == "Int64Index":
            self.idx = pd.Index(range(N))
        elif index_type == "PeriodIndex":
            self.idx = pd.period_range("1/1/2000", freq="T", periods=N)
        elif index_type == "RangeIndex":
            self.idx = pd.RangeIndex(start=0, stop=N)
        elif index_type == "IntervalIndex":

            

Reported by Pylint.

Attribute 'idx' defined outside __init__
Error

Line: 35 Column: 13

                      elif index_type == "Int64Index":
            self.idx = pd.Index(range(N))
        elif index_type == "PeriodIndex":
            self.idx = pd.period_range("1/1/2000", freq="T", periods=N)
        elif index_type == "RangeIndex":
            self.idx = pd.RangeIndex(start=0, stop=N)
        elif index_type == "IntervalIndex":
            self.idx = pd.IntervalIndex.from_arrays(range(N), range(1, N + 1))
        elif index_type == "TimedeltaIndex":

            

Reported by Pylint.

Attribute 'idx' defined outside __init__
Error

Line: 37 Column: 13

                      elif index_type == "PeriodIndex":
            self.idx = pd.period_range("1/1/2000", freq="T", periods=N)
        elif index_type == "RangeIndex":
            self.idx = pd.RangeIndex(start=0, stop=N)
        elif index_type == "IntervalIndex":
            self.idx = pd.IntervalIndex.from_arrays(range(N), range(1, N + 1))
        elif index_type == "TimedeltaIndex":
            self.idx = pd.TimedeltaIndex(range(N))
        elif index_type == "Float64Index":

            

Reported by Pylint.

Attribute 'idx' defined outside __init__
Error

Line: 39 Column: 13

                      elif index_type == "RangeIndex":
            self.idx = pd.RangeIndex(start=0, stop=N)
        elif index_type == "IntervalIndex":
            self.idx = pd.IntervalIndex.from_arrays(range(N), range(1, N + 1))
        elif index_type == "TimedeltaIndex":
            self.idx = pd.TimedeltaIndex(range(N))
        elif index_type == "Float64Index":
            self.idx = pd.Float64Index(range(N))
        elif index_type == "UInt64Index":

            

Reported by Pylint.

Attribute 'idx' defined outside __init__
Error

Line: 41 Column: 13

                      elif index_type == "IntervalIndex":
            self.idx = pd.IntervalIndex.from_arrays(range(N), range(1, N + 1))
        elif index_type == "TimedeltaIndex":
            self.idx = pd.TimedeltaIndex(range(N))
        elif index_type == "Float64Index":
            self.idx = pd.Float64Index(range(N))
        elif index_type == "UInt64Index":
            self.idx = pd.UInt64Index(range(N))
        elif index_type == "CategoricalIndex":

            

Reported by Pylint.

Attribute 'idx' defined outside __init__
Error

Line: 43 Column: 13

                      elif index_type == "TimedeltaIndex":
            self.idx = pd.TimedeltaIndex(range(N))
        elif index_type == "Float64Index":
            self.idx = pd.Float64Index(range(N))
        elif index_type == "UInt64Index":
            self.idx = pd.UInt64Index(range(N))
        elif index_type == "CategoricalIndex":
            self.idx = pd.CategoricalIndex(range(N), range(N))
        else:

            

Reported by Pylint.

Attribute 'idx' defined outside __init__
Error

Line: 45 Column: 13

                      elif index_type == "Float64Index":
            self.idx = pd.Float64Index(range(N))
        elif index_type == "UInt64Index":
            self.idx = pd.UInt64Index(range(N))
        elif index_type == "CategoricalIndex":
            self.idx = pd.CategoricalIndex(range(N), range(N))
        else:
            raise ValueError
        assert len(self.idx) == N

            

Reported by Pylint.

pandas/tests/groupby/aggregate/test_cython.py
45 issues
Unable to import 'pytest'
Error

Line: 6 Column: 1

              """

import numpy as np
import pytest

from pandas.core.dtypes.common import is_float_dtype

import pandas as pd
from pandas import (

            

Reported by Pylint.

Access to a protected member _cython_agg_general of a client class
Error

Line: 175 Column: 14

                  df = DataFrame(np.random.randn(1000))
    labels = np.random.randint(0, 50, size=1000).astype(float)

    result = df.groupby(labels)._cython_agg_general(op, alt=None, numeric_only=True)
    expected = df.groupby(labels).agg(targop)
    tm.assert_frame_equal(result, expected)


@pytest.mark.parametrize(

            

Reported by Pylint.

Access to a protected member _cython_agg_general of a client class
Error

Line: 197 Column: 14

                  # calling _cython_agg_general directly, instead of via the user API
    # which sets different values for min_count, so do that here.
    g = df.groupby(pd.cut(df[0], grps), observed=observed)
    result = g._cython_agg_general(op, alt=None, numeric_only=True)

    g = df.groupby(pd.cut(df[0], grps), observed=observed)
    expected = g.agg(lambda x: targop(x))
    tm.assert_frame_equal(result, expected)


            

Reported by Pylint.

Lambda may not be necessary
Error

Line: 200 Column: 22

                  result = g._cython_agg_general(op, alt=None, numeric_only=True)

    g = df.groupby(pd.cut(df[0], grps), observed=observed)
    expected = g.agg(lambda x: targop(x))
    tm.assert_frame_equal(result, expected)


def test_cython_agg_empty_buckets_nanops(observed):
    # GH-18869 can't call nanops on empty groups, so hardcode expected

            

Reported by Pylint.

Access to a protected member _cython_agg_general of a client class
Error

Line: 210 Column: 14

                  df = DataFrame([11, 12, 13], columns=["a"])
    grps = range(0, 25, 5)
    # add / sum
    result = df.groupby(pd.cut(df["a"], grps), observed=observed)._cython_agg_general(
        "add", alt=None, numeric_only=True
    )
    intervals = pd.interval_range(0, 20, freq=5)
    expected = DataFrame(
        {"a": [0, 0, 36, 0]},

            

Reported by Pylint.

Access to a protected member _cython_agg_general of a client class
Error

Line: 224 Column: 14

                  tm.assert_frame_equal(result, expected)

    # prod
    result = df.groupby(pd.cut(df["a"], grps), observed=observed)._cython_agg_general(
        "prod", alt=None, numeric_only=True
    )
    expected = DataFrame(
        {"a": [1, 1, 1716, 1]},
        index=pd.CategoricalIndex(intervals, name="a", ordered=True),

            

Reported by Pylint.

Access to a protected member _mgr of a client class
Error

Line: 286 Column: 5

                          "species": ["setosa", "setosa", "setosa", "setosa", "setosa"],
        }
    )
    df._mgr.arrays[0].flags.writeable = False

    result = df.groupby(["species"]).agg({"sepal_length": agg})
    expected = df.copy().groupby(["species"]).agg({"sepal_length": agg})

    tm.assert_equal(result, expected)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 41 Column: 1

                      "prod",
        "min",
        "max",
    ],
)
def test_cythonized_aggers(op_name):
    data = {
        "A": [0, 0, 0, 0, 1, 1, 1, 1, 1, 1.0, np.nan, np.nan],
        "B": ["A", "B"] * 6,

            

Reported by Pylint.

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

Line: 49 Column: 5

                      "B": ["A", "B"] * 6,
        "C": np.random.randn(12),
    }
    df = DataFrame(data)
    df.loc[2:10:2, "C"] = np.nan

    op = lambda x: getattr(x, op_name)()

    # single column

            

Reported by Pylint.

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

Line: 52 Column: 5

                  df = DataFrame(data)
    df.loc[2:10:2, "C"] = np.nan

    op = lambda x: getattr(x, op_name)()

    # single column
    grouped = df.drop(["B"], axis=1).groupby("A")
    exp = {cat: op(group["C"]) for cat, group in grouped}
    exp = DataFrame({"C": exp})

            

Reported by Pylint.

pandas/tests/libs/test_join.py
45 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

from pandas._libs import join as libjoin
from pandas._libs.join import (
    inner_join,
    left_outer_join,
)


            

Reported by Pylint.

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

Line: 4 Column: 1

              import numpy as np
import pytest

from pandas._libs import join as libjoin
from pandas._libs.join import (
    inner_join,
    left_outer_join,
)


            

Reported by Pylint.

Unable to import 'pandas._libs.join'
Error

Line: 5 Column: 1

              import pytest

from pandas._libs import join as libjoin
from pandas._libs.join import (
    inner_join,
    left_outer_join,
)

import pandas._testing as tm

            

Reported by Pylint.

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

Line: 5 Column: 1

              import pytest

from pandas._libs import join as libjoin
from pandas._libs.join import (
    inner_join,
    left_outer_join,
)

import pandas._testing as tm

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

from pandas._libs import join as libjoin
from pandas._libs.join import (
    inner_join,
    left_outer_join,
)


            

Reported by Pylint.

Missing class docstring
Error

Line: 13 Column: 1

              import pandas._testing as tm


class TestIndexer:
    @pytest.mark.parametrize(
        "dtype", ["int32", "int64", "float32", "float64", "object"]
    )
    def test_outer_join_indexer(self, dtype):
        indexer = libjoin.outer_join_indexer

            

Reported by Pylint.

Method could be a function
Error

Line: 16 Column: 5

              class TestIndexer:
    @pytest.mark.parametrize(
        "dtype", ["int32", "int64", "float32", "float64", "object"]
    )
    def test_outer_join_indexer(self, dtype):
        indexer = libjoin.outer_join_indexer

        left = np.arange(3, dtype=dtype)
        right = np.arange(2, 5, dtype=dtype)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 16 Column: 5

              class TestIndexer:
    @pytest.mark.parametrize(
        "dtype", ["int32", "int64", "float32", "float64", "object"]
    )
    def test_outer_join_indexer(self, dtype):
        indexer = libjoin.outer_join_indexer

        left = np.arange(3, dtype=dtype)
        right = np.arange(2, 5, dtype=dtype)

            

Reported by Pylint.

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

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

                      empty = np.array([], dtype=dtype)

        result, lindexer, rindexer = indexer(left, right)
        assert isinstance(result, np.ndarray)
        assert isinstance(lindexer, np.ndarray)
        assert isinstance(rindexer, np.ndarray)
        tm.assert_numpy_array_equal(result, np.arange(5, dtype=dtype))
        exp = np.array([0, 1, 2, -1, -1], dtype=np.intp)
        tm.assert_numpy_array_equal(lindexer, exp)

            

Reported by Bandit.

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

              
        result, lindexer, rindexer = indexer(left, right)
        assert isinstance(result, np.ndarray)
        assert isinstance(lindexer, np.ndarray)
        assert isinstance(rindexer, np.ndarray)
        tm.assert_numpy_array_equal(result, np.arange(5, dtype=dtype))
        exp = np.array([0, 1, 2, -1, -1], dtype=np.intp)
        tm.assert_numpy_array_equal(lindexer, exp)
        exp = np.array([-1, -1, 0, 1, 2], dtype=np.intp)

            

Reported by Bandit.

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

Line: 10 Column: 1

              """
from datetime import datetime

import pytest

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

            

Reported by Pylint.

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

Line: 13 Column: 1

              import pytest

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

            

Reported by Pylint.

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

Line: 13 Column: 1

              import pytest

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

            

Reported by Pylint.

Missing class docstring
Error

Line: 33 Column: 1

              )


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

    def test_offset_whole_year(self):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 38 Column: 5

                  offset1 = _offset()
    offset2 = _offset(2)

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

            

Reported by Pylint.

Method could be a function
Error

Line: 38 Column: 5

                  offset1 = _offset()
    offset2 = _offset(2)

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

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 211 Column: 5

                  )

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

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

            

Reported by Pylint.

Method could be a function
Error

Line: 211 Column: 5

                  )

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

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

            

Reported by Pylint.

Method could be a function
Error

Line: 217 Column: 5

                          assert_offset_equal(offset, base, expected)

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


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 217 Column: 5

                          assert_offset_equal(offset, base, expected)

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


            

Reported by Pylint.

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

Line: 4 Column: 1

              import math

import numpy as np
import pytest

import pandas.util._test_decorators as td

import pandas as pd
from pandas import (

            

Reported by Pylint.

Unable to import 'scipy.stats'
Error

Line: 61 Column: 9

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

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

        # partial overlap

            

Reported by Pylint.

Unable to import 'scipy.stats'
Error

Line: 91 Column: 9

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

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

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import math

import numpy as np
import pytest

import pandas.util._test_decorators as td

import pandas as pd
from pandas import (

            

Reported by Pylint.

Missing class docstring
Error

Line: 16 Column: 1

              import pandas._testing as tm


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

            

Reported by Pylint.

Method could be a function
Error

Line: 17 Column: 5

              

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


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 5

              

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


            

Reported by Pylint.

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

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

                      )

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

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

            

Reported by Bandit.

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

Line: 33 Column: 9

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

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

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

            

Reported by Pylint.

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

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

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

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

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

            

Reported by Bandit.

pandas/tests/frame/methods/test_asof.py
45 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

from pandas._libs.tslibs import IncompatibleFrequency

from pandas import (
    DataFrame,
    Period,
    Series,

            

Reported by Pylint.

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

Line: 31 Column: 26

              

class TestFrameAsof:
    def test_basic(self, date_range_frame):
        df = date_range_frame
        N = 50
        df.loc[df.index[15:30], "A"] = np.nan
        dates = date_range("1/1/1990", periods=N * 3, freq="25s")


            

Reported by Pylint.

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

Line: 51 Column: 27

                      rs = result[mask]
        assert (rs == 14).all(1).all()

    def test_subset(self, date_range_frame):
        N = 10
        df = date_range_frame.iloc[:N].copy()
        df.loc[df.index[4:8], "A"] = np.nan
        dates = date_range("1/1/1990", periods=N * 3, freq="25s")


            

Reported by Pylint.

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

Line: 74 Column: 28

              
        tm.assert_frame_equal(result, expected)

    def test_missing(self, date_range_frame):
        # GH 15118
        # no match found - `where` value before earliest date in index
        N = 10
        df = date_range_frame.iloc[:N].copy()


            

Reported by Pylint.

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

Line: 106 Column: 29

                      expected = frame_or_series([np.nan])
        tm.assert_equal(result, expected)

    def test_all_nans(self, date_range_frame):
        # GH 15713
        # DataFrame is all nans

        # testing non-default indexes, multiple inputs
        N = 150

            

Reported by Pylint.

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

Line: 161 Column: 28

                      result = df.asof(stamp)
        tm.assert_series_equal(result, expected)

    def test_is_copy(self, date_range_frame):
        # GH-27357, GH-30784: ensure the result of asof is an actual copy and
        # doesn't track the parent dataframe / doesn't give SettingWithCopy warnings
        df = date_range_frame
        N = 50
        df.loc[df.index[15:30], "A"] = np.nan

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

from pandas._libs.tslibs import IncompatibleFrequency

from pandas import (
    DataFrame,
    Period,
    Series,

            

Reported by Pylint.

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

Line: 25 Column: 5

              
    Columns are ['A', 'B'].
    """
    N = 50
    rng = date_range("1/1/1990", periods=N, freq="53s")
    return DataFrame({"A": np.arange(N), "B": np.arange(N)}, index=rng)


class TestFrameAsof:

            

Reported by Pylint.

Missing class docstring
Error

Line: 30 Column: 1

                  return DataFrame({"A": np.arange(N), "B": np.arange(N)}, index=rng)


class TestFrameAsof:
    def test_basic(self, date_range_frame):
        df = date_range_frame
        N = 50
        df.loc[df.index[15:30], "A"] = np.nan
        dates = date_range("1/1/1990", periods=N * 3, freq="25s")

            

Reported by Pylint.

Method could be a function
Error

Line: 31 Column: 5

              

class TestFrameAsof:
    def test_basic(self, date_range_frame):
        df = date_range_frame
        N = 50
        df.loc[df.index[15:30], "A"] = np.nan
        dates = date_range("1/1/1990", periods=N * 3, freq="25s")


            

Reported by Pylint.