The following issues were found

asv_bench/benchmarks/array.py
22 issues
Unable to import 'pandas'
Error

Line: 3 Column: 1

              import numpy as np

import pandas as pd


class BooleanArray:
    def setup(self):
        self.values_bool = np.array([True, False, True, False])
        self.values_float = np.array([1.0, 0.0, 1.0, 0.0])

            

Reported by Pylint.

Attribute 'values_bool' defined outside __init__
Error

Line: 8 Column: 9

              
class BooleanArray:
    def setup(self):
        self.values_bool = np.array([True, False, True, False])
        self.values_float = np.array([1.0, 0.0, 1.0, 0.0])
        self.values_integer = np.array([1, 0, 1, 0])
        self.values_integer_like = [1, 0, 1, 0]
        self.data = np.array([True, False, True, False])
        self.mask = np.array([False, False, True, False])

            

Reported by Pylint.

Attribute 'values_float' defined outside __init__
Error

Line: 9 Column: 9

              class BooleanArray:
    def setup(self):
        self.values_bool = np.array([True, False, True, False])
        self.values_float = np.array([1.0, 0.0, 1.0, 0.0])
        self.values_integer = np.array([1, 0, 1, 0])
        self.values_integer_like = [1, 0, 1, 0]
        self.data = np.array([True, False, True, False])
        self.mask = np.array([False, False, True, False])


            

Reported by Pylint.

Attribute 'values_integer' defined outside __init__
Error

Line: 10 Column: 9

                  def setup(self):
        self.values_bool = np.array([True, False, True, False])
        self.values_float = np.array([1.0, 0.0, 1.0, 0.0])
        self.values_integer = np.array([1, 0, 1, 0])
        self.values_integer_like = [1, 0, 1, 0]
        self.data = np.array([True, False, True, False])
        self.mask = np.array([False, False, True, False])

    def time_constructor(self):

            

Reported by Pylint.

Attribute 'values_integer_like' defined outside __init__
Error

Line: 11 Column: 9

                      self.values_bool = np.array([True, False, True, False])
        self.values_float = np.array([1.0, 0.0, 1.0, 0.0])
        self.values_integer = np.array([1, 0, 1, 0])
        self.values_integer_like = [1, 0, 1, 0]
        self.data = np.array([True, False, True, False])
        self.mask = np.array([False, False, True, False])

    def time_constructor(self):
        pd.arrays.BooleanArray(self.data, self.mask)

            

Reported by Pylint.

Attribute 'data' defined outside __init__
Error

Line: 12 Column: 9

                      self.values_float = np.array([1.0, 0.0, 1.0, 0.0])
        self.values_integer = np.array([1, 0, 1, 0])
        self.values_integer_like = [1, 0, 1, 0]
        self.data = np.array([True, False, True, False])
        self.mask = np.array([False, False, True, False])

    def time_constructor(self):
        pd.arrays.BooleanArray(self.data, self.mask)


            

Reported by Pylint.

Attribute 'mask' defined outside __init__
Error

Line: 13 Column: 9

                      self.values_integer = np.array([1, 0, 1, 0])
        self.values_integer_like = [1, 0, 1, 0]
        self.data = np.array([True, False, True, False])
        self.mask = np.array([False, False, True, False])

    def time_constructor(self):
        pd.arrays.BooleanArray(self.data, self.mask)

    def time_from_bool_array(self):

            

Reported by Pylint.

Attribute 'values_integer' defined outside __init__
Error

Line: 33 Column: 9

              
class IntegerArray:
    def setup(self):
        self.values_integer = np.array([1, 0, 1, 0])
        self.data = np.array([1, 2, 3, 4], dtype="int64")
        self.mask = np.array([False, False, True, False])

    def time_constructor(self):
        pd.arrays.IntegerArray(self.data, self.mask)

            

Reported by Pylint.

Attribute 'data' defined outside __init__
Error

Line: 34 Column: 9

              class IntegerArray:
    def setup(self):
        self.values_integer = np.array([1, 0, 1, 0])
        self.data = np.array([1, 2, 3, 4], dtype="int64")
        self.mask = np.array([False, False, True, False])

    def time_constructor(self):
        pd.arrays.IntegerArray(self.data, self.mask)


            

Reported by Pylint.

Attribute 'mask' defined outside __init__
Error

