The following issues were found

pandas/tests/base/test_value_counts.py
36 issues
Unable to import 'pytest'
Error

Line: 6 Column: 1

              from io import StringIO

import numpy as np
import pytest

from pandas._libs import iNaT
from pandas.compat import np_array_datetime64_compat

from pandas.core.dtypes.common import needs_i8_conversion

            

Reported by Pylint.

TODO: Order of entries with the same count is inconsistent on CI (gh-32449)
Error

Line: 38 Column: 3

                  if isinstance(obj, pd.MultiIndex):
        expected.index = Index(expected.index)

    # TODO: Order of entries with the same count is inconsistent on CI (gh-32449)
    if obj.duplicated().any():
        result = result.sort_index()
        expected = expected.sort_index()
    tm.assert_series_equal(result, expected)


            

Reported by Pylint.

TODO:
Error

Line: 75 Column: 3

              
    result = obj.value_counts()
    if obj.duplicated().any():
        # TODO:
        #  Order of entries with the same count is inconsistent on CI (gh-32449)
        expected = expected.sort_index()
        result = result.sort_index()
    tm.assert_series_equal(result, expected)


            

Reported by Pylint.

TODO:
Error

Line: 88 Column: 3

              
    result = obj.value_counts(dropna=False)
    if obj.duplicated().any():
        # TODO:
        #  Order of entries with the same count is inconsistent on CI (gh-32449)
        expected = expected.sort_index()
        result = result.sort_index()
    tm.assert_series_equal(result, expected)


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import collections
from datetime import timedelta
from io import StringIO

import numpy as np
import pytest

from pandas._libs import iNaT
from pandas.compat import np_array_datetime64_compat

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 27 Column: 1

              from pandas.tests.base.common import allow_na_ops


def test_value_counts(index_or_series_obj):
    obj = index_or_series_obj
    obj = np.repeat(obj, range(1, len(obj) + 1))
    result = obj.value_counts()

    counter = collections.Counter(obj)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 46 Column: 1

              

@pytest.mark.parametrize("null_obj", [np.nan, None])
def test_value_counts_null(null_obj, index_or_series_obj):
    orig = index_or_series_obj
    obj = orig.copy()

    if not allow_na_ops(obj):
        pytest.skip("type doesn't allow for NA operations")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 95 Column: 1

                  tm.assert_series_equal(result, expected)


def test_value_counts_inferred(index_or_series):
    klass = index_or_series
    s_values = ["a", "b", "b", "b", "b", "c", "d", "d", "a", "a"]
    s = klass(s_values)
    expected = Series([4, 3, 2, 1], index=["b", "a", "d", "c"])
    tm.assert_series_equal(s.value_counts(), expected)

            

Reported by Pylint.

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

Line: 98 Column: 5

              def test_value_counts_inferred(index_or_series):
    klass = index_or_series
    s_values = ["a", "b", "b", "b", "b", "c", "d", "d", "a", "a"]
    s = klass(s_values)
    expected = Series([4, 3, 2, 1], index=["b", "a", "d", "c"])
    tm.assert_series_equal(s.value_counts(), expected)

    if isinstance(s, Index):
        exp = Index(np.unique(np.array(s_values, dtype=np.object_)))

            

Reported by Pylint.

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

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

                      exp = np.unique(np.array(s_values, dtype=np.object_))
        tm.assert_numpy_array_equal(s.unique(), exp)

    assert s.nunique() == 4
    # don't sort, have to sort after the fact as not sorting is
    # platform-dep
    hist = s.value_counts(sort=False).sort_values()
    expected = Series([3, 1, 4, 2], index=list("acbd")).sort_values()
    tm.assert_series_equal(hist, expected)

            

Reported by Bandit.

pandas/tests/arrays/floating/test_function.py
36 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

from pandas.compat import IS64

import pandas as pd
import pandas._testing as tm



            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

from pandas.compat import IS64

import pandas as pd
import pandas._testing as tm



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 12 Column: 1

              
@pytest.mark.parametrize("ufunc", [np.abs, np.sign])
# np.sign emits a warning with nans, <https://github.com/numpy/numpy/issues/15127>
@pytest.mark.filterwarnings("ignore:invalid value encountered in sign")
def test_ufuncs_single(ufunc):
    a = pd.array([1, 2, -3, np.nan], dtype="Float64")
    result = ufunc(a)
    expected = pd.array(ufunc(a.astype(float)), dtype="Float64")
    tm.assert_extension_array_equal(result, expected)

            

Reported by Pylint.

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

Line: 14 Column: 5

              # np.sign emits a warning with nans, <https://github.com/numpy/numpy/issues/15127>
