The following issues were found

asv_bench/benchmarks/io/pickle.py
17 issues
Unable to import 'pandas'
Error

Line: 3 Column: 1

              import numpy as np

from pandas import (
    DataFrame,
    date_range,
    read_pickle,
)

from ..pandas_vb_common import (

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 9 Column: 1

                  read_pickle,
)

from ..pandas_vb_common import (
    BaseIO,
    tm,
)



            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 41 Column: 1

                      self.df.to_pickle(self.fname)


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

            

Reported by Pylint.

Attribute 'fname' defined outside __init__
Error

Line: 17 Column: 9

              
class Pickle(BaseIO):
    def setup(self):
        self.fname = "__test__.pkl"
        N = 100000
        C = 5
        self.df = DataFrame(
            np.random.randn(N, C),
            columns=[f"float{i}" for i in range(C)],

            

Reported by Pylint.

Attribute 'df' defined outside __init__
Error

Line: 20 Column: 9

                      self.fname = "__test__.pkl"
        N = 100000
        C = 5
        self.df = DataFrame(
            np.random.randn(N, C),
            columns=[f"float{i}" for i in range(C)],
            index=date_range("20000101", periods=N, freq="H"),
        )
        self.df["object"] = tm.makeStringIndex(N)

            

Reported by Pylint.

Unused setup imported from pandas_vb_common
Error

Line: 41 Column: 1

                      self.df.to_pickle(self.fname)


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

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np

from pandas import (
    DataFrame,
    date_range,
    read_pickle,
)

from ..pandas_vb_common import (

            

Reported by Pylint.

Missing class docstring
Error

Line: 15 Column: 1

              )


class Pickle(BaseIO):
    def setup(self):
        self.fname = "__test__.pkl"
        N = 100000
        C = 5
        self.df = DataFrame(

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 16 Column: 5

              

class Pickle(BaseIO):
    def setup(self):
        self.fname = "__test__.pkl"
        N = 100000
        C = 5
        self.df = DataFrame(
            np.random.randn(N, C),

            

Reported by Pylint.

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

Line: 18 Column: 9

              class Pickle(BaseIO):
    def setup(self):
        self.fname = "__test__.pkl"
        N = 100000
        C = 5
        self.df = DataFrame(
            np.random.randn(N, C),
            columns=[f"float{i}" for i in range(C)],
            index=date_range("20000101", periods=N, freq="H"),

            

Reported by Pylint.

pandas/_testing/contexts.py
17 issues
Redefining name 'os' from outer scope (line 4)
Error

Line: 63 Column: 5

                  ...
    'EDT'
    """
    import os
    import time

    def setTZ(tz):
        if tz is None:
            try:

            

Reported by Pylint.

Reimport 'os' (imported line 4)
Error

Line: 63 Column: 5

                  ...
    'EDT'
    """
    import os
    import time

    def setTZ(tz):
        if tz is None:
            try:

            

Reported by Pylint.

Access to a protected member _MIN_ELEMENTS of a client class
Error

Line: 201 Column: 24

                  from pandas.core.computation import expressions as expr

    if min_elements is None:
        min_elements = expr._MIN_ELEMENTS

    olduse = expr.USE_NUMEXPR
    oldmin = expr._MIN_ELEMENTS
    expr.set_use_numexpr(use)
    expr._MIN_ELEMENTS = min_elements

            

Reported by Pylint.

Access to a protected member _MIN_ELEMENTS of a client class
Error

Line: 204 Column: 14

                      min_elements = expr._MIN_ELEMENTS

    olduse = expr.USE_NUMEXPR
    oldmin = expr._MIN_ELEMENTS
    expr.set_use_numexpr(use)
    expr._MIN_ELEMENTS = min_elements
    yield
    expr._MIN_ELEMENTS = oldmin
    expr.set_use_numexpr(olduse)

            

Reported by Pylint.

Access to a protected member _MIN_ELEMENTS of a client class
Error

Line: 206 Column: 5

                  olduse = expr.USE_NUMEXPR
    oldmin = expr._MIN_ELEMENTS
    expr.set_use_numexpr(use)
    expr._MIN_ELEMENTS = min_elements
    yield
    expr._MIN_ELEMENTS = oldmin
    expr.set_use_numexpr(olduse)



            

Reported by Pylint.

Access to a protected member _MIN_ELEMENTS of a client class
Error

Line: 208 Column: 5

                  expr.set_use_numexpr(use)
    expr._MIN_ELEMENTS = min_elements
    yield
    expr._MIN_ELEMENTS = oldmin
    expr.set_use_numexpr(olduse)


class RNGContext:
    """

            

Reported by Pylint.

Attribute 'start_state' defined outside __init__
Error

Line: 233 Column: 9

              
    def __enter__(self):

        self.start_state = np.random.get_state()
        np.random.seed(self.seed)

    def __exit__(self, exc_type, exc_value, traceback):

        np.random.set_state(self.start_state)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from __future__ import annotations

from contextlib import contextmanager
import os
from pathlib import Path
import random
from shutil import rmtree
import string
import tempfile

            

Reported by Pylint.

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

Line: 42 Column: 1

              

@contextmanager
def set_timezone(tz: str):
    """
    Context manager for temporarily setting a timezone.

    Parameters
    ----------

            

Reported by Pylint.

Import outside toplevel (os)
Error

Line: 63 Column: 5

                  ...
    'EDT'
    """
    import os
    import time

    def setTZ(tz):
        if tz is None:
            try:

            

Reported by Pylint.

pandas/core/arrays/_ranges.py
17 issues
No name 'lib' in module 'pandas._libs'
Error

Line: 9 Column: 1

              
import numpy as np

from pandas._libs.lib import i8max
from pandas._libs.tslibs import (
    BaseOffset,
    OutOfBoundsDatetime,
    Timedelta,
    Timestamp,

            

Reported by Pylint.

Unable to import 'pandas._libs.lib'
Error

Line: 9 Column: 1

              
import numpy as np

from pandas._libs.lib import i8max
from pandas._libs.tslibs import (
    BaseOffset,
    OutOfBoundsDatetime,
    Timedelta,
    Timestamp,

            

Reported by Pylint.

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

Line: 49 Column: 9

                  stride = freq.nanos

    if periods is None:
        b = istart
        # cannot just use e = Timestamp(end) + 1 because arange breaks when
        # stride is too large, see GH10887
        e = b + (iend - b) // stride * stride + stride // 2 + 1
    elif istart is not None:
        b = istart

            

Reported by Pylint.

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

Line: 52 Column: 9

                      b = istart
        # cannot just use e = Timestamp(end) + 1 because arange breaks when
        # stride is too large, see GH10887
        e = b + (iend - b) // stride * stride + stride // 2 + 1
    elif istart is not None:
        b = istart
        e = _generate_range_overflow_safe(b, periods, stride, side="start")
    elif iend is not None:
        e = iend + stride

            

Reported by Pylint.

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

Line: 54 Column: 9

                      # stride is too large, see GH10887
        e = b + (iend - b) // stride * stride + stride // 2 + 1
    elif istart is not None:
        b = istart
        e = _generate_range_overflow_safe(b, periods, stride, side="start")
    elif iend is not None:
        e = iend + stride
        b = _generate_range_overflow_safe(e, periods, stride, side="end")
    else:

            

Reported by Pylint.

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

Line: 55 Column: 9

                      e = b + (iend - b) // stride * stride + stride // 2 + 1
    elif istart is not None:
        b = istart
        e = _generate_range_overflow_safe(b, periods, stride, side="start")
    elif iend is not None:
        e = iend + stride
        b = _generate_range_overflow_safe(e, periods, stride, side="end")
    else:
        raise ValueError(

            

Reported by Pylint.

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

Line: 57 Column: 9

                      b = istart
        e = _generate_range_overflow_safe(b, periods, stride, side="start")
    elif iend is not None:
        e = iend + stride
        b = _generate_range_overflow_safe(e, periods, stride, side="end")
    else:
        raise ValueError(
            "at least 'start' or 'end' should be specified if a 'period' is given."
        )

            

Reported by Pylint.

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

Line: 58 Column: 9

                      e = _generate_range_overflow_safe(b, periods, stride, side="start")
    elif iend is not None:
        e = iend + stride
        b = _generate_range_overflow_safe(e, periods, stride, side="end")
    else:
        raise ValueError(
            "at least 'start' or 'end' should be specified if a 'period' is given."
        )


            

Reported by Pylint.

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

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

                  OutOfBoundsDatetime
    """
    # GH#14187 raise instead of incorrectly wrapping around
    assert side in ["start", "end"]

    i64max = np.uint64(i8max)
    msg = f"Cannot generate range with {side}={endpoint} and periods={periods}"

    with np.errstate(over="raise"):

            

Reported by Bandit.

Unnecessary "elif" after "return"
Error

Line: 118 Column: 5

                      except FloatingPointError as err:
            raise OutOfBoundsDatetime(msg) from err

    if np.abs(addend) <= i64max:
        # relatively easy case without casting concerns
        return _generate_range_overflow_safe_signed(endpoint, periods, stride, side)

    elif (endpoint > 0 and side == "start" and stride > 0) or (
        endpoint < 0 and side == "end" and stride > 0

            

Reported by Pylint.

pandas/core/arrays/sparse/scipy_sparse.py
17 issues
Unable to import 'scipy.sparse'
Error

Line: 97 Column: 5

                  levels row_levels, column_levels as the row and column
    labels respectively. Returns the sparse_matrix, row and column labels.
    """
    import scipy.sparse

    if ss.index.nlevels < 2:
        raise ValueError("to_coo requires MultiIndex with nlevels > 2")
    if not ss.index.is_unique:
        raise ValueError(

            

Reported by Pylint.

Access to a protected member _valid_sp_values of a client class
Error

Line: 32 Column: 14

                  _check_is_partition([row_levels, column_levels], range(ss.index.nlevels))

    # from the sparse Series: get the labels and data for non-null entries
    values = ss.array._valid_sp_values

    nonnull_labels = ss.dropna()

    def get_indexers(levels):
        """Return sparse coords and dense labels for subset levels"""

            

Reported by Pylint.

TODO: how to do this better? cleanly slice nonnull_labels given the
Error

Line: 38 Column: 3

              
    def get_indexers(levels):
        """Return sparse coords and dense labels for subset levels"""
        # TODO: how to do this better? cleanly slice nonnull_labels given the
        # coord
        values_ilabels = [tuple(x[i] for i in levels) for x in nonnull_labels.index]
        if len(levels) == 1:
            values_ilabels = [x[0] for x in values_ilabels]


            

Reported by Pylint.

TODO: these two lines can replace the code below but
Error

Line: 45 Column: 3

                          values_ilabels = [x[0] for x in values_ilabels]

        # # performance issues with groupby ###################################
        # TODO: these two lines can replace the code below but
        # groupby is too slow (in some cases at least)
        # labels_to_i = ss.groupby(level=levels, sort=sort_labels).first()
        # labels_to_i[:] = np.arange(labels_to_i.shape[0])

        def _get_label_to_i_dict(labels, sort_labels=False):

            

Reported by Pylint.

Access to a protected member _get_level_values of a client class
Error

Line: 61 Column: 34

                          return {k: i for i, k in enumerate(labels)}

        def _get_index_subset_to_coord_dict(index, subset, sort_labels=False):
            ilabels = list(zip(*(index._get_level_values(i) for i in subset)))
            labels_to_i = _get_label_to_i_dict(ilabels, sort_labels=sort_labels)
            labels_to_i = Series(labels_to_i)
            if len(subset) > 1:
                labels_to_i.index = MultiIndex.from_tuples(labels_to_i.index)
                labels_to_i.index.names = [index.names[i] for i in subset]

            

Reported by Pylint.

Access to a protected member _get_level_number of a client class
Error

Line: 107 Column: 19

                      )

    # to keep things simple, only rely on integer indexing (not labels)
    row_levels = [ss.index._get_level_number(x) for x in row_levels]
    column_levels = [ss.index._get_level_number(x) for x in column_levels]

    v, i, j, rows, columns = _to_ijv(
        ss, row_levels=row_levels, column_levels=column_levels, sort_labels=sort_labels
    )

            

Reported by Pylint.

Access to a protected member _get_level_number of a client class
Error

Line: 108 Column: 22

              
    # to keep things simple, only rely on integer indexing (not labels)
    row_levels = [ss.index._get_level_number(x) for x in row_levels]
    column_levels = [ss.index._get_level_number(x) for x in column_levels]

    v, i, j, rows, columns = _to_ijv(
        ss, row_levels=row_levels, column_levels=column_levels, sort_labels=sort_labels
    )
    sparse_matrix = scipy.sparse.coo_matrix(

            

Reported by Pylint.

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

Line: 22 Column: 1

                      raise ValueError("Is not a partition because union is not the whole.")


def _to_ijv(ss, row_levels=(0,), column_levels=(1,), sort_labels=False):
    """
    For arbitrary (MultiIndexed) sparse Series return
    (v, i, j, ilabels, jlabels) where (v, (i, j)) is suitable for
    passing to scipy.sparse.coo constructor.
    """

            

Reported by Pylint.

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

Line: 91 Column: 1

                  return values, i_coord, j_coord, i_labels, j_labels


def sparse_series_to_coo(ss, row_levels=(0,), column_levels=(1,), sort_labels=False):
    """
    Convert a sparse Series to a scipy.sparse.coo_matrix using index
    levels row_levels, column_levels as the row and column
    labels respectively. Returns the sparse_matrix, row and column labels.
    """

            

Reported by Pylint.

Import outside toplevel (scipy.sparse)
Error

Line: 97 Column: 5

                  levels row_levels, column_levels as the row and column
    labels respectively. Returns the sparse_matrix, row and column labels.
    """
    import scipy.sparse

    if ss.index.nlevels < 2:
        raise ValueError("to_coo requires MultiIndex with nlevels > 2")
    if not ss.index.is_unique:
        raise ValueError(

            

Reported by Pylint.

pandas/core/describe.py
17 issues
Value 'np.ndarray' is unsubscriptable
Error

Line: 391 Column: 6

              
def refine_percentiles(
    percentiles: Sequence[float] | np.ndarray | None,
) -> np.ndarray[Any, np.dtype[np.float64]]:
    """
    Ensure that percentiles are unique and sorted.

    Parameters
    ----------

            

Reported by Pylint.

Unused argument 'percentiles_ignored'
Error

Line: 248 Column: 5

              
def describe_categorical_1d(
    data: Series,
    percentiles_ignored: Sequence[float],
) -> Series:
    """Describe series containing categorical data.

    Parameters
    ----------

            

Reported by Pylint.

Unused argument 'percentiles_ignored'
Error

Line: 280 Column: 5

              
def describe_timestamp_as_categorical_1d(
    data: Series,
    percentiles_ignored: Sequence[float],
) -> Series:
    """Describe series containing timestamp data treated as categorical.

    Parameters
    ----------

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 97 Column: 1

                  return cast(FrameOrSeries, result)


class NDFrameDescriberAbstract(ABC):
    """Abstract class for describing dataframe or series.

    Parameters
    ----------
    obj : Series or DataFrame

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 123 Column: 1

                      """


class SeriesDescriber(NDFrameDescriberAbstract):
    """Class responsible for creating series description."""

    obj: Series

    def describe(self, percentiles: Sequence[float] | np.ndarray) -> Series:

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 136 Column: 1

                      return describe_func(self.obj, percentiles)


class DataFrameDescriber(NDFrameDescriberAbstract):
    """Class responsible for creating dataobj description.

    Parameters
    ----------
    obj : DataFrame

            

Reported by Pylint.

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

Line: 176 Column: 9

                          ldesc.append(describe_func(series, percentiles))

        col_names = reorder_columns(ldesc)
        d = concat(
            [x.reindex(col_names, copy=False) for x in ldesc],
            axis=1,
            sort=False,
        )
        d.columns = data.columns.copy()

            

Reported by Pylint.

Import outside toplevel (pandas.Series)
Error

Line: 230 Column: 5

                  percentiles : list-like of numbers
        The percentiles to include in the output.
    """
    from pandas import Series

    # error: Argument 1 to "format_percentiles" has incompatible type "Sequence[float]";
    # expected "Union[ndarray, List[Union[int, float]], List[float], List[Union[str,
    # float]]]"
    formatted_percentiles = format_percentiles(percentiles)  # type: ignore[arg-type]

            

Reported by Pylint.

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

Line: 238 Column: 5

                  formatted_percentiles = format_percentiles(percentiles)  # type: ignore[arg-type]

    stat_index = ["count", "mean", "std", "min"] + formatted_percentiles + ["max"]
    d = (
        [series.count(), series.mean(), series.std(), series.min()]
        + series.quantile(percentiles).tolist()
        + [series.max()]
    )
    return Series(d, index=stat_index, name=series.name)

            

Reported by Pylint.

Import outside toplevel (pandas.Series)
Error

Line: 273 Column: 5

              
    result = [data.count(), count_unique, top, freq]

    from pandas import Series

    return Series(result, index=names, name=data.name, dtype=dtype)


def describe_timestamp_as_categorical_1d(

            

Reported by Pylint.

pandas/io/json/_table_schema.py
17 issues
No name 'json' in module 'pandas._libs'
Error

Line: 15 Column: 1

              )
import warnings

import pandas._libs.json as json
from pandas._typing import (
    DtypeObj,
    FrameOrSeries,
    JSONSerializable,
)

            

Reported by Pylint.

Unable to import 'pandas._libs.json'
Error

Line: 15 Column: 1

              )
import warnings

import pandas._libs.json as json
from pandas._typing import (
    DtypeObj,
    FrameOrSeries,
    JSONSerializable,
)

            

Reported by Pylint.

Unused variable 'column'
Error

Line: 277 Column: 13

                          fields.append(convert_pandas_type_to_json_field(data.index))

    if data.ndim > 1:
        for column, s in data.items():
            fields.append(convert_pandas_type_to_json_field(s))
    else:
        fields.append(convert_pandas_type_to_json_field(data))

    schema["fields"] = fields

            

Reported by Pylint.

Redefining name 'json' from outer scope (line 15)
Error

Line: 296 Column: 24

                  return schema


def parse_table_schema(json, precise_float):
    """
    Builds a DataFrame from a given schema

    Parameters
    ----------

            

Reported by Pylint.

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

Line: 44 Column: 1

              loads = json.loads


def as_json_table_type(x: DtypeObj) -> str:
    """
    Convert a NumPy / pandas type to its corresponding json_table.

    Parameters
    ----------

            

Reported by Pylint.

Too many return statements (8/6)
Error

Line: 44 Column: 1

              loads = json.loads


def as_json_table_type(x: DtypeObj) -> str:
    """
    Convert a NumPy / pandas type to its corresponding json_table.

    Parameters
    ----------

            

Reported by Pylint.

Unnecessary "elif" after "return"
Error

Line: 74 Column: 5

                  categorical     any
    =============== =================
    """
    if is_integer_dtype(x):
        return "integer"
    elif is_bool_dtype(x):
        return "boolean"
    elif is_numeric_dtype(x):
        return "number"

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 114 Column: 1

                  return data


def convert_pandas_type_to_json_field(arr):
    dtype = arr.dtype
    if arr.name is None:
        name = "values"
    else:
        name = arr.name

            

Reported by Pylint.

Too many return statements (9/6)
Error

Line: 138 Column: 1

                  return field


def convert_json_field_to_pandas_type(field):
    """
    Converts a JSON field descriptor into its corresponding NumPy / pandas type

    Parameters
    ----------

            

Reported by Pylint.

Unnecessary "elif" after "return"
Error

Line: 180 Column: 5

                  'datetime64[ns, US/Central]'
    """
    typ = field["type"]
    if typ == "string":
        return "object"
    elif typ == "integer":
        return "int64"
    elif typ == "number":
        return "float64"

            

Reported by Pylint.

pandas/tests/extension/base/reduce.py
17 issues
Unable to import 'pytest'
Error

Line: 3 Column: 1

              import warnings

import pytest

import pandas as pd
import pandas._testing as tm
from pandas.tests.extension.base.base import BaseExtensionTests



            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import warnings

import pytest

import pandas as pd
import pandas._testing as tm
from pandas.tests.extension.base.base import BaseExtensionTests



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 16 Column: 5

                  make sense for numeric/boolean operations.
    """

    def check_reduce(self, s, op_name, skipna):
        result = getattr(s, op_name)(skipna=skipna)
        expected = getattr(s.astype("float64"), op_name)(skipna=skipna)
        tm.assert_almost_equal(result, expected)



            

Reported by Pylint.

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

Line: 16 Column: 5

                  make sense for numeric/boolean operations.
    """

    def check_reduce(self, s, op_name, skipna):
        result = getattr(s, op_name)(skipna=skipna)
        expected = getattr(s.astype("float64"), op_name)(skipna=skipna)
        tm.assert_almost_equal(result, expected)



            

Reported by Pylint.

Method could be a function
Error

Line: 16 Column: 5

                  make sense for numeric/boolean operations.
    """

    def check_reduce(self, s, op_name, skipna):
        result = getattr(s, op_name)(skipna=skipna)
        expected = getattr(s.astype("float64"), op_name)(skipna=skipna)
        tm.assert_almost_equal(result, expected)



            

Reported by Pylint.

Missing function or method docstring
Error

Line: 26 Column: 5

                  """we don't define any reductions"""

    @pytest.mark.parametrize("skipna", [True, False])
    def test_reduce_series_numeric(self, data, all_numeric_reductions, skipna):
        op_name = all_numeric_reductions
        s = pd.Series(data)

        msg = (
            "[Cc]annot perform|Categorical is not ordered for operation|"

            

Reported by Pylint.

Method could be a function
Error

Line: 26 Column: 5

                  """we don't define any reductions"""

    @pytest.mark.parametrize("skipna", [True, False])
    def test_reduce_series_numeric(self, data, all_numeric_reductions, skipna):
        op_name = all_numeric_reductions
        s = pd.Series(data)

        msg = (
            "[Cc]annot perform|Categorical is not ordered for operation|"

            

Reported by Pylint.

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

Line: 28 Column: 9

                  @pytest.mark.parametrize("skipna", [True, False])
    def test_reduce_series_numeric(self, data, all_numeric_reductions, skipna):
        op_name = all_numeric_reductions
        s = pd.Series(data)

        msg = (
            "[Cc]annot perform|Categorical is not ordered for operation|"
            "'Categorical' does not implement reduction|"
        )

            

Reported by Pylint.

Method could be a function
Error

Line: 39 Column: 5

                          getattr(s, op_name)(skipna=skipna)

    @pytest.mark.parametrize("skipna", [True, False])
    def test_reduce_series_boolean(self, data, all_boolean_reductions, skipna):
        op_name = all_boolean_reductions
        s = pd.Series(data)

        msg = (
            "[Cc]annot perform|Categorical is not ordered for operation|"

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 39 Column: 5

                          getattr(s, op_name)(skipna=skipna)

    @pytest.mark.parametrize("skipna", [True, False])
    def test_reduce_series_boolean(self, data, all_boolean_reductions, skipna):
        op_name = all_boolean_reductions
        s = pd.Series(data)

        msg = (
            "[Cc]annot perform|Categorical is not ordered for operation|"

            

Reported by Pylint.

pandas/tests/frame/methods/test_to_numpy.py
17 issues
Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np

import pandas.util._test_decorators as td

from pandas import (
    DataFrame,
    Timestamp,
)
import pandas._testing as tm

            

Reported by Pylint.

Missing class docstring
Error

Line: 12 Column: 1

              import pandas._testing as tm


class TestToNumpy:
    def test_to_numpy(self):
        df = DataFrame({"A": [1, 2], "B": [3, 4.5]})
        expected = np.array([[1, 3], [2, 4.5]])
        result = df.to_numpy()
        tm.assert_numpy_array_equal(result, expected)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 5

              

class TestToNumpy:
    def test_to_numpy(self):
        df = DataFrame({"A": [1, 2], "B": [3, 4.5]})
        expected = np.array([[1, 3], [2, 4.5]])
        result = df.to_numpy()
        tm.assert_numpy_array_equal(result, expected)


            

Reported by Pylint.

Method could be a function
Error

Line: 13 Column: 5

              

class TestToNumpy:
    def test_to_numpy(self):
        df = DataFrame({"A": [1, 2], "B": [3, 4.5]})
        expected = np.array([[1, 3], [2, 4.5]])
        result = df.to_numpy()
        tm.assert_numpy_array_equal(result, expected)


            

Reported by Pylint.

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

Line: 14 Column: 9

              
class TestToNumpy:
    def test_to_numpy(self):
        df = DataFrame({"A": [1, 2], "B": [3, 4.5]})
        expected = np.array([[1, 3], [2, 4.5]])
        result = df.to_numpy()
        tm.assert_numpy_array_equal(result, expected)

    def test_to_numpy_dtype(self):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 19 Column: 5

                      result = df.to_numpy()
        tm.assert_numpy_array_equal(result, expected)

    def test_to_numpy_dtype(self):
        df = DataFrame({"A": [1, 2], "B": [3, 4.5]})
        expected = np.array([[1, 3], [2, 4]], dtype="int64")
        result = df.to_numpy(dtype="int64")
        tm.assert_numpy_array_equal(result, expected)


            

Reported by Pylint.

Method could be a function
Error

Line: 19 Column: 5

                      result = df.to_numpy()
        tm.assert_numpy_array_equal(result, expected)

    def test_to_numpy_dtype(self):
        df = DataFrame({"A": [1, 2], "B": [3, 4.5]})
        expected = np.array([[1, 3], [2, 4]], dtype="int64")
        result = df.to_numpy(dtype="int64")
        tm.assert_numpy_array_equal(result, expected)


            

Reported by Pylint.

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

Line: 20 Column: 9

                      tm.assert_numpy_array_equal(result, expected)

    def test_to_numpy_dtype(self):
        df = DataFrame({"A": [1, 2], "B": [3, 4.5]})
        expected = np.array([[1, 3], [2, 4]], dtype="int64")
        result = df.to_numpy(dtype="int64")
        tm.assert_numpy_array_equal(result, expected)

    @td.skip_array_manager_invalid_test

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 26 Column: 5

                      tm.assert_numpy_array_equal(result, expected)

    @td.skip_array_manager_invalid_test
    def test_to_numpy_copy(self):
        arr = np.random.randn(4, 3)
        df = DataFrame(arr)
        assert df.values.base is arr
        assert df.to_numpy(copy=False).base is arr
        assert df.to_numpy(copy=True).base is not arr

            

Reported by Pylint.

Method could be a function
Error

Line: 26 Column: 5

                      tm.assert_numpy_array_equal(result, expected)

    @td.skip_array_manager_invalid_test
    def test_to_numpy_copy(self):
        arr = np.random.randn(4, 3)
        df = DataFrame(arr)
        assert df.values.base is arr
        assert df.to_numpy(copy=False).base is arr
        assert df.to_numpy(copy=True).base is not arr

            

Reported by Pylint.

pandas/tests/frame/methods/test_value_counts.py
17 issues
Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np

import pandas as pd
import pandas._testing as tm


def test_data_frame_value_counts_unsorted():
    df = pd.DataFrame(
        {"num_legs": [2, 4, 4, 6], "num_wings": [2, 0, 0, 0]},

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 7 Column: 1

              import pandas._testing as tm


def test_data_frame_value_counts_unsorted():
    df = pd.DataFrame(
        {"num_legs": [2, 4, 4, 6], "num_wings": [2, 0, 0, 0]},
        index=["falcon", "dog", "cat", "ant"],
    )


            

Reported by Pylint.

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

Line: 8 Column: 5

              

def test_data_frame_value_counts_unsorted():
    df = pd.DataFrame(
        {"num_legs": [2, 4, 4, 6], "num_wings": [2, 0, 0, 0]},
        index=["falcon", "dog", "cat", "ant"],
    )

    result = df.value_counts(sort=False)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 24 Column: 1

                  tm.assert_series_equal(result, expected)


def test_data_frame_value_counts_ascending():
    df = pd.DataFrame(
        {"num_legs": [2, 4, 4, 6], "num_wings": [2, 0, 0, 0]},
        index=["falcon", "dog", "cat", "ant"],
    )


            

Reported by Pylint.

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

Line: 25 Column: 5

              

def test_data_frame_value_counts_ascending():
    df = pd.DataFrame(
        {"num_legs": [2, 4, 4, 6], "num_wings": [2, 0, 0, 0]},
        index=["falcon", "dog", "cat", "ant"],
    )

    result = df.value_counts(ascending=True)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 41 Column: 1

                  tm.assert_series_equal(result, expected)


def test_data_frame_value_counts_default():
    df = pd.DataFrame(
        {"num_legs": [2, 4, 4, 6], "num_wings": [2, 0, 0, 0]},
        index=["falcon", "dog", "cat", "ant"],
    )


            

Reported by Pylint.

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

Line: 42 Column: 5

              

def test_data_frame_value_counts_default():
    df = pd.DataFrame(
        {"num_legs": [2, 4, 4, 6], "num_wings": [2, 0, 0, 0]},
        index=["falcon", "dog", "cat", "ant"],
    )

    result = df.value_counts()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 58 Column: 1

                  tm.assert_series_equal(result, expected)


def test_data_frame_value_counts_normalize():
    df = pd.DataFrame(
        {"num_legs": [2, 4, 4, 6], "num_wings": [2, 0, 0, 0]},
        index=["falcon", "dog", "cat", "ant"],
    )


            

Reported by Pylint.

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

Line: 59 Column: 5

              

def test_data_frame_value_counts_normalize():
    df = pd.DataFrame(
        {"num_legs": [2, 4, 4, 6], "num_wings": [2, 0, 0, 0]},
        index=["falcon", "dog", "cat", "ant"],
    )

    result = df.value_counts(normalize=True)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 75 Column: 1

                  tm.assert_series_equal(result, expected)


def test_data_frame_value_counts_single_col_default():
    df = pd.DataFrame({"num_legs": [2, 4, 4, 6]})

    result = df.value_counts()
    expected = pd.Series(
        data=[2, 1, 1],

            

Reported by Pylint.

pandas/tests/indexes/base_class/test_formats.py
17 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

import pandas._config.config as cf

from pandas import Index


class TestIndexRendering:

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

import pandas._config.config as cf

from pandas import Index


class TestIndexRendering:

            

Reported by Pylint.

Missing class docstring
Error

Line: 9 Column: 1

              from pandas import Index


class TestIndexRendering:
    @pytest.mark.parametrize(
        "index,expected",
        [
            # ASCII
            # short

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 61 Column: 5

                              Index(["あ", "いい", "ううう"] * 100),
                (
                    "Index(['あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', "
                    "'あ', 'いい', 'ううう', 'あ',\n"
                    "       ...\n"
                    "       'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', "
                    "'ううう', 'あ', 'いい', 'ううう'],\n"
                    "      dtype='object', length=300)"
                ),

            

Reported by Pylint.

Method could be a function
Error

Line: 61 Column: 5

                              Index(["あ", "いい", "ううう"] * 100),
                (
                    "Index(['あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', "
                    "'あ', 'いい', 'ううう', 'あ',\n"
                    "       ...\n"
                    "       'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', "
                    "'ううう', 'あ', 'いい', 'ううう'],\n"
                    "      dtype='object', length=300)"
                ),

            

Reported by Pylint.

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

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

                  )
    def test_string_index_repr(self, index, expected):
        result = repr(index)
        assert result == expected

    @pytest.mark.parametrize(
        "index,expected",
        [
            # short

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 102 Column: 5

                              Index(["あ", "いい", "ううう"] * 100),
                (
                    "Index(['あ', 'いい', 'ううう', 'あ', 'いい', "
                    "'ううう', 'あ', 'いい', 'ううう',\n"
                    "       'あ',\n"
                    "       ...\n"
                    "       'ううう', 'あ', 'いい', 'ううう', 'あ', "
                    "'いい', 'ううう', 'あ', 'いい',\n"
                    "       'ううう'],\n"

            

Reported by Pylint.

Method could be a function
Error

Line: 102 Column: 5

                              Index(["あ", "いい", "ううう"] * 100),
                (
                    "Index(['あ', 'いい', 'ううう', 'あ', 'いい', "
                    "'ううう', 'あ', 'いい', 'ううう',\n"
                    "       'あ',\n"
                    "       ...\n"
                    "       'ううう', 'あ', 'いい', 'ううう', 'あ', "
                    "'いい', 'ううう', 'あ', 'いい',\n"
                    "       'ううう'],\n"

            

Reported by Pylint.

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

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

                      # Enable Unicode option -----------------------------------------
        with cf.option_context("display.unicode.east_asian_width", True):
            result = repr(index)
            assert result == expected

    def test_repr_summary(self):
        with cf.option_context("display.max_seq_items", 10):
            result = repr(Index(np.arange(1000)))
            assert len(result) < 200

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 119 Column: 5

                          result = repr(index)
            assert result == expected

    def test_repr_summary(self):
        with cf.option_context("display.max_seq_items", 10):
            result = repr(Index(np.arange(1000)))
            assert len(result) < 200
            assert "..." in result


            

Reported by Pylint.