Line: 35 Column: 9

                  def setup(self):
        self.values_integer = np.array([1, 0, 1, 0])
        self.data = np.array([1, 2, 3, 4], dtype="int64")
        self.mask = np.array([False, False, True, False])

    def time_constructor(self):
        pd.arrays.IntegerArray(self.data, self.mask)

    def time_from_integer_array(self):

            

Reported by Pylint.

pandas/core/window/common.py
22 issues
Access to a protected member _values of a client class
Error

Line: 138 Column: 12

                      mask = x < 0

    if isinstance(x, ABCDataFrame):
        if mask._values.any():
            result[mask] = 0
    else:
        if mask.any():
            result[mask] = 0


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 15 Column: 1

              from pandas.core.indexes.api import MultiIndex


def flex_binary_moment(arg1, arg2, f, pairwise=False):

    if isinstance(arg1, ABCSeries) and isinstance(arg2, ABCSeries):
        X, Y = prep_binary(arg1, arg2)
        return f(X, Y)


            

Reported by Pylint.

Too many local variables (18/15)
Error

Line: 15 Column: 1

              from pandas.core.indexes.api import MultiIndex


def flex_binary_moment(arg1, arg2, f, pairwise=False):

    if isinstance(arg1, ABCSeries) and isinstance(arg2, ABCSeries):
        X, Y = prep_binary(arg1, arg2)
        return f(X, Y)


            

Reported by Pylint.

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

Line: 15 Column: 1

              from pandas.core.indexes.api import MultiIndex


def flex_binary_moment(arg1, arg2, f, pairwise=False):

    if isinstance(arg1, ABCSeries) and isinstance(arg2, ABCSeries):
        X, Y = prep_binary(arg1, arg2)
        return f(X, Y)


            

Reported by Pylint.

Either all return statements in a function should return an expression, or none of them should.
Error

Line: 15 Column: 1

              from pandas.core.indexes.api import MultiIndex


def flex_binary_moment(arg1, arg2, f, pairwise=False):

    if isinstance(arg1, ABCSeries) and isinstance(arg2, ABCSeries):
        X, Y = prep_binary(arg1, arg2)
        return f(X, Y)


            

Reported by Pylint.

Too many branches (22/12)
Error

Line: 15 Column: 1

              from pandas.core.indexes.api import MultiIndex


def flex_binary_moment(arg1, arg2, f, pairwise=False):

    if isinstance(arg1, ABCSeries) and isinstance(arg2, ABCSeries):
        X, Y = prep_binary(arg1, arg2)
        return f(X, Y)


            

Reported by Pylint.

Too many statements (51/50)
Error

Line: 15 Column: 1

              from pandas.core.indexes.api import MultiIndex


def flex_binary_moment(arg1, arg2, f, pairwise=False):

    if isinstance(arg1, ABCSeries) and isinstance(arg2, ABCSeries):
        X, Y = prep_binary(arg1, arg2)
        return f(X, Y)


            

Reported by Pylint.

Unnecessary "elif" after "return"
Error

Line: 17 Column: 5

              
def flex_binary_moment(arg1, arg2, f, pairwise=False):

    if isinstance(arg1, ABCSeries) and isinstance(arg2, ABCSeries):
        X, Y = prep_binary(arg1, arg2)
        return f(X, Y)

    elif isinstance(arg1, ABCDataFrame):
        from pandas import DataFrame

            

Reported by Pylint.

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

Line: 18 Column: 12

              def flex_binary_moment(arg1, arg2, f, pairwise=False):

    if isinstance(arg1, ABCSeries) and isinstance(arg2, ABCSeries):
        X, Y = prep_binary(arg1, arg2)
        return f(X, Y)

    elif isinstance(arg1, ABCDataFrame):
        from pandas import DataFrame


            

Reported by Pylint.

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

Line: 18 Column: 9

              def flex_binary_moment(arg1, arg2, f, pairwise=False):

    if isinstance(arg1, ABCSeries) and isinstance(arg2, ABCSeries):
        X, Y = prep_binary(arg1, arg2)
        return f(X, Y)

    elif isinstance(arg1, ABCDataFrame):
        from pandas import DataFrame


            

Reported by Pylint.

pandas/_libs/tslibs/__init__.py
22 issues
No name 'conversion' in module 'pandas._libs.tslibs'
Error

Line: 31 Column: 1

              ]