@pytest.mark.filterwarnings("ignore:invalid value encountered in sign")
def test_ufuncs_single(ufunc):
    a = pd.array([1, 2, -3, np.nan], dtype="Float64")
    result = ufunc(a)
    expected = pd.array(ufunc(a.astype(float)), dtype="Float64")
    tm.assert_extension_array_equal(result, expected)

    s = pd.Series(a)

            

Reported by Pylint.

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

Line: 19 Column: 5

                  expected = pd.array(ufunc(a.astype(float)), dtype="Float64")
    tm.assert_extension_array_equal(result, expected)

    s = pd.Series(a)
    result = ufunc(s)
    expected = pd.Series(expected)
    tm.assert_series_equal(result, expected)



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 26 Column: 1

              

@pytest.mark.parametrize("ufunc", [np.log, np.exp, np.sin, np.cos, np.sqrt])
def test_ufuncs_single_float(ufunc):
    a = pd.array([1.0, 0.2, 3.0, np.nan], dtype="Float64")
    with np.errstate(invalid="ignore"):
        result = ufunc(a)
        expected = pd.array(ufunc(a.astype(float)), dtype="Float64")
    tm.assert_extension_array_equal(result, expected)

            

Reported by Pylint.

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

Line: 27 Column: 5

              
@pytest.mark.parametrize("ufunc", [np.log, np.exp, np.sin, np.cos, np.sqrt])
def test_ufuncs_single_float(ufunc):
    a = pd.array([1.0, 0.2, 3.0, np.nan], dtype="Float64")
    with np.errstate(invalid="ignore"):
        result = ufunc(a)
        expected = pd.array(ufunc(a.astype(float)), dtype="Float64")
    tm.assert_extension_array_equal(result, expected)


            

Reported by Pylint.

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

Line: 33 Column: 5

                      expected = pd.array(ufunc(a.astype(float)), dtype="Float64")
    tm.assert_extension_array_equal(result, expected)

    s = pd.Series(a)
    with np.errstate(invalid="ignore"):
        result = ufunc(s)
        expected = pd.Series(ufunc(s.astype(float)), dtype="Float64")
    tm.assert_series_equal(result, expected)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 41 Column: 1

              

@pytest.mark.parametrize("ufunc", [np.add, np.subtract])
def test_ufuncs_binary_float(ufunc):
    # two FloatingArrays
    a = pd.array([1, 0.2, -3, np.nan], dtype="Float64")
    result = ufunc(a, a)
    expected = pd.array(ufunc(a.astype(float), a.astype(float)), dtype="Float64")
    tm.assert_extension_array_equal(result, expected)

            

Reported by Pylint.

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

Line: 43 Column: 5

              @pytest.mark.parametrize("ufunc", [np.add, np.subtract])
def test_ufuncs_binary_float(ufunc):
    # two FloatingArrays
    a = pd.array([1, 0.2, -3, np.nan], dtype="Float64")
    result = ufunc(a, a)
    expected = pd.array(ufunc(a.astype(float), a.astype(float)), dtype="Float64")
    tm.assert_extension_array_equal(result, expected)

    # FloatingArray with numpy array

            

Reported by Pylint.

pandas/tests/arrays/floating/test_construction.py
36 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

