The following issues were found
asv_bench/benchmarks/io/pickle.py
17 issues
Line: 3
Column: 1
import numpy as np
from pandas import (
DataFrame,
date_range,
read_pickle,
)
from ..pandas_vb_common import (
Reported by Pylint.
Line: 9
Column: 1
read_pickle,
)
from ..pandas_vb_common import (
BaseIO,
tm,
)
Reported by Pylint.
Line: 41
Column: 1
self.df.to_pickle(self.fname)
from ..pandas_vb_common import setup # noqa: F401 isort:skip
Reported by Pylint.
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.
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.
Line: 41
Column: 1
self.df.to_pickle(self.fname)
from ..pandas_vb_common import setup # noqa: F401 isort:skip
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
from pandas import (
DataFrame,
date_range,
read_pickle,
)
from ..pandas_vb_common import (
Reported by Pylint.
Line: 15
Column: 1
)
class Pickle(BaseIO):
def setup(self):
self.fname = "__test__.pkl"
N = 100000
C = 5
self.df = DataFrame(
Reported by Pylint.
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.
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
Line: 63
Column: 5
...
'EDT'
"""
import os
import time
def setTZ(tz):
if tz is None:
try:
Reported by Pylint.
Line: 63
Column: 5
...
'EDT'
"""
import os
import time
def setTZ(tz):
if tz is None:
try:
Reported by Pylint.
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.
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.
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.
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.
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.
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.
Line: 42
Column: 1
@contextmanager
def set_timezone(tz: str):
"""
Context manager for temporarily setting a timezone.
Parameters
----------
Reported by Pylint.
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
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.
Line: 248
Column: 5
def describe_categorical_1d(
data: Series,
percentiles_ignored: Sequence[float],
) -> Series:
"""Describe series containing categorical data.
Parameters
----------
Reported by Pylint.
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.
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.
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.
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.
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.
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.
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.
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
Line: 15
Column: 1
)
import warnings
import pandas._libs.json as json
from pandas._typing import (
DtypeObj,
FrameOrSeries,
JSONSerializable,
)
Reported by Pylint.
Line: 15
Column: 1
)
import warnings
import pandas._libs.json as json
from pandas._typing import (
DtypeObj,
FrameOrSeries,
JSONSerializable,
)
Reported by Pylint.
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.
Line: 296
Column: 24
return schema
def parse_table_schema(json, precise_float):
"""
Builds a DataFrame from a given schema
Parameters
----------
Reported by Pylint.
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.
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.
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.
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.
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.
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
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.
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.
Line: 9
Column: 1
from pandas import Index
class TestIndexRendering:
@pytest.mark.parametrize(
"index,expected",
[
# ASCII
# short
Reported by Pylint.
Line: 61
Column: 5
Index(["あ", "いい", "ううう"] * 100),
(
"Index(['あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', "
"'あ', 'いい', 'ううう', 'あ',\n"
" ...\n"
" 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', "
"'ううう', 'あ', 'いい', 'ううう'],\n"
" dtype='object', length=300)"
),
Reported by Pylint.
Line: 61
Column: 5
Index(["あ", "いい", "ううう"] * 100),
(
"Index(['あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', "
"'あ', 'いい', 'ううう', 'あ',\n"
" ...\n"
" 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', "
"'ううう', 'あ', 'いい', 'ううう'],\n"
" dtype='object', length=300)"
),
Reported by Pylint.
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.
Line: 102
Column: 5
Index(["あ", "いい", "ううう"] * 100),
(
"Index(['あ', 'いい', 'ううう', 'あ', 'いい', "
"'ううう', 'あ', 'いい', 'ううう',\n"
" 'あ',\n"
" ...\n"
" 'ううう', 'あ', 'いい', 'ううう', 'あ', "
"'いい', 'ううう', 'あ', 'いい',\n"
" 'ううう'],\n"
Reported by Pylint.
Line: 102
Column: 5
Index(["あ", "いい", "ううう"] * 100),
(
"Index(['あ', 'いい', 'ううう', 'あ', 'いい', "
"'ううう', 'あ', 'いい', 'ううう',\n"
" 'あ',\n"
" ...\n"
" 'ううう', 'あ', 'いい', 'ううう', 'あ', "
"'いい', 'ううう', 'あ', 'いい',\n"
" 'ううう'],\n"
Reported by Pylint.
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.
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.