from pandas._libs.tslibs import dtypes
from pandas._libs.tslibs.conversion import (
    OutOfBoundsTimedelta,
    localize_pydatetime,
)
from pandas._libs.tslibs.dtypes import Resolution
from pandas._libs.tslibs.nattype import (

            

Reported by Pylint.

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

Line: 31 Column: 1

              ]

from pandas._libs.tslibs import dtypes
from pandas._libs.tslibs.conversion import (
    OutOfBoundsTimedelta,
    localize_pydatetime,
)
from pandas._libs.tslibs.dtypes import Resolution
from pandas._libs.tslibs.nattype import (

            

Reported by Pylint.

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

Line: 35 Column: 1

                  OutOfBoundsTimedelta,
    localize_pydatetime,
)
from pandas._libs.tslibs.dtypes import Resolution
from pandas._libs.tslibs.nattype import (
    NaT,
    NaTType,
    iNaT,
    is_null_datetimelike,

            

Reported by Pylint.

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

Line: 36 Column: 1

                  localize_pydatetime,
)
from pandas._libs.tslibs.dtypes import Resolution
from pandas._libs.tslibs.nattype import (
    NaT,
    NaTType,
    iNaT,
    is_null_datetimelike,
    nat_strings,

            

Reported by Pylint.

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

Line: 36 Column: 1

                  localize_pydatetime,
)
from pandas._libs.tslibs.dtypes import Resolution
from pandas._libs.tslibs.nattype import (
    NaT,
    NaTType,
    iNaT,
    is_null_datetimelike,
    nat_strings,

            

Reported by Pylint.

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

Line: 43 Column: 1

                  is_null_datetimelike,
    nat_strings,
)
from pandas._libs.tslibs.np_datetime import OutOfBoundsDatetime
from pandas._libs.tslibs.offsets import (
    BaseOffset,
    Tick,
    to_offset,
)

            

Reported by Pylint.

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

Line: 43 Column: 1

                  is_null_datetimelike,
    nat_strings,
)
from pandas._libs.tslibs.np_datetime import OutOfBoundsDatetime
from pandas._libs.tslibs.offsets import (
    BaseOffset,
    Tick,
    to_offset,
)

            

Reported by Pylint.

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