import pandas as pd
import pandas._testing as tm
from pandas.core.arrays import FloatingArray
from pandas.core.arrays.floating import (
    Float32Dtype,
    Float64Dtype,

            

Reported by Pylint.

No value for argument 'mask' in constructor call
Error

Line: 40 Column: 9

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


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

            

Reported by Pylint.

Access to a protected member _data of a client class
Error

Line: 25 Column: 33

                  result = FloatingArray(values, mask)
    expected = pd.array([1, 2, 3, np.nan], dtype="Float64")
    tm.assert_extension_array_equal(result, expected)
    tm.assert_numpy_array_equal(result._data, values)
    tm.assert_numpy_array_equal(result._mask, mask)

    msg = r".* should be .* numpy array. Use the 'pd.array' function instead"
    with pytest.raises(TypeError, match=msg):
        FloatingArray(values.tolist(), mask)

            

Reported by Pylint.

Access to a protected member _mask of a client class
Error

Line: 26 Column: 33

                  expected = pd.array([1, 2, 3, np.nan], dtype="Float64")
    tm.assert_extension_array_equal(result, expected)
    tm.assert_numpy_array_equal(result._data, values)
    tm.assert_numpy_array_equal(result._mask, mask)

    msg = r".* should be .* numpy array. Use the 'pd.array' function instead"
    with pytest.raises(TypeError, match=msg):
        FloatingArray(values.tolist(), mask)


            

Reported by Pylint.

Access to a protected member _data of a client class
Error

Line: 48 Column: 12

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

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

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

            

Reported by Pylint.

Access to a protected member _mask of a client class
Error

Line: 49 Column: 12

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

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


            

Reported by Pylint.

Access to a protected member _data of a client class
Error

Line: 52 Column: 12

                  assert result._mask is mask

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


def test_to_array():
    result = pd.array([0.1, 0.2, 0.3, 0.4])

            

Reported by Pylint.

Access to a protected member _mask of a client class
Error

Line: 53 Column: 12

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


def test_to_array():
    result = pd.array([0.1, 0.2, 0.3, 0.4])
    expected = pd.array([0.1, 0.2, 0.3, 0.4], dtype="Float64")

            

Reported by Pylint.

TODO can we specify "floating" in general?
Error

Line: 138 Column: 3

                  tm.assert_extension_array_equal(result, expected)

    # for integer dtypes, the itemsize is not preserved
    # TODO can we specify "floating" in general?
    result = pd.array(np.array([1, 2], dtype="int32"), dtype="Float64")
    assert result.dtype == Float64Dtype()


@pytest.mark.parametrize(

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

import pandas as pd
import pandas._testing as tm
from pandas.core.arrays import FloatingArray
from pandas.core.arrays.floating import (
    Float32Dtype,
    Float64Dtype,

            

Reported by Pylint.

pandas/tests/indexing/test_datetime.py
36 issues
Access to a protected member _with_freq of a client class
Error

Line: 114 Column: 34

                          result = indexer_sl(ser)[sel]
            expected = ser.copy()
            if sel is not index:
                expected.index = expected.index._with_freq(None)
            tm.assert_series_equal(result, expected)

            # setitem
            result = ser.copy()
            indexer_sl(result)[sel] = 1

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import pandas as pd
from pandas import (
    DataFrame,
    Index,
    Series,
    Timestamp,
    date_range,
)
import pandas._testing as tm

            

Reported by Pylint.

Missing class docstring
Error

Line: 12 Column: 1

              import pandas._testing as tm


class TestDatetimeIndex:
    def test_datetimeindex_transpose_empty_df(self):
        """
        Regression test for:
        https://github.com/pandas-dev/pandas/issues/41382
        """

            

Reported by Pylint.

Method could be a function
Error

Line: 13 Column: 5

              

class TestDatetimeIndex:
    def test_datetimeindex_transpose_empty_df(self):
        """
        Regression test for:
        https://github.com/pandas-dev/pandas/issues/41382
        """
        df = DataFrame(index=pd.DatetimeIndex([]))

            

Reported by Pylint.

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

Line: 18 Column: 9

                      Regression test for:
        https://github.com/pandas-dev/pandas/issues/41382
        """
        df = DataFrame(index=pd.DatetimeIndex([]))

        expected = pd.DatetimeIndex([], dtype="datetime64[ns]", freq=None)

        result1 = df.T.sum().index
        result2 = df.sum(axis=1).index

            

Reported by Pylint.

Method could be a function
Error

Line: 28 Column: 5

                      tm.assert_index_equal(result1, expected)
        tm.assert_index_equal(result2, expected)

    def test_indexing_with_datetime_tz(self):

        # GH#8260
        # support datetime64 with tz

        idx = Index(date_range("20130101", periods=3, tz="US/Eastern"), name="foo")

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 28 Column: 5

                      tm.assert_index_equal(result1, expected)
        tm.assert_index_equal(result2, expected)

    def test_indexing_with_datetime_tz(self):

        # GH#8260
        # support datetime64 with tz

        idx = Index(date_range("20130101", periods=3, tz="US/Eastern"), name="foo")

            

Reported by Pylint.

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

Line: 34 Column: 9

                      # support datetime64 with tz

        idx = Index(date_range("20130101", periods=3, tz="US/Eastern"), name="foo")
        dr = date_range("20130110", periods=3)
        df = DataFrame({"A": idx, "B": dr})
        df["C"] = idx
        df.iloc[1, 1] = pd.NaT
        df.iloc[1, 2] = pd.NaT


            

Reported by Pylint.

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

Line: 35 Column: 9

              
        idx = Index(date_range("20130101", periods=3, tz="US/Eastern"), name="foo")
        dr = date_range("20130110", periods=3)
        df = DataFrame({"A": idx, "B": dr})
        df["C"] = idx
        df.iloc[1, 1] = pd.NaT
        df.iloc[1, 2] = pd.NaT

        expected = Series(

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 53 Column: 5

                      result = df.loc[1]
        tm.assert_series_equal(result, expected)

    def test_indexing_fast_xs(self):
        # indexing - fast_xs
        df = DataFrame({"a": date_range("2014-01-01", periods=10, tz="UTC")})
        result = df.iloc[5]
        expected = Series(
            [Timestamp("2014-01-06 00:00:00+0000", tz="UTC")], index=["a"], name=5

            

Reported by Pylint.

pandas/_version.py
36 issues
Attribute 'VCS' defined outside __init__
Error

Line: 41 Column: 5

                  # these strings are filled in when 'setup.py versioneer' creates
    # _version.py
    cfg = VersioneerConfig()
    cfg.VCS = "git"
    cfg.style = "pep440"
    cfg.tag_prefix = "v"
    cfg.parentdir_prefix = "pandas-"
    cfg.versionfile_source = "pandas/_version.py"
    cfg.verbose = False

            

Reported by Pylint.

Attribute 'style' defined outside __init__
Error

Line: 42 Column: 5

                  # _version.py
    cfg = VersioneerConfig()
    cfg.VCS = "git"
    cfg.style = "pep440"
    cfg.tag_prefix = "v"
    cfg.parentdir_prefix = "pandas-"
    cfg.versionfile_source = "pandas/_version.py"
    cfg.verbose = False
    return cfg

            

Reported by Pylint.

Attribute 'tag_prefix' defined outside __init__
Error

Line: 43 Column: 5

                  cfg = VersioneerConfig()
    cfg.VCS = "git"
    cfg.style = "pep440"
    cfg.tag_prefix = "v"
    cfg.parentdir_prefix = "pandas-"
    cfg.versionfile_source = "pandas/_version.py"
    cfg.verbose = False
    return cfg


            

Reported by Pylint.

Attribute 'parentdir_prefix' defined outside __init__
Error

Line: 44 Column: 5

                  cfg.VCS = "git"
    cfg.style = "pep440"
    cfg.tag_prefix = "v"
    cfg.parentdir_prefix = "pandas-"
    cfg.versionfile_source = "pandas/_version.py"
    cfg.verbose = False
    return cfg



            

Reported by Pylint.

Attribute 'versionfile_source' defined outside __init__
Error

Line: 45 Column: 5

                  cfg.style = "pep440"
    cfg.tag_prefix = "v"
    cfg.parentdir_prefix = "pandas-"
    cfg.versionfile_source = "pandas/_version.py"
    cfg.verbose = False
    return cfg


class NotThisMethod(Exception):

            

Reported by Pylint.

Attribute 'verbose' defined outside __init__
Error

Line: 46 Column: 5

                  cfg.tag_prefix = "v"
    cfg.parentdir_prefix = "pandas-"
    cfg.versionfile_source = "pandas/_version.py"
    cfg.verbose = False
    return cfg


class NotThisMethod(Exception):
    """Exception raised if a method is not valid for the current scenario."""

            

Reported by Pylint.

Unused variable 'i'
Error

Line: 116 Column: 9

                  """
    rootdirs = []

    for i in range(3):
        dirname = os.path.basename(root)
        if dirname.startswith(parentdir_prefix):
            return {
                "version": dirname[len(parentdir_prefix) :],
                "full-revisionid": None,

            

Reported by Pylint.

Redefining name 'run_command' from outer scope (line 70)
Error

Line: 234 Column: 52

              

@register_vcs_handler("git", "pieces_from_vcs")
def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
    """Get version from 'git describe' in the root of the source tree.

    This only gets called if the git-archive 'subst' keywords were *not*
    expanded, and _version.py hasn't already been rewritten with a short
    version string, meaning we're inside a checked out source tree.

            

Reported by Pylint.

Unused variable 'out'
Error

Line: 245 Column: 5

                  if sys.platform == "win32":
        GITS = ["git.cmd", "git.exe"]

    out, rc = run_command(GITS, ["rev-parse", "--git-dir"], cwd=root, hide_stderr=True)
    if rc != 0:
        if verbose:
            print("Directory %s not under git control" % root)
        raise NotThisMethod("'git rev-parse --git-dir' returned error")


            

Reported by Pylint.

Unused variable 'i'
Error

Line: 531 Column: 13

                      # versionfile_source is the relative path from the top of the source
        # tree (where the .git directory might live) to this file. Invert
        # this to find the root from __file__.
        for i in cfg.versionfile_source.split("/"):
            root = os.path.dirname(root)
    except NameError:
        return {
            "version": "0+unknown",
            "full-revisionid": None,

            

Reported by Pylint.

pandas/tests/indexes/datetimes/methods/test_factorize.py
36 issues
Instance of 'DatetimeIndex' has no 'freq' member
Error

Line: 24 Column: 28

                      arr, idx = idx1.factorize()
        tm.assert_numpy_array_equal(arr, exp_arr)
        tm.assert_index_equal(idx, exp_idx)
        assert idx.freq == exp_idx.freq

        arr, idx = idx1.factorize(sort=True)
        tm.assert_numpy_array_equal(arr, exp_arr)
        tm.assert_index_equal(idx, exp_idx)
        assert idx.freq == exp_idx.freq

            

Reported by Pylint.

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

Line: 29 Column: 28

                      arr, idx = idx1.factorize(sort=True)
        tm.assert_numpy_array_equal(arr, exp_arr)
        tm.assert_index_equal(idx, exp_idx)
        assert idx.freq == exp_idx.freq

        # tz must be preserved
        idx1 = idx1.tz_localize("Asia/Tokyo")
        exp_idx = exp_idx.tz_localize("Asia/Tokyo")


            

Reported by Pylint.

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

Line: 49 Column: 28

                      arr, idx = idx2.factorize(sort=True)
        tm.assert_numpy_array_equal(arr, exp_arr)
        tm.assert_index_equal(idx, exp_idx)
        assert idx.freq == exp_idx.freq

        exp_arr = np.array([0, 0, 1, 2, 0, 2], dtype=np.intp)
        exp_idx = DatetimeIndex(["2014-03", "2014-02", "2014-01"])
        arr, idx = idx2.factorize()
        tm.assert_numpy_array_equal(arr, exp_arr)

            

Reported by Pylint.

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

Line: 56 Column: 28

                      arr, idx = idx2.factorize()
        tm.assert_numpy_array_equal(arr, exp_arr)
        tm.assert_index_equal(idx, exp_idx)
        assert idx.freq == exp_idx.freq

    def test_factorize_preserves_freq(self):
        # GH#38120 freq should be preserved
        idx3 = date_range("2000-01", periods=4, freq="M", tz="Asia/Tokyo")
        exp_arr = np.array([0, 1, 2, 3], dtype=np.intp)

            

Reported by Pylint.

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

Line: 66 Column: 28

                      arr, idx = idx3.factorize()
        tm.assert_numpy_array_equal(arr, exp_arr)
        tm.assert_index_equal(idx, idx3)
        assert idx.freq == idx3.freq

        arr, idx = factorize(idx3)
        tm.assert_numpy_array_equal(arr, exp_arr)
        tm.assert_index_equal(idx, idx3)
        assert idx.freq == idx3.freq

            

Reported by Pylint.

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

Line: 66 Column: 28

                      arr, idx = idx3.factorize()
        tm.assert_numpy_array_equal(arr, exp_arr)
        tm.assert_index_equal(idx, idx3)
        assert idx.freq == idx3.freq

        arr, idx = factorize(idx3)
        tm.assert_numpy_array_equal(arr, exp_arr)
        tm.assert_index_equal(idx, idx3)
        assert idx.freq == idx3.freq

            

Reported by Pylint.

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

Line: 71 Column: 28

                      arr, idx = factorize(idx3)
        tm.assert_numpy_array_equal(arr, exp_arr)
        tm.assert_index_equal(idx, idx3)
        assert idx.freq == idx3.freq

    def test_factorize_tz(self, tz_naive_fixture, index_or_series):
        tz = tz_naive_fixture
        # GH#13750
        base = date_range("2016-11-05", freq="H", periods=100, tz=tz)

            

Reported by Pylint.

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

Line: 71 Column: 28

                      arr, idx = factorize(idx3)
        tm.assert_numpy_array_equal(arr, exp_arr)
        tm.assert_index_equal(idx, idx3)
        assert idx.freq == idx3.freq

    def test_factorize_tz(self, tz_naive_fixture, index_or_series):
        tz = tz_naive_fixture
        # GH#13750
        base = date_range("2016-11-05", freq="H", periods=100, tz=tz)

            

Reported by Pylint.

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

Line: 85 Column: 20

              
        arr, res = obj.factorize()
        tm.assert_numpy_array_equal(arr, exp_arr)
        expected = base._with_freq(None)
        tm.assert_index_equal(res, expected)
        assert res.freq == expected.freq

    def test_factorize_dst(self, index_or_series):
        # GH#13750

            

Reported by Pylint.

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

Line: 85 Column: 20

              
        arr, res = obj.factorize()
        tm.assert_numpy_array_equal(arr, exp_arr)
        expected = base._with_freq(None)
        tm.assert_index_equal(res, expected)
        assert res.freq == expected.freq

    def test_factorize_dst(self, index_or_series):
        # GH#13750

            

Reported by Pylint.

asv_bench/benchmarks/replace.py
36 issues
Unable to import 'pandas'
Error

Line: 3 Column: 1

              import numpy as np

import pandas as pd


class FillNa:

    params = [True, False]
    param_names = ["inplace"]

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 77 Column: 1

                      self.data.replace(self.to_replace)


from .pandas_vb_common import setup  # noqa: F401 isort:skip

            

Reported by Pylint.

Unused argument 'inplace'
Error

Line: 11 Column: 21

                  params = [True, False]
    param_names = ["inplace"]

    def setup(self, inplace):
        N = 10 ** 6
        rng = pd.date_range("1/1/2000", periods=N, freq="min")
        data = np.random.randn(N)
        data[::2] = np.nan
        self.ts = pd.Series(data, index=rng)

            

Reported by Pylint.

Attribute 'ts' defined outside __init__
Error

Line: 16 Column: 9

                      rng = pd.date_range("1/1/2000", periods=N, freq="min")
        data = np.random.randn(N)
        data[::2] = np.nan
        self.ts = pd.Series(data, index=rng)

    def time_fillna(self, inplace):
        self.ts.fillna(0.0, inplace=inplace)

    def time_replace(self, inplace):

            

Reported by Pylint.

Unused argument 'inplace'
Error

Line: 30 Column: 21

                  params = [True, False]
    param_names = ["inplace"]

    def setup(self, inplace):
        N = 10 ** 5
        start_value = 10 ** 5
        self.to_rep = dict(enumerate(np.arange(N) + start_value))
        self.s = pd.Series(np.random.randint(N, size=10 ** 3))


            

Reported by Pylint.

Attribute 'to_rep' defined outside __init__
Error

Line: 33 Column: 9

                  def setup(self, inplace):
        N = 10 ** 5
        start_value = 10 ** 5
        self.to_rep = dict(enumerate(np.arange(N) + start_value))
        self.s = pd.Series(np.random.randint(N, size=10 ** 3))

    def time_replace_series(self, inplace):
        self.s.replace(self.to_rep, inplace=inplace)


            

Reported by Pylint.

Attribute 's' defined outside __init__
Error

Line: 34 Column: 9

                      N = 10 ** 5
        start_value = 10 ** 5
        self.to_rep = dict(enumerate(np.arange(N) + start_value))
        self.s = pd.Series(np.random.randint(N, size=10 ** 3))

    def time_replace_series(self, inplace):
        self.s.replace(self.to_rep, inplace=inplace)



            

Reported by Pylint.

Unused argument 'inplace'
Error

Line: 46 Column: 21

                  params = [(True, False)]
    param_names = ["inplace"]

    def setup(self, inplace):
        self.df = pd.DataFrame({"A": 0, "B": 0}, index=range(4 * 10 ** 7))

    def time_replace_list(self, inplace):
        self.df.replace([np.inf, -np.inf], np.nan, inplace=inplace)


            

Reported by Pylint.

Attribute 'df' defined outside __init__
Error

Line: 47 Column: 9

                  param_names = ["inplace"]

    def setup(self, inplace):
        self.df = pd.DataFrame({"A": 0, "B": 0}, index=range(4 * 10 ** 7))

    def time_replace_list(self, inplace):
        self.df.replace([np.inf, -np.inf], np.nan, inplace=inplace)

    def time_replace_list_one_match(self, inplace):

            

Reported by Pylint.

Attribute 'to_replace' defined outside __init__
Error

Line: 70 Column: 9

                              {"A": np.random.randint(N, size=N), "B": np.random.randint(N, size=N)}
            ),
        }
        self.to_replace = {i: getattr(pd, replace_data) for i in range(N)}
        self.data = data[constructor]

    def time_replace(self, constructor, replace_data):
        self.data.replace(self.to_replace)


            

Reported by Pylint.

pandas/tests/plotting/test_groupby.py
36 issues
Unable to import 'pytest'
Error

Line: 5 Column: 1

              

import numpy as np
import pytest

from pandas.compat import is_platform_windows
import pandas.util._test_decorators as td

from pandas import (

            

Reported by Pylint.

Missing class docstring
Error

Line: 22 Column: 1

              

@td.skip_if_no_mpl
class TestDataFrameGroupByPlots(TestPlotBase):
    @pytest.mark.xfail(
        is_platform_windows(),
        reason="Looks like LinePlot._is_ts_plot is wrong",
        strict=False,
    )

            

Reported by Pylint.

Method could be a function
Error

Line: 27 Column: 5

                      is_platform_windows(),
        reason="Looks like LinePlot._is_ts_plot is wrong",
        strict=False,
    )
    def test_series_groupby_plotting_nominally_works(self):
        n = 10
        weight = Series(np.random.normal(166, 20, size=n))
        height = Series(np.random.normal(60, 10, size=n))
        with tm.RNGContext(42):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 27 Column: 5

                      is_platform_windows(),
        reason="Looks like LinePlot._is_ts_plot is wrong",
        strict=False,
    )
    def test_series_groupby_plotting_nominally_works(self):
        n = 10
        weight = Series(np.random.normal(166, 20, size=n))
        height = Series(np.random.normal(60, 10, size=n))
        with tm.RNGContext(42):

            

Reported by Pylint.

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

Line: 29 Column: 9

                      strict=False,
    )
    def test_series_groupby_plotting_nominally_works(self):
        n = 10
        weight = Series(np.random.normal(166, 20, size=n))
        height = Series(np.random.normal(60, 10, size=n))
        with tm.RNGContext(42):
            gender = np.random.choice(["male", "female"], size=n)


            

Reported by Pylint.

Method could be a function
Error

Line: 43 Column: 5

                      height.groupby(gender).plot(alpha=0.5)
        tm.close()

    def test_plotting_with_float_index_works(self):
        # GH 7025
        df = DataFrame(
            {"def": [1, 1, 1, 2, 2, 2, 3, 3, 3], "val": np.random.randn(9)},
            index=[1.0, 2.0, 3.0, 1.0, 2.0, 3.0, 1.0, 2.0, 3.0],
        )

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 43 Column: 5

                      height.groupby(gender).plot(alpha=0.5)
        tm.close()

    def test_plotting_with_float_index_works(self):
        # GH 7025
        df = DataFrame(
            {"def": [1, 1, 1, 2, 2, 2, 3, 3, 3], "val": np.random.randn(9)},
            index=[1.0, 2.0, 3.0, 1.0, 2.0, 3.0, 1.0, 2.0, 3.0],
        )

            

Reported by Pylint.

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

Line: 45 Column: 9

              
    def test_plotting_with_float_index_works(self):
        # GH 7025
        df = DataFrame(
            {"def": [1, 1, 1, 2, 2, 2, 3, 3, 3], "val": np.random.randn(9)},
            index=[1.0, 2.0, 3.0, 1.0, 2.0, 3.0, 1.0, 2.0, 3.0],
        )

        df.groupby("def")["val"].plot()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 55 Column: 5

                      df.groupby("def")["val"].apply(lambda x: x.plot())
        tm.close()

    def test_hist_single_row(self):
        # GH10214
        bins = np.arange(80, 100 + 2, 1)
        df = DataFrame({"Name": ["AAA", "BBB"], "ByCol": [1, 2], "Mark": [85, 89]})
        df["Mark"].hist(by=df["ByCol"], bins=bins)
        df = DataFrame({"Name": ["AAA"], "ByCol": [1], "Mark": [85]})

            

Reported by Pylint.

Method could be a function
Error

Line: 55 Column: 5

                      df.groupby("def")["val"].apply(lambda x: x.plot())
        tm.close()

    def test_hist_single_row(self):
        # GH10214
        bins = np.arange(80, 100 + 2, 1)
        df = DataFrame({"Name": ["AAA", "BBB"], "ByCol": [1, 2], "Mark": [85, 89]})
        df["Mark"].hist(by=df["ByCol"], bins=bins)
        df = DataFrame({"Name": ["AAA"], "ByCol": [1], "Mark": [85]})

            

Reported by Pylint.

pandas/io/formats/printing.py
36 issues
Unable to import 'IPython'
Error

Line: 248 Column: 5

                  if "IPython" not in sys.modules:
        # definitely not in IPython
        return
    from IPython import get_ipython

    ip = get_ipython()
    if ip is None:
        # still not in IPython
        return

            

Reported by Pylint.

Unable to import 'IPython.core.formatters'
Error

Line: 261 Column: 13

                  if enable:
        if mimetype not in formatters:
            # define tableschema formatter
            from IPython.core.formatters import BaseFormatter

            class TableSchemaFormatter(BaseFormatter):
                print_method = "_repr_data_resource_"
                _return_type = (dict,)


            

Reported by Pylint.

Redefining built-in 'object'
Error

Line: 238 Column: 5

              

def pprint_thing_encoded(
    object, encoding: str = "utf-8", errors: str = "replace"
) -> bytes:
    value = pprint_thing(object)  # get unicode representation of object
    return value.encode(encoding, errors)



            

Reported by Pylint.

Using possibly undefined loop variable 'max_items'
Error

Line: 423 Column: 50

                              pprinted_seq = _pprint_seq(value, max_seq_items=max_items)
                if len(pprinted_seq) < max_space:
                    break
            head = [_pprint_seq(x, max_seq_items=max_items) for x in head]
            tail = [_pprint_seq(x, max_seq_items=max_items) for x in tail]

        summary = ""
        line = space2


            

Reported by Pylint.

Using possibly undefined loop variable 'max_items'
Error

Line: 424 Column: 50

                              if len(pprinted_seq) < max_space:
                    break
            head = [_pprint_seq(x, max_seq_items=max_items) for x in head]
            tail = [_pprint_seq(x, max_seq_items=max_items) for x in tail]

        summary = ""
        line = space2

        for max_items in range(len(head)):

            

Reported by Pylint.

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

Line: 47 Column: 5

                  justfunc = kwargs.pop("justfunc", justify)

    out_lines = []
    newLists = []
    lengths = [max(map(strlen, x)) + space for x in lists[:-1]]
    # not the last one
    lengths.append(max(map(len, lists[-1])))
    maxLen = max(map(len, lists))
    for i, lst in enumerate(lists):

            

Reported by Pylint.

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

Line: 51 Column: 5

                  lengths = [max(map(strlen, x)) + space for x in lists[:-1]]
    # not the last one
    lengths.append(max(map(len, lists[-1])))
    maxLen = max(map(len, lists))
    for i, lst in enumerate(lists):
        nl = justfunc(lst, lengths[i], mode="left")
        nl.extend([" " * lengths[i]] * (maxLen - len(lst)))
        newLists.append(nl)
    toJoin = zip(*newLists)

            

Reported by Pylint.

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

Line: 53 Column: 9

                  lengths.append(max(map(len, lists[-1])))
    maxLen = max(map(len, lists))
    for i, lst in enumerate(lists):
        nl = justfunc(lst, lengths[i], mode="left")
        nl.extend([" " * lengths[i]] * (maxLen - len(lst)))
        newLists.append(nl)
    toJoin = zip(*newLists)
    for lines in toJoin:
        out_lines.append("".join(lines))

            

Reported by Pylint.

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

Line: 56 Column: 5

                      nl = justfunc(lst, lengths[i], mode="left")
        nl.extend([" " * lengths[i]] * (maxLen - len(lst)))
        newLists.append(nl)
    toJoin = zip(*newLists)
    for lines in toJoin:
        out_lines.append("".join(lines))
    return "\n".join(out_lines)



            

Reported by Pylint.

Unnecessary "elif" after "return"
Error

Line: 66 Column: 5

                  """
    Perform ljust, center, rjust against string or list-like
    """
    if mode == "left":
        return [x.ljust(max_len) for x in texts]
    elif mode == "center":
        return [x.center(max_len) for x in texts]
    else:
        return [x.rjust(max_len) for x in texts]

            

Reported by Pylint.

pandas/tests/series/methods/test_clip.py
36 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              from datetime import datetime

import numpy as np
import pytest

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

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from datetime import datetime

import numpy as np
import pytest

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

            

Reported by Pylint.

Missing class docstring
Error

Line: 16 Column: 1

              import pandas._testing as tm


class TestSeriesClip:
    def test_clip(self, datetime_series):
        val = datetime_series.median()

        assert datetime_series.clip(lower=val).min() == val
        assert datetime_series.clip(upper=val).max() == val

            

Reported by Pylint.

Method could be a function
Error

Line: 17 Column: 5

              

class TestSeriesClip:
    def test_clip(self, datetime_series):
        val = datetime_series.median()

        assert datetime_series.clip(lower=val).min() == val
        assert datetime_series.clip(upper=val).max() == val


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 5

              

class TestSeriesClip:
    def test_clip(self, datetime_series):
        val = datetime_series.median()

        assert datetime_series.clip(lower=val).min() == val
        assert datetime_series.clip(upper=val).max() == val


            

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_clip(self, datetime_series):
        val = datetime_series.median()

        assert datetime_series.clip(lower=val).min() == val
        assert datetime_series.clip(upper=val).max() == val

        result = datetime_series.clip(-0.5, 0.5)
        expected = np.clip(datetime_series, -0.5, 0.5)
        tm.assert_series_equal(result, expected)

            

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

                      val = datetime_series.median()

        assert datetime_series.clip(lower=val).min() == val
        assert datetime_series.clip(upper=val).max() == val

        result = datetime_series.clip(-0.5, 0.5)
        expected = np.clip(datetime_series, -0.5, 0.5)
        tm.assert_series_equal(result, expected)
        assert isinstance(expected, Series)

            

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 = datetime_series.clip(-0.5, 0.5)
        expected = np.clip(datetime_series, -0.5, 0.5)
        tm.assert_series_equal(result, expected)
        assert isinstance(expected, Series)

    def test_clip_types_and_nulls(self):

        sers = [
            Series([np.nan, 1.0, 2.0, 3.0]),

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 28 Column: 5

                      tm.assert_series_equal(result, expected)
        assert isinstance(expected, Series)

    def test_clip_types_and_nulls(self):

        sers = [
            Series([np.nan, 1.0, 2.0, 3.0]),
            Series([None, "a", "b", "c"]),
            Series(pd.to_datetime([np.nan, 1, 2, 3], unit="D")),

            

Reported by Pylint.

Method could be a function
Error

Line: 28 Column: 5

                      tm.assert_series_equal(result, expected)
        assert isinstance(expected, Series)

    def test_clip_types_and_nulls(self):

        sers = [
            Series([np.nan, 1.0, 2.0, 3.0]),
            Series([None, "a", "b", "c"]),
            Series(pd.to_datetime([np.nan, 1, 2, 3], unit="D")),

            

Reported by Pylint.