The following issues were found
pandas/tests/arithmetic/test_object.py
87 issues
Line: 9
Column: 1
import operator
import numpy as np
import pytest
import pandas as pd
from pandas import (
Series,
Timestamp,
Reported by Pylint.
Line: 28
Column: 9
ser = Series(np.random.randn(10), dtype=object)
shifted = ser.shift(2)
ops = ["lt", "le", "gt", "ge", "eq", "ne"]
for op in ops:
func = getattr(operator, op)
result = func(ser, shifted)
expected = func(ser.astype(float), shifted.astype(float))
Reported by Pylint.
Line: 79
Column: 3
class TestArithmetic:
# TODO: parametrize
def test_pow_ops_object(self):
# GH#22922
# pow is weird with masking & 1, so testing here
a = Series([1, np.nan, 1, np.nan], dtype=object)
b = Series([1, np.nan, np.nan, 1], dtype=object)
Reported by Pylint.
Line: 151
Column: 13
"must be str"
)
with pytest.raises(TypeError, match=msg):
"foo_" + ser
@pytest.mark.parametrize("op", [operator.add, ops.radd, operator.sub, ops.rsub])
def test_objarr_add_invalid(self, op, box_with_array):
# invalid ops
box = box_with_array
Reported by Pylint.
Line: 168
Column: 3
with pytest.raises(Exception, match=msg):
op(obj_ser, np.array(1, dtype=np.int64))
# TODO: Moved from tests.series.test_operators; needs cleanup
def test_operators_na_handling(self):
ser = Series(["foo", "bar", "baz", np.nan])
result = "prefix_" + ser
expected = Series(["prefix_foo", "prefix_bar", "prefix_baz", np.nan])
tm.assert_series_equal(result, expected)
Reported by Pylint.
Line: 179
Column: 3
expected = Series(["foo_suffix", "bar_suffix", "baz_suffix", np.nan])
tm.assert_series_equal(result, expected)
# TODO: parametrize over box
@pytest.mark.parametrize("dtype", [None, object])
def test_series_with_dtype_radd_timedelta(self, dtype):
# note this test is _not_ aimed at timedelta64-dtyped Series
ser = Series(
[pd.Timedelta("1 days"), pd.Timedelta("2 days"), pd.Timedelta("3 days")],
Reported by Pylint.
Line: 197
Column: 3
result = ser + pd.Timedelta("3 days")
tm.assert_series_equal(result, expected)
# TODO: cleanup & parametrize over box
def test_mixed_timezone_series_ops_object(self):
# GH#13043
ser = Series(
[
Timestamp("2015-01-01", tz="US/Eastern"),
Reported by Pylint.
Line: 243
Column: 3
tm.assert_series_equal(ser + pd.Timedelta("00:30:00"), exp)
tm.assert_series_equal(pd.Timedelta("00:30:00") + ser, exp)
# TODO: cleanup & parametrize over box
def test_iadd_preserves_name(self):
# GH#17067, GH#19723 __iadd__ and __isub__ should preserve index name
ser = Series([1, 2, 3])
ser.index.name = "foo"
Reported by Pylint.
Line: 290
Column: 13
msg = "unsupported operand type|Cannot broadcast"
with pytest.raises(TypeError, match=msg):
index - "a"
with pytest.raises(TypeError, match=msg):
index - index
with pytest.raises(TypeError, match=msg):
index - index.tolist()
with pytest.raises(TypeError, match=msg):
Reported by Pylint.
Line: 292
Column: 13
with pytest.raises(TypeError, match=msg):
index - "a"
with pytest.raises(TypeError, match=msg):
index - index
with pytest.raises(TypeError, match=msg):
index - index.tolist()
with pytest.raises(TypeError, match=msg):
index.tolist() - index
Reported by Pylint.
pandas/tests/io/pytables/test_file_handling.py
87 issues
Line: 4
Column: 1
import os
import numpy as np
import pytest
from pandas.compat import is_platform_little_endian
from pandas import (
DataFrame,
Reported by Pylint.
Line: 48
Column: 24
else:
store = HDFStore(path, mode=mode)
assert store._handle.mode == mode
store.close()
with ensure_clean_path(setup_path) as path:
# context
Reported by Pylint.
Line: 60
Column: 28
pass
else:
with HDFStore(path, mode=mode) as store:
assert store._handle.mode == mode
with ensure_clean_path(setup_path) as path:
# conv write
if mode in ["r", "r+"]:
Reported by Pylint.
Line: 131
Column: 16
store.open("r")
assert store.is_open
assert len(store) == 1
assert store._mode == "r"
store.close()
assert not store.is_open
# reopen as append
store.open("a")
Reported by Pylint.
Line: 139
Column: 16
store.open("a")
assert store.is_open
assert len(store) == 1
assert store._mode == "a"
store.close()
assert not store.is_open
# reopen as append (again)
store.open("a")
Reported by Pylint.
Line: 147
Column: 16
store.open("a")
assert store.is_open
assert len(store) == 1
assert store._mode == "a"
store.close()
assert not store.is_open
def test_open_args(setup_path):
Reported by Pylint.
Line: 342
Column: 12
with ensure_clean_path(setup_path) as path:
if pytables._table_file_open_policy_is_strict:
# multiples
store1 = HDFStore(path)
msg = (
r"The file [\S]* is already opened\. Please close it before "
r"reopening in write mode\."
Reported by Pylint.
Line: 417
Column: 13
store.keys()
with pytest.raises(ClosedFileError, match=msg):
"df" in store
with pytest.raises(ClosedFileError, match=msg):
len(store)
with pytest.raises(ClosedFileError, match=msg):
Reported by Pylint.
Line: 423
Column: 13
len(store)
with pytest.raises(ClosedFileError, match=msg):
store["df"]
with pytest.raises(ClosedFileError, match=msg):
store.select("df")
with pytest.raises(ClosedFileError, match=msg):
Reported by Pylint.
Line: 448
Column: 13
msg = "'HDFStore' object has no attribute 'df'"
with pytest.raises(AttributeError, match=msg):
store.df
def test_fspath():
with tm.ensure_clean("foo.h5") as path:
with HDFStore(path) as store:
Reported by Pylint.
pandas/tests/window/test_numba.py
87 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas.errors import NumbaUtilError
import pandas.util._test_decorators as td
from pandas import (
DataFrame,
Series,
Reported by Pylint.
Line: 30
Column: 13
return np.mean(x) + arg_sum
if jit:
import numba
f = numba.jit(f)
engine_kwargs = {"nogil": nogil, "parallel": parallel, "nopython": nopython}
args = (2,)
Reported by Pylint.
Line: 95
Column: 13
return np.std(x) * 5
if jit:
import numba
func_1 = numba.jit(func_1)
func_2 = numba.jit(func_2)
engine_kwargs = {"nogil": nogil, "parallel": parallel, "nopython": nopython}
Reported by Pylint.
Line: 132
Column: 38
],
)
def test_dont_cache_args(
self, window, window_kwargs, nogil, parallel, nopython, method
):
# GH 42287
def add(values, x):
return np.sum(values) + x
Reported by Pylint.
Line: 132
Column: 65
],
)
def test_dont_cache_args(
self, window, window_kwargs, nogil, parallel, nopython, method
):
# GH 42287
def add(values, x):
return np.sum(values) + x
Reported by Pylint.
Line: 132
Column: 45
],
)
def test_dont_cache_args(
self, window, window_kwargs, nogil, parallel, nopython, method
):
# GH 42287
def add(values, x):
return np.sum(values) + x
Reported by Pylint.
Line: 132
Column: 55
],
)
def test_dont_cache_args(
self, window, window_kwargs, nogil, parallel, nopython, method
):
# GH 42287
def add(values, x):
return np.sum(values) + x
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas.errors import NumbaUtilError
import pandas.util._test_decorators as td
from pandas import (
DataFrame,
Series,
Reported by Pylint.
Line: 20
Column: 1
@td.skip_if_no("numba", "0.46.0")
@pytest.mark.filterwarnings("ignore:\\nThe keyword argument")
# Filter warnings when parallel=True and the function can't be parallelized by Numba
class TestEngine:
@pytest.mark.parametrize("jit", [True, False])
def test_numba_vs_cython_apply(self, jit, nogil, parallel, nopython, center):
def f(x, *args):
arg_sum = 0
for arg in args:
Reported by Pylint.
Line: 22
Column: 5
# Filter warnings when parallel=True and the function can't be parallelized by Numba
class TestEngine:
@pytest.mark.parametrize("jit", [True, False])
def test_numba_vs_cython_apply(self, jit, nogil, parallel, nopython, center):
def f(x, *args):
arg_sum = 0
for arg in args:
arg_sum += arg
return np.mean(x) + arg_sum
Reported by Pylint.
pandas/io/formats/style_render.py
87 issues
Line: 65
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b701_jinja2_autoescape_false.html
"""
loader = jinja2.PackageLoader("pandas", "io/formats/templates")
env = jinja2.Environment(loader=loader, trim_blocks=True)
template_html = env.get_template("html.tpl")
template_html_table = env.get_template("html_table.tpl")
template_html_style = env.get_template("html_style.tpl")
template_latex = env.get_template("latex.tpl")
Reported by Bandit.
Line: 24
Column: 1
from pandas._config import get_option
from pandas._libs import lib
from pandas.compat._optional import import_optional_dependency
from pandas.core.dtypes.generic import ABCSeries
from pandas import (
Reported by Pylint.
Line: 121
Column: 3
Generates a dict with necessary kwargs passed to jinja2 template.
"""
self._compute()
# TODO: namespace all the pandas keys
d = self._translate(sparse_index, sparse_columns)
d.update(kwargs)
return self.template_html.render(
**d,
html_table_tpl=self.template_html_table,
Reported by Pylint.
Line: 208
Column: 9
len(self.data.index), len(self.data.columns), max_elements
)
self.cellstyle_map_columns: DefaultDict[
tuple[CSSPair, ...], list[str]
] = defaultdict(list)
head = self._translate_header(
BLANK_CLASS,
BLANK_VALUE,
Reported by Pylint.
Line: 222
Column: 9
)
d.update({"head": head})
self.cellstyle_map: DefaultDict[tuple[CSSPair, ...], list[str]] = defaultdict(
list
)
self.cellstyle_map_index: DefaultDict[
tuple[CSSPair, ...], list[str]
] = defaultdict(list)
Reported by Pylint.
Line: 225
Column: 9
self.cellstyle_map: DefaultDict[tuple[CSSPair, ...], list[str]] = defaultdict(
list
)
self.cellstyle_map_index: DefaultDict[
tuple[CSSPair, ...], list[str]
] = defaultdict(list)
body = self._translate_body(
DATA_CLASS,
ROW_HEADING_CLASS,
Reported by Pylint.
Line: 245
Column: 13
"cellstyle_columns": "cellstyle_map_columns",
} # add the cell_ids styles map to the render dictionary in right format
for k, attr in ctx_maps.items():
map = [
{"props": list(props), "selectors": selectors}
for props, selectors in getattr(self, attr).items()
]
d.update({k: map})
Reported by Pylint.
Line: 262
Column: 17
d.update({"table_attributes": table_attr})
if self.tooltips:
d = self.tooltips._translate(self.data, self.uuid, d)
return d
def _translate_header(
self,
Reported by Pylint.
Line: 881
Column: 16
lengths = {}
if index.nlevels == 1:
for i, value in enumerate(levels):
if i not in hidden_elements:
lengths[(0, i)] = 1
return lengths
for i, lvl in enumerate(levels):
Reported by Pylint.
Line: 1021
Column: 18
"""
# Get initial func from input string, input callable, or from default factory
if isinstance(formatter, str):
func_0 = lambda x: formatter.format(x)
elif callable(formatter):
func_0 = formatter
elif formatter is None:
precision = get_option("display.precision") if precision is None else precision
func_0 = partial(
Reported by Pylint.
pandas/core/arrays/sparse/array.py
87 issues
Line: 19
Column: 1
import numpy as np
from pandas._libs import lib
import pandas._libs.sparse as splib
from pandas._libs.sparse import (
BlockIndex,
IntIndex,
SparseIndex,
Reported by Pylint.
Line: 20
Column: 1
import numpy as np
from pandas._libs import lib
import pandas._libs.sparse as splib
from pandas._libs.sparse import (
BlockIndex,
IntIndex,
SparseIndex,
)
Reported by Pylint.
Line: 20
Column: 1
import numpy as np
from pandas._libs import lib
import pandas._libs.sparse as splib
from pandas._libs.sparse import (
BlockIndex,
IntIndex,
SparseIndex,
)
Reported by Pylint.
Line: 21
Column: 1
from pandas._libs import lib
import pandas._libs.sparse as splib
from pandas._libs.sparse import (
BlockIndex,
IntIndex,
SparseIndex,
)
from pandas._libs.tslibs import NaT
Reported by Pylint.
Line: 21
Column: 1
from pandas._libs import lib
import pandas._libs.sparse as splib
from pandas._libs.sparse import (
BlockIndex,
IntIndex,
SparseIndex,
)
from pandas._libs.tslibs import NaT
Reported by Pylint.
Line: 1228
Column: 13
# Compat for pandas < 0.24.0
nd_state, (fill_value, sp_index) = state
sparse_values = np.array([])
sparse_values.__setstate__(nd_state)
self._sparse_values = sparse_values
self._sparse_index = sp_index
self._dtype = SparseDtype(sparse_values.dtype, fill_value)
else:
Reported by Pylint.
Line: 144
Column: 3
ltype = SparseDtype(subtype, left.fill_value)
rtype = SparseDtype(subtype, right.fill_value)
# TODO(GH-23092): pass copy=False. Need to fix astype_nansafe
left = left.astype(ltype)
right = right.astype(rtype)
dtype = ltype.subtype
else:
dtype = ltype
Reported by Pylint.
Line: 320
Column: 3
fill_value = data.fill_value
if dtype is None:
dtype = data.dtype
# TODO: make kind=None, and use data.kind?
data = data.sp_values
# Handle use-provided dtype
if isinstance(dtype, str):
# Two options: dtype='int', regular numpy dtype
Reported by Pylint.
Line: 357
Column: 3
if dtype is not None:
dtype = pandas_dtype(dtype)
# TODO: disentangle the fill_value dtype inference from
# dtype inference
if data is None:
# TODO: What should the empty dtype be? Object or float?
# error: Argument "dtype" to "array" has incompatible type
Reported by Pylint.
Line: 360
Column: 3
# TODO: disentangle the fill_value dtype inference from
# dtype inference
if data is None:
# TODO: What should the empty dtype be? Object or float?
# error: Argument "dtype" to "array" has incompatible type
# "Union[ExtensionDtype, dtype[Any], None]"; expected "Union[dtype[Any],
# None, type, _SupportsDType, str, Union[Tuple[Any, int], Tuple[Any,
# Union[int, Sequence[int]]], List[Any], _DTypeDict, Tuple[Any, Any]]]"
Reported by Pylint.
pandas/core/algorithms.py
86 issues
Line: 20
Column: 1
import numpy as np
from pandas._libs import (
algos,
hashtable as htable,
iNaT,
lib,
)
Reported by Pylint.
Line: 20
Column: 1
import numpy as np
from pandas._libs import (
algos,
hashtable as htable,
iNaT,
lib,
)
Reported by Pylint.
Line: 20
Column: 1
import numpy as np
from pandas._libs import (
algos,
hashtable as htable,
iNaT,
lib,
)
Reported by Pylint.
Line: 530
Column: 12
size_hint: int | None = None,
na_value=None,
mask: np.ndarray | None = None,
) -> tuple[npt.NDArray[np.intp], np.ndarray]:
"""
Factorize a numpy array to codes and uniques.
This doesn't do any coercion of types or unboxing before factorization.
Reported by Pylint.
Line: 9
Column: 1
import operator
from textwrap import dedent
from typing import (
TYPE_CHECKING,
Literal,
Union,
cast,
final,
Reported by Pylint.
Line: 206
Column: 18
if isinstance(values, cls) and values.dtype == dtype:
return values
values = cls._from_sequence(values)
elif is_bool_dtype(dtype):
values = values.astype(dtype, copy=False)
# we only support object dtypes bool Index
if isinstance(original, ABCIndex):
Reported by Pylint.
Line: 272
Column: 5
values = _ensure_data(values)
ndtype = _check_object_for_strings(values)
htable = _hashtables[ndtype]
return htable, values
def _get_values_for_rank(values: ArrayLike) -> np.ndarray:
if is_categorical_dtype(values):
Reported by Pylint.
Line: 278
Column: 18
def _get_values_for_rank(values: ArrayLike) -> np.ndarray:
if is_categorical_dtype(values):
values = cast("Categorical", values)._values_for_rank()
values = _ensure_data(values)
if values.dtype.kind in ["i", "u", "f"]:
# rank_t includes only object, int64, uint64, float64
dtype = values.dtype.kind + "8"
Reported by Pylint.
Line: 292
Column: 5
values = _get_values_for_rank(values)
ndtype = _check_object_for_strings(values)
htable = _hashtables.get(ndtype, _hashtables["object"])
return htable, values
def _check_object_for_strings(values: np.ndarray) -> str:
Reported by Pylint.
Line: 425
Column: 5
return values.unique()
original = values
htable, values = _get_hashtable_algo(values)
table = htable(len(values))
uniques = table.unique(values)
uniques = _reconstruct_data(uniques, original.dtype, original)
return uniques
Reported by Pylint.
asv_bench/benchmarks/frame_ctor.py
86 issues
Line: 3
Column: 1
import numpy as np
import pandas as pd
from pandas import (
DataFrame,
MultiIndex,
Series,
Timestamp,
date_range,
Reported by Pylint.
Line: 4
Column: 1
import numpy as np
import pandas as pd
from pandas import (
DataFrame,
MultiIndex,
Series,
Timestamp,
date_range,
Reported by Pylint.
Line: 12
Column: 1
date_range,
)
from .pandas_vb_common import tm
try:
from pandas.tseries.offsets import (
Hour,
Nano,
Reported by Pylint.
Line: 174
Column: 1
)
from .pandas_vb_common import setup # noqa: F401 isort:skip
Reported by Pylint.
Line: 21
Column: 5
)
except ImportError:
# For compatibility with older versions
from pandas.core.datetools import * # noqa
class FromDicts:
def setup(self):
N, K = 5000, 50
Reported by Pylint.
Line: 27
Column: 9
class FromDicts:
def setup(self):
N, K = 5000, 50
self.index = tm.makeStringIndex(N)
self.columns = tm.makeStringIndex(K)
frame = DataFrame(np.random.randn(N, K), index=self.index, columns=self.columns)
self.data = frame.to_dict()
self.dict_list = frame.to_dict(orient="records")
self.data2 = {i: {j: float(j) for j in range(100)} for i in range(2000)}
Reported by Pylint.
Line: 28
Column: 9
def setup(self):
N, K = 5000, 50
self.index = tm.makeStringIndex(N)
self.columns = tm.makeStringIndex(K)
frame = DataFrame(np.random.randn(N, K), index=self.index, columns=self.columns)
self.data = frame.to_dict()
self.dict_list = frame.to_dict(orient="records")
self.data2 = {i: {j: float(j) for j in range(100)} for i in range(2000)}
Reported by Pylint.
Line: 30
Column: 9
self.index = tm.makeStringIndex(N)
self.columns = tm.makeStringIndex(K)
frame = DataFrame(np.random.randn(N, K), index=self.index, columns=self.columns)
self.data = frame.to_dict()
self.dict_list = frame.to_dict(orient="records")
self.data2 = {i: {j: float(j) for j in range(100)} for i in range(2000)}
def time_list_of_dict(self):
DataFrame(self.dict_list)
Reported by Pylint.
Line: 31
Column: 9
self.columns = tm.makeStringIndex(K)
frame = DataFrame(np.random.randn(N, K), index=self.index, columns=self.columns)
self.data = frame.to_dict()
self.dict_list = frame.to_dict(orient="records")
self.data2 = {i: {j: float(j) for j in range(100)} for i in range(2000)}
def time_list_of_dict(self):
DataFrame(self.dict_list)
Reported by Pylint.
Line: 32
Column: 9
frame = DataFrame(np.random.randn(N, K), index=self.index, columns=self.columns)
self.data = frame.to_dict()
self.dict_list = frame.to_dict(orient="records")
self.data2 = {i: {j: float(j) for j in range(100)} for i in range(2000)}
def time_list_of_dict(self):
DataFrame(self.dict_list)
def time_nested_dict(self):
Reported by Pylint.
pandas/tests/arrays/categorical/test_indexing.py
85 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas import (
Categorical,
CategoricalIndex,
Index,
Interval,
IntervalIndex,
Reported by Pylint.
Line: 26
Column: 37
assert self.factor[-1] == "c"
subf = self.factor[[0, 1, 2]]
tm.assert_numpy_array_equal(subf._codes, np.array([0, 1, 1], dtype=np.int8))
subf = self.factor[np.asarray(self.factor) == "c"]
tm.assert_numpy_array_equal(subf._codes, np.array([2, 2, 2], dtype=np.int8))
def test_setitem(self):
Reported by Pylint.
Line: 29
Column: 37
tm.assert_numpy_array_equal(subf._codes, np.array([0, 1, 1], dtype=np.int8))
subf = self.factor[np.asarray(self.factor) == "c"]
tm.assert_numpy_array_equal(subf._codes, np.array([2, 2, 2], dtype=np.int8))
def test_setitem(self):
# int/positional
c = self.factor.copy()
Reported by Pylint.
Line: 149
Column: 37
str(cat1)
exp_arr = np.array([0, 0, 1, 1, 2, 2], dtype=np.int8)
exp_idx = PeriodIndex(["2014-01", "2014-02", "2014-03"], freq="M")
tm.assert_numpy_array_equal(cat1._codes, exp_arr)
tm.assert_index_equal(cat1.categories, exp_idx)
idx2 = PeriodIndex(
["2014-03", "2014-03", "2014-02", "2014-01", "2014-03", "2014-01"], freq="M"
)
Reported by Pylint.
Line: 159
Column: 37
str(cat2)
exp_arr = np.array([2, 2, 1, 0, 2, 0], dtype=np.int8)
exp_idx2 = PeriodIndex(["2014-01", "2014-02", "2014-03"], freq="M")
tm.assert_numpy_array_equal(cat2._codes, exp_arr)
tm.assert_index_equal(cat2.categories, exp_idx2)
idx3 = PeriodIndex(
[
"2013-12",
Reported by Pylint.
Line: 188
Column: 37
],
freq="M",
)
tm.assert_numpy_array_equal(cat3._codes, exp_arr)
tm.assert_index_equal(cat3.categories, exp_idx)
def test_categories_assignments(self):
s = Categorical(["a", "b", "c", "a"])
exp = np.array([1, 2, 3, 1], dtype=np.int64)
Reported by Pylint.
Line: 320
Column: 13
assert "a" not in cat
with pytest.raises(TypeError, match="unhashable type"):
["a"] in cat
with pytest.raises(TypeError, match="unhashable type"):
["a", "b"] in cat
Reported by Pylint.
Line: 323
Column: 13
["a"] in cat
with pytest.raises(TypeError, match="unhashable type"):
["a", "b"] in cat
@pytest.mark.parametrize("index", [True, False])
def test_mask_with_boolean(index):
s = Series(range(3))
Reported by Pylint.
Line: 363
Column: 3
ValueError
When Categorical.__array__ is called.
"""
# TODO(Categorical): identify other places where this may be
# useful and move to a conftest.py
def array(self, dtype=None):
raise ValueError("I cannot be converted.")
with monkeypatch.context() as m:
Reported by Pylint.
Line: 373
Column: 20
yield
def test_series_at(non_coercible_categorical):
arr = Categorical(["a", "b", "c"])
ser = Series(arr)
result = ser.at[0]
assert result == "a"
Reported by Pylint.
pandas/tests/extension/test_boolean.py
85 issues
Line: 17
Column: 1
"""
import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
from pandas.core.arrays.boolean import BooleanDtype
from pandas.tests.extension import base
Reported by Pylint.
Line: 35
Column: 10
@pytest.fixture
def data(dtype):
return pd.array(make_data(), dtype=dtype)
@pytest.fixture
def data_for_twos(dtype):
Reported by Pylint.
Line: 40
Column: 19
@pytest.fixture
def data_for_twos(dtype):
return pd.array(np.ones(100), dtype=dtype)
@pytest.fixture
def data_missing(dtype):
Reported by Pylint.
Line: 45
Column: 18
@pytest.fixture
def data_missing(dtype):
return pd.array([np.nan, True], dtype=dtype)
@pytest.fixture
def data_for_sorting(dtype):
Reported by Pylint.
Line: 50
Column: 22
@pytest.fixture
def data_for_sorting(dtype):
return pd.array([True, True, False], dtype=dtype)
@pytest.fixture
def data_missing_for_sorting(dtype):
Reported by Pylint.
Line: 55
Column: 30
@pytest.fixture
def data_missing_for_sorting(dtype):
return pd.array([True, np.nan, False], dtype=dtype)
@pytest.fixture
def na_cmp():
Reported by Pylint.
Line: 71
Column: 23
@pytest.fixture
def data_for_grouping(dtype):
b = True
a = False
na = np.nan
return pd.array([b, b, na, na, a, a, b], dtype=dtype)
Reported by Pylint.
Line: 109
Column: 5
# overwriting to indicate ops don't raise an error
super().check_opname(s, op_name, other, exc=None)
def _check_op(self, obj, op, other, op_name, exc=NotImplementedError):
if exc is None:
if op_name in self.implements:
msg = r"numpy boolean subtract"
with pytest.raises(TypeError, match=msg):
op(obj, other)
Reported by Pylint.
Line: 153
Column: 33
# overwriting to indicate ops don't raise an error
super().check_opname(s, op_name, other, exc=None)
def _compare_other(self, s, data, op_name, other):
self.check_opname(s, op_name, other)
@pytest.mark.skip(reason="Tested in tests/arrays/test_boolean.py")
def test_compare_scalar(self, data, all_compare_operators):
pass
Reported by Pylint.
Line: 157
Column: 35
self.check_opname(s, op_name, other)
@pytest.mark.skip(reason="Tested in tests/arrays/test_boolean.py")
def test_compare_scalar(self, data, all_compare_operators):
pass
@pytest.mark.skip(reason="Tested in tests/arrays/test_boolean.py")
def test_compare_array(self, data, all_compare_operators):
pass
Reported by Pylint.
pandas/tests/io/pytables/test_append.py
85 issues
Line: 7
Column: 1
from warnings import catch_warnings
import numpy as np
import pytest
from pandas._libs.tslibs import Timestamp
import pandas.util._test_decorators as td
import pandas as pd
Reported by Pylint.
Line: 441
Column: 9
with ensure_clean_store(setup_path) as store:
def check_col(key, name, size):
assert getattr(store.get_storer(key).table.description, name).itemsize, size
df = DataFrame({"A": "foo", "B": "bar"}, index=range(10))
# a min_itemsize that creates a data_column
Reported by Pylint.
Line: 285
Column: 20
# column oriented
df = tm.makeTimeDataFrame()
df.index = df.index._with_freq(None) # freq doesn't round-trip
_maybe_remove(store, "df1")
store.append("df1", df.iloc[:, :2], axes=["columns"])
store.append("df1", df.iloc[:, 2:])
tm.assert_frame_equal(store["df1"], df)
Reported by Pylint.
Line: 503
Column: 16
tm.assert_frame_equal(store["df"], df)
# check that we have indices created
assert store._handle.root.df.table.cols.index.is_indexed is True
assert store._handle.root.df.table.cols.B.is_indexed is True
# data column searching
result = store.select("df", "B>0")
expected = df[df.B > 0]
Reported by Pylint.
Line: 504
Column: 16
# check that we have indices created
assert store._handle.root.df.table.cols.index.is_indexed is True
assert store._handle.root.df.table.cols.B.is_indexed is True
# data column searching
result = store.select("df", "B>0")
expected = df[df.B > 0]
tm.assert_frame_equal(result, expected)
Reported by Pylint.
Line: 585
Column: 3
& (df_new.B < 0)
]
tm.assert_frame_equal(result, expected, check_freq=False)
# FIXME: 2020-05-07 freq check randomly fails in the CI
# yield an empty frame
result = store.select("df", "string='foo' and string2='cool'")
expected = df_new[(df_new.string == "foo") & (df_new.string2 == "cool")]
tm.assert_frame_equal(result, expected)
Reported by Pylint.
Line: 600
Column: 17
df_dc.loc[df_dc.index[7:9], "string"] = "bar"
df_dc["string2"] = "cool"
df_dc["datetime"] = Timestamp("20010102")
df_dc = df_dc._convert(datetime=True)
df_dc.loc[df_dc.index[3:5], ["A", "B", "datetime"]] = np.nan
_maybe_remove(store, "df_dc")
store.append(
"df_dc", df_dc, data_columns=["B", "C", "string", "string2", "datetime"]
Reported by Pylint.
Line: 615
Column: 3
result = store.select("df_dc", ["B > 0", "C > 0", "string == foo"])
expected = df_dc[(df_dc.B > 0) & (df_dc.C > 0) & (df_dc.string == "foo")]
tm.assert_frame_equal(result, expected, check_freq=False)
# FIXME: 2020-12-07 intermittent build failures here with freq of
# None instead of BDay(4)
with ensure_clean_store(setup_path) as store:
# doc example part 2
np.random.seed(1234)
Reported by Pylint.
Line: 717
Column: 3
tm.assert_frame_equal(store.select("df2"), df)
# TODO(ArrayManager) currently we rely on falling back to BlockManager, but
# the conversion from AM->BM converts the invalid object dtype column into
# a datetime64 column no longer raising an error
@td.skip_array_manager_not_yet_implemented
def test_append_raise(setup_path):
Reported by Pylint.
Line: 915
Column: 3
{"df1a": ["A", "B"], "df2a": None}, df, selector="df1a", dropna=False
)
# TODO Update error message to desired message for this case
msg = "Cannot select as multiple after appending with dropna=False"
with pytest.raises(ValueError, match=msg):
store.select_as_multiple(["df1a", "df2a"])
assert not store.select("df1a").index.equals(store.select("df2a").index)
Reported by Pylint.