Line: 44 Column: 1

                  nat_strings,
)
from pandas._libs.tslibs.np_datetime import OutOfBoundsDatetime
from pandas._libs.tslibs.offsets import (
    BaseOffset,
    Tick,
    to_offset,
)
from pandas._libs.tslibs.period import (

            

Reported by Pylint.

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

Line: 44 Column: 1

                  nat_strings,
)
from pandas._libs.tslibs.np_datetime import OutOfBoundsDatetime
from pandas._libs.tslibs.offsets import (
    BaseOffset,
    Tick,
    to_offset,
)
from pandas._libs.tslibs.period import (

            

Reported by Pylint.

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

Line: 49 Column: 1

                  Tick,
    to_offset,
)
from pandas._libs.tslibs.period import (
    IncompatibleFrequency,
    Period,
)
from pandas._libs.tslibs.timedeltas import (
    Timedelta,

            

Reported by Pylint.

pandas/_libs/src/ujson/python/objToJSON.c
21 issues
snprintf - If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate
Security

Line: 1332 Column: 21 CWE codes: 134
Suggestion: Use a constant for the format specification

                              } else {
                    int size_of_cLabel = 21;  // 21 chars for int 64
                    cLabel = PyObject_Malloc(size_of_cLabel);
                    snprintf(cLabel, size_of_cLabel, "%" NPY_DATETIME_FMT,
                            NpyDateTimeToEpoch(nanosecVal, base));
                    len = strlen(cLabel);
                }
            }
        } else {  // Fallback to string representation

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 1008 Column: 9 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                  index = GET_TC(tc)->index;
    Py_XDECREF(GET_TC(tc)->itemValue);
    if (index == 0) {
        memcpy(GET_TC(tc)->cStr, "name", sizeof(char) * 5);
        GET_TC(tc)->itemValue = PyObject_GetAttrString(obj, "name");
    } else if (index == 1) {
        memcpy(GET_TC(tc)->cStr, "data", sizeof(char) * 5);
        GET_TC(tc)->itemValue = get_values(obj);
        if (!GET_TC(tc)->itemValue) {

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 1011 Column: 9 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                      memcpy(GET_TC(tc)->cStr, "name", sizeof(char) * 5);
        GET_TC(tc)->itemValue = PyObject_GetAttrString(obj, "name");
    } else if (index == 1) {
        memcpy(GET_TC(tc)->cStr, "data", sizeof(char) * 5);
        GET_TC(tc)->itemValue = get_values(obj);
        if (!GET_TC(tc)->itemValue) {
            return 0;
        }
    } else {

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 1058 Column: 9 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                  index = GET_TC(tc)->index;
    Py_XDECREF(GET_TC(tc)->itemValue);
    if (index == 0) {
        memcpy(GET_TC(tc)->cStr, "name", sizeof(char) * 5);
        GET_TC(tc)->itemValue = PyObject_GetAttrString(obj, "name");
    } else if (index == 1) {
        memcpy(GET_TC(tc)->cStr, "index", sizeof(char) * 6);
        GET_TC(tc)->itemValue = PyObject_GetAttrString(obj, "index");
    } else if (index == 2) {

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 1061 Column: 9 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                      memcpy(GET_TC(tc)->cStr, "name", sizeof(char) * 5);
        GET_TC(tc)->itemValue = PyObject_GetAttrString(obj, "name");
    } else if (index == 1) {
        memcpy(GET_TC(tc)->cStr, "index", sizeof(char) * 6);
        GET_TC(tc)->itemValue = PyObject_GetAttrString(obj, "index");
    } else if (index == 2) {
        memcpy(GET_TC(tc)->cStr, "data", sizeof(char) * 5);
        GET_TC(tc)->itemValue = get_values(obj);
        if (!GET_TC(tc)->itemValue) {

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 1064 Column: 9 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                      memcpy(GET_TC(tc)->cStr, "index", sizeof(char) * 6);
        GET_TC(tc)->itemValue = PyObject_GetAttrString(obj, "index");
    } else if (index == 2) {
        memcpy(GET_TC(tc)->cStr, "data", sizeof(char) * 5);
        GET_TC(tc)->itemValue = get_values(obj);
        if (!GET_TC(tc)->itemValue) {
            return 0;
        }
    } else {

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 1114 Column: 9 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                  index = GET_TC(tc)->index;
    Py_XDECREF(GET_TC(tc)->itemValue);
    if (index == 0) {
        memcpy(GET_TC(tc)->cStr, "columns", sizeof(char) * 8);
        GET_TC(tc)->itemValue = PyObject_GetAttrString(obj, "columns");
    } else if (index == 1) {
        memcpy(GET_TC(tc)->cStr, "index", sizeof(char) * 6);
        GET_TC(tc)->itemValue = PyObject_GetAttrString(obj, "index");
    } else if (index == 2) {

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 1117 Column: 9 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                      memcpy(GET_TC(tc)->cStr, "columns", sizeof(char) * 8);
        GET_TC(tc)->itemValue = PyObject_GetAttrString(obj, "columns");
    } else if (index == 1) {
        memcpy(GET_TC(tc)->cStr, "index", sizeof(char) * 6);
        GET_TC(tc)->itemValue = PyObject_GetAttrString(obj, "index");
    } else if (index == 2) {
        memcpy(GET_TC(tc)->cStr, "data", sizeof(char) * 5);
        if (is_simple_frame(obj)) {
            GET_TC(tc)->itemValue = PyObject_GetAttrString(obj, "values");

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 1120 Column: 9 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                      memcpy(GET_TC(tc)->cStr, "index", sizeof(char) * 6);
        GET_TC(tc)->itemValue = PyObject_GetAttrString(obj, "index");
    } else if (index == 2) {
        memcpy(GET_TC(tc)->cStr, "data", sizeof(char) * 5);
        if (is_simple_frame(obj)) {
            GET_TC(tc)->itemValue = PyObject_GetAttrString(obj, "values");
            if (!GET_TC(tc)->itemValue) {
                return 0;
            }

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 1352 Column: 9 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

              
        // Add 1 to include NULL terminator
        ret[i] = PyObject_Malloc(len + 1);
        memcpy(ret[i], cLabel, len + 1);
        Py_DECREF(item);

        if (is_datetimelike) {
            PyObject_Free(cLabel);
        }

            

Reported by FlawFinder.

asv_bench/benchmarks/tslibs/offsets.py
21 issues
Unable to import 'pandas'
Error

Line: 9 Column: 1

              
import numpy as np

from pandas import offsets

try:
    import pandas.tseries.holiday
except ImportError:
    pass

            

Reported by Pylint.

Unused argument 'offset'
Error

Line: 52 Column: 21

                  params = offset_objs
    param_names = ["offset"]

    def setup(self, offset):
        self.dates = [
            datetime(2016, m, d)
            for m in [10, 11, 12]
            for d in [1, 2, 3, 28, 29, 30, 31]
            if not (m == 11 and d == 31)

            

Reported by Pylint.

Attribute 'dates' defined outside __init__
Error

Line: 53 Column: 9

                  param_names = ["offset"]

    def setup(self, offset):
        self.dates = [
            datetime(2016, m, d)
            for m in [10, 11, 12]
            for d in [1, 2, 3, 28, 29, 30, 31]
            if not (m == 11 and d == 31)
        ]

            

Reported by Pylint.

Unused argument 'offset'
Error

Line: 70 Column: 21

                  params = offset_objs
    param_names = ["offset"]

    def setup(self, offset):
        self.date = datetime(2011, 1, 1)
        self.dt64 = np.datetime64("2011-01-01 09:00Z")

    def time_apply(self, offset):
        offset.apply(self.date)

            

Reported by Pylint.

Attribute 'date' defined outside __init__
Error

Line: 71 Column: 9

                  param_names = ["offset"]

    def setup(self, offset):
        self.date = datetime(2011, 1, 1)
        self.dt64 = np.datetime64("2011-01-01 09:00Z")

    def time_apply(self, offset):
        offset.apply(self.date)


            

Reported by Pylint.

Attribute 'dt64' defined outside __init__
Error

Line: 72 Column: 9

              
    def setup(self, offset):
        self.date = datetime(2011, 1, 1)
        self.dt64 = np.datetime64("2011-01-01 09:00Z")

    def time_apply(self, offset):
        offset.apply(self.date)

    def time_apply_np_dt64(self, offset):

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 81 Column: 9

                      offset.apply(self.dt64)

    def time_add(self, offset):
        self.date + offset

    def time_add_10(self, offset):
        self.date + (10 * offset)

    def time_subtract(self, offset):

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 84 Column: 9

                      self.date + offset

    def time_add_10(self, offset):
        self.date + (10 * offset)

    def time_subtract(self, offset):
        self.date - offset

    def time_subtract_10(self, offset):

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 87 Column: 9

                      self.date + (10 * offset)

    def time_subtract(self, offset):
        self.date - offset

    def time_subtract_10(self, offset):
        self.date - (10 * offset)

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 90 Column: 9

                      self.date - offset

    def time_subtract_10(self, offset):
        self.date - (10 * offset)

            

Reported by Pylint.

pandas/tests/frame/methods/test_convert.py
21 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

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


            

Reported by Pylint.

Access to a protected member _convert of a client class
Error

Line: 15 Column: 21

                  def test_convert_objects(self, float_string_frame):

        oops = float_string_frame.T.T
        converted = oops._convert(datetime=True)
        tm.assert_frame_equal(converted, float_string_frame)
        assert converted["A"].dtype == np.float64

        # force numeric conversion
        float_string_frame["H"] = "1."

            

Reported by Pylint.

Access to a protected member _convert of a client class
Error

Line: 28 Column: 21

                      float_string_frame["J"] = "1."
        float_string_frame["K"] = "1"
        float_string_frame.loc[float_string_frame.index[0:5], ["J", "K"]] = "garbled"
        converted = float_string_frame._convert(datetime=True, numeric=True)
        assert converted["H"].dtype == "float64"
        assert converted["I"].dtype == "int64"
        assert converted["J"].dtype == "float64"
        assert converted["K"].dtype == "float64"
        assert len(converted["J"].dropna()) == length - 5

            

Reported by Pylint.

Access to a protected member _convert of a client class
Error

Line: 50 Column: 18

              
        # mixed in a single column
        df = DataFrame({"s": Series([1, "na", 3, 4])})
        result = df._convert(datetime=True, numeric=True)
        expected = DataFrame({"s": Series([1, np.nan, 3, 4])})
        tm.assert_frame_equal(result, expected)

    def test_convert_objects_no_conversion(self):
        mixed1 = DataFrame({"a": [1, 2, 3], "b": [4.0, 5, 6], "c": ["x", "y", "z"]})

            

Reported by Pylint.

Access to a protected member _convert of a client class
Error

Line: 56 Column: 18

              
    def test_convert_objects_no_conversion(self):
        mixed1 = DataFrame({"a": [1, 2, 3], "b": [4.0, 5, 6], "c": ["x", "y", "z"]})
        mixed2 = mixed1._convert(datetime=True)
        tm.assert_frame_equal(mixed1, mixed2)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

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


            

Reported by Pylint.

Missing class docstring
Error

Line: 11 Column: 1

              import pandas._testing as tm


class TestConvert:
    def test_convert_objects(self, float_string_frame):

        oops = float_string_frame.T.T
        converted = oops._convert(datetime=True)
        tm.assert_frame_equal(converted, float_string_frame)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 12 Column: 5

              

class TestConvert:
    def test_convert_objects(self, float_string_frame):

        oops = float_string_frame.T.T
        converted = oops._convert(datetime=True)
        tm.assert_frame_equal(converted, float_string_frame)
        assert converted["A"].dtype == np.float64

            

Reported by Pylint.

Method could be a function
Error

Line: 12 Column: 5

              

class TestConvert:
    def test_convert_objects(self, float_string_frame):

        oops = float_string_frame.T.T
        converted = oops._convert(datetime=True)
        tm.assert_frame_equal(converted, float_string_frame)
        assert converted["A"].dtype == np.float64

            

Reported by Pylint.

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

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

                      oops = float_string_frame.T.T
        converted = oops._convert(datetime=True)
        tm.assert_frame_equal(converted, float_string_frame)
        assert converted["A"].dtype == np.float64

        # force numeric conversion
        float_string_frame["H"] = "1."
        float_string_frame["I"] = "1"


            

Reported by Bandit.

pandas/tests/frame/methods/test_dot.py
21 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

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


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

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


            

Reported by Pylint.

Missing class docstring
Error

Line: 11 Column: 1

              import pandas._testing as tm


class DotSharedTests:
    @pytest.fixture
    def obj(self):
        raise NotImplementedError

    @pytest.fixture

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 5

              
class DotSharedTests:
    @pytest.fixture
    def obj(self):
        raise NotImplementedError

    @pytest.fixture
    def other(self) -> DataFrame:
        """

            

Reported by Pylint.

Method could be a function
Error

Line: 37 Column: 5

                      """
        raise NotImplementedError

    def test_dot_equiv_values_dot(self, obj, other, expected):
        # `expected` is constructed from obj.values.dot(other.values)
        result = obj.dot(other)
        tm.assert_equal(result, expected)

    def test_dot_2d_ndarray(self, obj, other, expected):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 37 Column: 5

                      """
        raise NotImplementedError

    def test_dot_equiv_values_dot(self, obj, other, expected):
        # `expected` is constructed from obj.values.dot(other.values)
        result = obj.dot(other)
        tm.assert_equal(result, expected)

    def test_dot_2d_ndarray(self, obj, other, expected):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 42 Column: 5

                      result = obj.dot(other)
        tm.assert_equal(result, expected)

    def test_dot_2d_ndarray(self, obj, other, expected):
        # Check ndarray argument; in this case we get matching values,
        #  but index/columns may not match
        result = obj.dot(other.values)
        assert np.all(result == expected.values)


            

Reported by Pylint.

Method could be a function
Error

Line: 42 Column: 5

                      result = obj.dot(other)
        tm.assert_equal(result, expected)

    def test_dot_2d_ndarray(self, obj, other, expected):
        # Check ndarray argument; in this case we get matching values,
        #  but index/columns may not match
        result = obj.dot(other.values)
        assert np.all(result == expected.values)


            

Reported by Pylint.

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

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

                      # Check ndarray argument; in this case we get matching values,
        #  but index/columns may not match
        result = obj.dot(other.values)
        assert np.all(result == expected.values)

    def test_dot_1d_ndarray(self, obj, expected):
        # can pass correct-length array
        row = obj.iloc[0] if obj.ndim == 2 else obj


            

Reported by Bandit.

Missing function or method docstring
Error

Line: 48 Column: 5

                      result = obj.dot(other.values)
        assert np.all(result == expected.values)

    def test_dot_1d_ndarray(self, obj, expected):
        # can pass correct-length array
        row = obj.iloc[0] if obj.ndim == 2 else obj

        result = obj.dot(row.values)
        expected = obj.dot(row)

            

Reported by Pylint.

pandas/tests/indexes/categorical/test_astype.py
21 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              from datetime import date

import numpy as np
import pytest

from pandas import (
    Categorical,
    CategoricalDtype,
    CategoricalIndex,

            

Reported by Pylint.

Comparing against a callable, did you omit the parenthesis?
Error

Line: 81 Column: 16

                      v = date.today()

        obj = Index([v, v])
        assert obj.dtype == object

        cat = obj.astype("category")

        rtrip = cat.astype(object)
        assert rtrip.dtype == object

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from datetime import date

import numpy as np
import pytest

from pandas import (
    Categorical,
    CategoricalDtype,
    CategoricalIndex,

            

Reported by Pylint.

Missing class docstring
Error

Line: 16 Column: 1

              import pandas._testing as tm


class TestAstype:
    def test_astype(self):
        ci = CategoricalIndex(list("aabbca"), categories=list("cab"), ordered=False)

        result = ci.astype(object)
        tm.assert_index_equal(result, Index(np.array(ci)))

            

Reported by Pylint.

Method could be a function
Error

Line: 17 Column: 5

              

class TestAstype:
    def test_astype(self):
        ci = CategoricalIndex(list("aabbca"), categories=list("cab"), ordered=False)

        result = ci.astype(object)
        tm.assert_index_equal(result, Index(np.array(ci)))


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 5

              

class TestAstype:
    def test_astype(self):
        ci = CategoricalIndex(list("aabbca"), categories=list("cab"), ordered=False)

        result = ci.astype(object)
        tm.assert_index_equal(result, Index(np.array(ci)))


            

Reported by Pylint.

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

Line: 18 Column: 9

              
class TestAstype:
    def test_astype(self):
        ci = CategoricalIndex(list("aabbca"), categories=list("cab"), ordered=False)

        result = ci.astype(object)
        tm.assert_index_equal(result, Index(np.array(ci)))

        # this IS equal, but not the same class

            

Reported by Pylint.

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

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

                      tm.assert_index_equal(result, Index(np.array(ci)))

        # this IS equal, but not the same class
        assert result.equals(ci)
        assert isinstance(result, Index)
        assert not isinstance(result, CategoricalIndex)

        # interval
        ii = IntervalIndex.from_arrays(left=[-0.001, 2.0], right=[2, 4], closed="right")

            

Reported by Bandit.

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

              
        # this IS equal, but not the same class
        assert result.equals(ci)
        assert isinstance(result, Index)
        assert not isinstance(result, CategoricalIndex)

        # interval
        ii = IntervalIndex.from_arrays(left=[-0.001, 2.0], right=[2, 4], closed="right")


            

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

                      # this IS equal, but not the same class
        assert result.equals(ci)
        assert isinstance(result, Index)
        assert not isinstance(result, CategoricalIndex)

        # interval
        ii = IntervalIndex.from_arrays(left=[-0.001, 2.0], right=[2, 4], closed="right")

        ci = CategoricalIndex(

            

Reported by Bandit.

pandas/tests/frame/methods/test_set_axis.py
21 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

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


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

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


            

Reported by Pylint.

Missing class docstring
Error

Line: 11 Column: 1

              import pandas._testing as tm


class SharedSetAxisTests:
    @pytest.fixture
    def obj(self):
        raise NotImplementedError("Implemented by subclasses")

    def test_set_axis(self, obj):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 5

              
class SharedSetAxisTests:
    @pytest.fixture
    def obj(self):
        raise NotImplementedError("Implemented by subclasses")

    def test_set_axis(self, obj):
        # GH14636; this tests setting index for both Series and DataFrame
        new_index = list("abcd")[: len(obj)]

            

Reported by Pylint.

Method could be a function
Error

Line: 16 Column: 5

                  def obj(self):
        raise NotImplementedError("Implemented by subclasses")

    def test_set_axis(self, obj):
        # GH14636; this tests setting index for both Series and DataFrame
        new_index = list("abcd")[: len(obj)]

        expected = obj.copy()
        expected.index = new_index

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 16 Column: 5

                  def obj(self):
        raise NotImplementedError("Implemented by subclasses")

    def test_set_axis(self, obj):
        # GH14636; this tests setting index for both Series and DataFrame
        new_index = list("abcd")[: len(obj)]

        expected = obj.copy()
        expected.index = new_index

            

Reported by Pylint.

Method could be a function
Error

Line: 28 Column: 5

                      tm.assert_equal(expected, result)

    @pytest.mark.parametrize("axis", [0, "index", 1, "columns"])
    def test_set_axis_inplace_axis(self, axis, obj):
        # GH#14636
        if obj.ndim == 1 and axis in [1, "columns"]:
            # Series only has [0, "index"]
            return


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 28 Column: 5

                      tm.assert_equal(expected, result)

    @pytest.mark.parametrize("axis", [0, "index", 1, "columns"])
    def test_set_axis_inplace_axis(self, axis, obj):
        # GH#14636
        if obj.ndim == 1 and axis in [1, "columns"]:
            # Series only has [0, "index"]
            return


            

Reported by Pylint.

Method could be a function
Error

Line: 46 Column: 5

                      result.set_axis(new_index, axis=axis, inplace=True)
        tm.assert_equal(result, expected)

    def test_set_axis_unnamed_kwarg_warns(self, obj):
        # omitting the "axis" parameter
        new_index = list("abcd")[: len(obj)]

        expected = obj.copy()
        expected.index = new_index

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 46 Column: 5

                      result.set_axis(new_index, axis=axis, inplace=True)
        tm.assert_equal(result, expected)

    def test_set_axis_unnamed_kwarg_warns(self, obj):
        # omitting the "axis" parameter
        new_index = list("abcd")[: len(obj)]

        expected = obj.copy()
        expected.index = new_index

            

Reported by Pylint.

pandas/tests/extension/base/printing.py
21 issues
Unable to import 'pytest'
Error

Line: 3 Column: 1

              import io

import pytest

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


class BasePrintingTests(BaseExtensionTests):

            

Reported by Pylint.

Access to a protected member _concat_same_type of a client class
Error

Line: 17 Column: 20

                      if size == "small":
            data = data[:5]
        else:
            data = type(data)._concat_same_type([data] * 5)

        result = repr(data)
        assert type(data).__name__ in result
        assert f"Length: {len(data)}" in result
        assert str(data.dtype) in result

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import io

import pytest

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


class BasePrintingTests(BaseExtensionTests):

            

Reported by Pylint.

Method could be a function
Error

Line: 13 Column: 5

                  """Tests checking the formatting of your EA when printed."""

    @pytest.mark.parametrize("size", ["big", "small"])
    def test_array_repr(self, data, size):
        if size == "small":
            data = data[:5]
        else:
            data = type(data)._concat_same_type([data] * 5)


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 5

                  """Tests checking the formatting of your EA when printed."""

    @pytest.mark.parametrize("size", ["big", "small"])
    def test_array_repr(self, data, size):
        if size == "small":
            data = data[:5]
        else:
            data = type(data)._concat_same_type([data] * 5)


            

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

                          data = type(data)._concat_same_type([data] * 5)

        result = repr(data)
        assert type(data).__name__ in result
        assert f"Length: {len(data)}" in result
        assert str(data.dtype) in result
        if size == "big":
            assert "..." in result


            

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

              
        result = repr(data)
        assert type(data).__name__ in result
        assert f"Length: {len(data)}" in result
        assert str(data.dtype) in result
        if size == "big":
            assert "..." in result

    def test_array_repr_unicode(self, data):

            

Reported by Bandit.

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

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

                      result = repr(data)
        assert type(data).__name__ in result
        assert f"Length: {len(data)}" in result
        assert str(data.dtype) in result
        if size == "big":
            assert "..." in result

    def test_array_repr_unicode(self, data):
        result = str(data)

            

Reported by Bandit.

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

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

                      assert f"Length: {len(data)}" in result
        assert str(data.dtype) in result
        if size == "big":
            assert "..." in result

    def test_array_repr_unicode(self, data):
        result = str(data)
        assert isinstance(result, str)


            

Reported by Bandit.

Method could be a function
Error

Line: 26 Column: 5

                      if size == "big":
            assert "..." in result

    def test_array_repr_unicode(self, data):
        result = str(data)
        assert isinstance(result, str)

    def test_series_repr(self, data):
        ser = pd.Series(data)

            

Reported by Pylint.