The following issues were found
pandas/tests/indexes/datetimes/test_scalar_compat.py
136 issues
Line: 7
Column: 1
from datetime import datetime
import numpy as np
import pytest
from pandas._libs.tslibs import (
OutOfBoundsDatetime,
to_offset,
)
Reported by Pylint.
Line: 13
Column: 1
OutOfBoundsDatetime,
to_offset,
)
from pandas._libs.tslibs.offsets import INVALID_FREQ_ERR_MSG
import pandas as pd
from pandas import (
DatetimeIndex,
Timestamp,
Reported by Pylint.
Line: 13
Column: 1
OutOfBoundsDatetime,
to_offset,
)
from pandas._libs.tslibs.offsets import INVALID_FREQ_ERR_MSG
import pandas as pd
from pandas import (
DatetimeIndex,
Timestamp,
Reported by Pylint.
Line: 27
Column: 18
class TestDatetimeIndexOps:
def test_dti_time(self):
rng = date_range("1/1/2000", freq="12min", periods=10)
result = pd.Index(rng).time
expected = [t.time() for t in rng]
assert (result == expected).all()
def test_dti_date(self):
rng = date_range("1/1/2000", freq="12H", periods=10)
Reported by Pylint.
Line: 33
Column: 18
def test_dti_date(self):
rng = date_range("1/1/2000", freq="12H", periods=10)
result = pd.Index(rng).date
expected = [t.date() for t in rng]
assert (result == expected).all()
@pytest.mark.parametrize("data", [["1400-01-01"], [datetime(1400, 1, 1)]])
def test_dti_date_out_of_range(self, data):
Reported by Pylint.
Line: 85
Column: 37
msg = "The 'freq' argument in Timestamp is deprecated"
with tm.assert_produces_warning(FutureWarning, match=msg):
ts = Timestamp(idx[-1], idx.freq)
msg2 = "Timestamp.freq is deprecated"
with tm.assert_produces_warning(FutureWarning, match=msg2):
assert idx.freq == ts.freq
Reported by Pylint.
Line: 89
Column: 20
msg2 = "Timestamp.freq is deprecated"
with tm.assert_produces_warning(FutureWarning, match=msg2):
assert idx.freq == ts.freq
msg3 = "Timestamp.freqstr is deprecated"
with tm.assert_produces_warning(FutureWarning, match=msg3):
assert idx.freqstr == ts.freqstr
Reported by Pylint.
Line: 93
Column: 20
msg3 = "Timestamp.freqstr is deprecated"
with tm.assert_produces_warning(FutureWarning, match=msg3):
assert idx.freqstr == ts.freqstr
# ----------------------------------------------------------------
# DatetimeIndex.round
def test_round_daily(self):
Reported by Pylint.
Line: 100
Column: 18
def test_round_daily(self):
dti = date_range("20130101 09:10:11", periods=5)
result = dti.round("D")
expected = date_range("20130101", periods=5)
tm.assert_index_equal(result, expected)
dti = dti.tz_localize("UTC").tz_convert("US/Eastern")
result = dti.round("D")
Reported by Pylint.
Line: 100
Column: 18
def test_round_daily(self):
dti = date_range("20130101 09:10:11", periods=5)
result = dti.round("D")
expected = date_range("20130101", periods=5)
tm.assert_index_equal(result, expected)
dti = dti.tz_localize("UTC").tz_convert("US/Eastern")
result = dti.round("D")
Reported by Pylint.
pandas/tests/frame/methods/test_set_index.py
136 issues
Line: 11
Column: 1
)
import numpy as np
import pytest
from pandas import (
Categorical,
DataFrame,
DatetimeIndex,
Reported by Pylint.
Line: 470
Column: 16
tz="US/Eastern",
)
idx3 = date_range("2011-01-01 09:00", periods=6, tz="Asia/Tokyo")
idx3 = idx3._with_freq(None)
df = df.set_index(idx1)
df = df.set_index(idx2, append=True)
df = df.set_index(idx3, append=True)
Reported by Pylint.
Line: 470
Column: 16
tz="US/Eastern",
)
idx3 = date_range("2011-01-01 09:00", periods=6, tz="Asia/Tokyo")
idx3 = idx3._with_freq(None)
df = df.set_index(idx1)
df = df.set_index(idx2, append=True)
df = df.set_index(idx3, append=True)
Reported by Pylint.
Line: 109
Column: 21
data={"a": [0, 1, 2], "b": [3, 4, 5]},
index=Index(di, name="index"),
)
exp.index = exp.index._with_freq(None)
tm.assert_frame_equal(res, exp)
# GH#12920
res = df.set_index(["index", "a"])
exp_index = MultiIndex.from_arrays([di, [0, 1, 2]], names=["index", "a"])
Reported by Pylint.
Line: 470
Column: 16
tz="US/Eastern",
)
idx3 = date_range("2011-01-01 09:00", periods=6, tz="Asia/Tokyo")
idx3 = idx3._with_freq(None)
df = df.set_index(idx1)
df = df.set_index(idx2, append=True)
df = df.set_index(idx3, append=True)
Reported by Pylint.
Line: 676
Column: 13
# purposefully inherit from something unhashable
class Thing(set):
def __init__(self, name, color):
self.name = name
self.color = color
def __str__(self) -> str:
return f"<Thing {repr(self.name)}>"
Reported by Pylint.
Line: 27
Column: 1
import pandas._testing as tm
class TestSetIndex:
def test_set_index_multiindex(self):
# segfault in GH#3308
d = {"t1": [2, 2.5, 3], "t2": [4, 5, 6]}
df = DataFrame(d)
tuples = [(0, 1), (0, 2), (1, 2)]
Reported by Pylint.
Line: 27
Column: 1
import pandas._testing as tm
class TestSetIndex:
def test_set_index_multiindex(self):
# segfault in GH#3308
d = {"t1": [2, 2.5, 3], "t2": [4, 5, 6]}
df = DataFrame(d)
tuples = [(0, 1), (0, 2), (1, 2)]
Reported by Pylint.
Line: 28
Column: 5
class TestSetIndex:
def test_set_index_multiindex(self):
# segfault in GH#3308
d = {"t1": [2, 2.5, 3], "t2": [4, 5, 6]}
df = DataFrame(d)
tuples = [(0, 1), (0, 2), (1, 2)]
df["tuples"] = tuples
Reported by Pylint.
Line: 28
Column: 5
class TestSetIndex:
def test_set_index_multiindex(self):
# segfault in GH#3308
d = {"t1": [2, 2.5, 3], "t2": [4, 5, 6]}
df = DataFrame(d)
tuples = [(0, 1), (0, 2), (1, 2)]
df["tuples"] = tuples
Reported by Pylint.
pandas/tests/series/test_repr.py
136 issues
Line: 7
Column: 1
)
import numpy as np
import pytest
import pandas as pd
from pandas import (
Categorical,
DataFrame,
Reported by Pylint.
Line: 197
Column: 9
assert repr(ts).splitlines()[-1].startswith("Freq:")
ts2 = ts.iloc[np.random.randint(0, len(ts) - 1, 400)]
repr(ts2).splitlines()[-1]
def test_latex_repr(self):
result = r"""\begin{tabular}{ll}
\toprule
{} & 0 \\
Reported by Pylint.
Line: 212
Column: 30
"""
with option_context("display.latex.escape", False, "display.latex.repr", True):
s = Series([r"$\alpha$", "b", "c"])
assert result == s._repr_latex_()
assert s._repr_latex_() is None
def test_index_repr_in_frame_with_nan(self):
# see gh-25061
Reported by Pylint.
Line: 214
Column: 16
s = Series([r"$\alpha$", "b", "c"])
assert result == s._repr_latex_()
assert s._repr_latex_() is None
def test_index_repr_in_frame_with_nan(self):
# see gh-25061
i = Index([1, np.nan])
s = Series([1, 2], index=i)
Reported by Pylint.
Line: 1
Column: 1
from datetime import (
datetime,
timedelta,
)
import numpy as np
import pytest
import pandas as pd
Reported by Pylint.
Line: 24
Column: 1
import pandas._testing as tm
class TestSeriesRepr:
def test_multilevel_name_print(self):
index = MultiIndex(
levels=[["foo", "bar", "baz", "qux"], ["one", "two", "three"]],
codes=[[0, 0, 0, 1, 1, 2, 2, 3, 3, 3], [0, 1, 2, 0, 1, 1, 2, 0, 1, 2]],
names=["first", "second"],
Reported by Pylint.
Line: 25
Column: 5
class TestSeriesRepr:
def test_multilevel_name_print(self):
index = MultiIndex(
levels=[["foo", "bar", "baz", "qux"], ["one", "two", "three"]],
codes=[[0, 0, 0, 1, 1, 2, 2, 3, 3, 3], [0, 1, 2, 0, 1, 1, 2, 0, 1, 2]],
names=["first", "second"],
)
Reported by Pylint.
Line: 25
Column: 5
class TestSeriesRepr:
def test_multilevel_name_print(self):
index = MultiIndex(
levels=[["foo", "bar", "baz", "qux"], ["one", "two", "three"]],
codes=[[0, 0, 0, 1, 1, 2, 2, 3, 3, 3], [0, 1, 2, 0, 1, 1, 2, 0, 1, 2]],
names=["first", "second"],
)
Reported by Pylint.
Line: 31
Column: 9
codes=[[0, 0, 0, 1, 1, 2, 2, 3, 3, 3], [0, 1, 2, 0, 1, 1, 2, 0, 1, 2]],
names=["first", "second"],
)
s = Series(range(len(index)), index=index, name="sth")
expected = [
"first second",
"foo one 0",
" two 1",
" three 2",
Reported by Pylint.
Line: 47
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
"Name: sth, dtype: int64",
]
expected = "\n".join(expected)
assert repr(s) == expected
def test_name_printing(self):
# Test small Series.
s = Series([0, 1, 2])
Reported by Bandit.
pandas/core/apply.py
134 issues
Line: 21
Column: 1
from pandas._config import option_context
from pandas._libs import lib
from pandas._typing import (
AggFuncType,
AggFuncTypeBase,
AggFuncTypeDict,
AggObjType,
Reported by Pylint.
Line: 606
Column: 39
@property
def agg_axis(self) -> Index:
return self.obj._get_agg_axis(self.axis)
class FrameApply(NDFrameApply):
obj: DataFrame
Reported by Pylint.
Line: 81
Column: 12
kwargs=None,
) -> FrameApply:
"""construct and return a row or column based frame apply object"""
axis = obj._get_axis_number(axis)
klass: type[FrameApply]
if axis == 0:
klass = FrameRowApply
elif axis == 1:
klass = FrameColumnApply
Reported by Pylint.
Line: 197
Column: 12
is_series = obj.ndim == 1
if obj._get_axis_number(axis) == 1:
assert not is_series
return obj.T.transform(func, 0, *args, **kwargs).T
if is_list_like(func) and not is_dict_like(func):
func = cast(List[AggFuncTypeBase], func)
Reported by Pylint.
Line: 259
Column: 20
failed_names = []
all_type_errors = True
for name, how in func.items():
colg = obj._gotitem(name, ndim=1)
try:
results[name] = colg.transform(how, 0, *args, **kwargs)
except Exception as err:
if str(err) in {
"Function did not transform",
Reported by Pylint.
Line: 262
Column: 20
colg = obj._gotitem(name, ndim=1)
try:
results[name] = colg.transform(how, 0, *args, **kwargs)
except Exception as err:
if str(err) in {
"Function did not transform",
"No transform functions were provided",
}:
raise err
Reported by Pylint.
Line: 305
Column: 16
# Two possible ways to use a UDF - apply or call directly
try:
return obj.apply(func, args=args, **kwargs)
except Exception:
return func(obj, *args, **kwargs)
def agg_list_like(self) -> DataFrame | Series:
"""
Compute aggregation in the case of a list-like argument.
Reported by Pylint.
Line: 324
Column: 14
if not isinstance(obj, SelectionMixin):
# i.e. obj is Series or DataFrame
selected_obj = obj
elif obj._selected_obj.ndim == 1:
# For SeriesGroupBy this matches _obj_with_exclusions
selected_obj = obj._selected_obj
else:
selected_obj = obj._obj_with_exclusions
Reported by Pylint.
Line: 326
Column: 28
selected_obj = obj
elif obj._selected_obj.ndim == 1:
# For SeriesGroupBy this matches _obj_with_exclusions
selected_obj = obj._selected_obj
else:
selected_obj = obj._obj_with_exclusions
results = []
keys = []
Reported by Pylint.
Line: 328
Column: 28
# For SeriesGroupBy this matches _obj_with_exclusions
selected_obj = obj._selected_obj
else:
selected_obj = obj._obj_with_exclusions
results = []
keys = []
# degenerate case
Reported by Pylint.
pandas/tests/indexes/numeric/test_indexing.py
134 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas import (
Float64Index,
Index,
Int64Index,
RangeIndex,
Series,
Reported by Pylint.
Line: 353
Column: 39
expected = np.array([0, 1, 1, 2, 2, 3, 3, 4, 4, 5], dtype=np.intp)
tm.assert_numpy_array_equal(indexer, expected)
def test_get_indexer_uint64(self, index_large):
target = UInt64Index(np.arange(10).astype("uint64") * 5 + 2 ** 63)
indexer = index_large.get_indexer(target)
expected = np.array([0, -1, 1, 2, 3, 4, -1, -1, -1, -1], dtype=np.intp)
tm.assert_numpy_array_equal(indexer, expected)
Reported by Pylint.
Line: 386
Column: 34
result = index.where(klass(cond))
cond = [False] + [True] * (len(index) - 1)
expected = Float64Index([index._na_value] + index[1:].tolist())
result = index.where(klass(cond))
tm.assert_index_equal(result, expected)
def test_where_uin64(self):
idx = UInt64Index([0, 6, 2])
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas import (
Float64Index,
Index,
Int64Index,
RangeIndex,
Series,
Reported by Pylint.
Line: 17
Column: 1
@pytest.fixture
def index_large():
# large values used in UInt64Index tests where no compat needed with Int64/Float64
large = [2 ** 63, 2 ** 63 + 10, 2 ** 63 + 15, 2 ** 63 + 20, 2 ** 63 + 25]
return UInt64Index(large)
Reported by Pylint.
Line: 23
Column: 1
return UInt64Index(large)
class TestGetLoc:
@pytest.mark.parametrize("method", [None, "pad", "backfill", "nearest"])
def test_get_loc(self, method):
index = Index([0, 1, 2])
warn = None if method is None else FutureWarning
Reported by Pylint.
Line: 25
Column: 5
class TestGetLoc:
@pytest.mark.parametrize("method", [None, "pad", "backfill", "nearest"])
def test_get_loc(self, method):
index = Index([0, 1, 2])
warn = None if method is None else FutureWarning
with tm.assert_produces_warning(warn, match="deprecated"):
assert index.get_loc(1, method=method) == 1
Reported by Pylint.
Line: 25
Column: 5
class TestGetLoc:
@pytest.mark.parametrize("method", [None, "pad", "backfill", "nearest"])
def test_get_loc(self, method):
index = Index([0, 1, 2])
warn = None if method is None else FutureWarning
with tm.assert_produces_warning(warn, match="deprecated"):
assert index.get_loc(1, method=method) == 1
Reported by Pylint.
Line: 30
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
warn = None if method is None else FutureWarning
with tm.assert_produces_warning(warn, match="deprecated"):
assert index.get_loc(1, method=method) == 1
if method:
with tm.assert_produces_warning(warn, match="deprecated"):
assert index.get_loc(1, method=method, tolerance=0) == 1
Reported by Bandit.
Line: 34
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
if method:
with tm.assert_produces_warning(warn, match="deprecated"):
assert index.get_loc(1, method=method, tolerance=0) == 1
@pytest.mark.parametrize("method", [None, "pad", "backfill", "nearest"])
@pytest.mark.filterwarnings("ignore:Passing method:FutureWarning")
def test_get_loc_raises_bad_label(self, method):
index = Index([0, 1, 2])
Reported by Bandit.
pandas/tests/tseries/offsets/test_custom_business_month.py
134 issues
Line: 14
Column: 1
)
import numpy as np
import pytest
from pandas._libs.tslibs.offsets import (
CBMonthBegin,
CBMonthEnd,
CDay,
Reported by Pylint.
Line: 16
Column: 1
import numpy as np
import pytest
from pandas._libs.tslibs.offsets import (
CBMonthBegin,
CBMonthEnd,
CDay,
)
Reported by Pylint.
Line: 16
Column: 1
import numpy as np
import pytest
from pandas._libs.tslibs.offsets import (
CBMonthBegin,
CBMonthEnd,
CDay,
)
Reported by Pylint.
Line: 40
Column: 23
class CustomBusinessMonthBase:
def setup_method(self, method):
self.d = datetime(2008, 1, 1)
self.offset = self._offset()
self.offset1 = self.offset
self.offset2 = self._offset(2)
def test_eq(self):
assert self.offset2 == self.offset2
Reported by Pylint.
Line: 42
Column: 24
self.d = datetime(2008, 1, 1)
self.offset = self._offset()
self.offset1 = self.offset
self.offset2 = self._offset(2)
def test_eq(self):
assert self.offset2 == self.offset2
def test_mul(self):
Reported by Pylint.
Line: 58
Column: 26
unpickled = tm.round_trip_pickle(obj)
assert unpickled == obj
_check_roundtrip(self._offset())
_check_roundtrip(self._offset(2))
_check_roundtrip(self._offset() * 2)
def test_copy(self):
# GH 17452
Reported by Pylint.
Line: 59
Column: 26
assert unpickled == obj
_check_roundtrip(self._offset())
_check_roundtrip(self._offset(2))
_check_roundtrip(self._offset() * 2)
def test_copy(self):
# GH 17452
off = self._offset(weekmask="Mon Wed Fri")
Reported by Pylint.
Line: 60
Column: 26
_check_roundtrip(self._offset())
_check_roundtrip(self._offset(2))
_check_roundtrip(self._offset() * 2)
def test_copy(self):
# GH 17452
off = self._offset(weekmask="Mon Wed Fri")
assert off == off.copy()
Reported by Pylint.
Line: 64
Column: 15
def test_copy(self):
# GH 17452
off = self._offset(weekmask="Mon Wed Fri")
assert off == off.copy()
class TestCustomBusinessMonthBegin(CustomBusinessMonthBase, Base):
_offset = CBMonthBegin
Reported by Pylint.
Line: 38
Column: 28
class CustomBusinessMonthBase:
def setup_method(self, method):
self.d = datetime(2008, 1, 1)
self.offset = self._offset()
self.offset1 = self.offset
self.offset2 = self._offset(2)
Reported by Pylint.
pandas/tests/scalar/timestamp/test_comparisons.py
134 issues
Line: 8
Column: 1
import operator
import numpy as np
import pytest
from pandas import Timestamp
import pandas._testing as tm
Reported by Pylint.
Line: 97
Column: 13
arr = np.array([naive], dtype=object)
msg = "Cannot compare tz-naive and tz-aware timestamps"
with pytest.raises(TypeError, match=msg):
arr < ts
def test_comparison(self):
# 5-18-2012 00:00:00.000
stamp = 1337299200000000000
Reported by Pylint.
Line: 193
Column: 13
assert not a == b
assert a != b
with pytest.raises(TypeError, match=msg):
a < b
with pytest.raises(TypeError, match=msg):
a <= b
with pytest.raises(TypeError, match=msg):
a > b
with pytest.raises(TypeError, match=msg):
Reported by Pylint.
Line: 195
Column: 13
with pytest.raises(TypeError, match=msg):
a < b
with pytest.raises(TypeError, match=msg):
a <= b
with pytest.raises(TypeError, match=msg):
a > b
with pytest.raises(TypeError, match=msg):
a >= b
Reported by Pylint.
Line: 197
Column: 13
with pytest.raises(TypeError, match=msg):
a <= b
with pytest.raises(TypeError, match=msg):
a > b
with pytest.raises(TypeError, match=msg):
a >= b
assert not b == a
assert b != a
Reported by Pylint.
Line: 199
Column: 13
with pytest.raises(TypeError, match=msg):
a > b
with pytest.raises(TypeError, match=msg):
a >= b
assert not b == a
assert b != a
with pytest.raises(TypeError, match=msg):
b < a
Reported by Pylint.
Line: 204
Column: 13
assert not b == a
assert b != a
with pytest.raises(TypeError, match=msg):
b < a
with pytest.raises(TypeError, match=msg):
b <= a
with pytest.raises(TypeError, match=msg):
b > a
with pytest.raises(TypeError, match=msg):
Reported by Pylint.
Line: 206
Column: 13
with pytest.raises(TypeError, match=msg):
b < a
with pytest.raises(TypeError, match=msg):
b <= a
with pytest.raises(TypeError, match=msg):
b > a
with pytest.raises(TypeError, match=msg):
b >= a
Reported by Pylint.
Line: 208
Column: 13
with pytest.raises(TypeError, match=msg):
b <= a
with pytest.raises(TypeError, match=msg):
b > a
with pytest.raises(TypeError, match=msg):
b >= a
assert not a == b.to_pydatetime()
assert not a.to_pydatetime() == b
Reported by Pylint.
Line: 210
Column: 13
with pytest.raises(TypeError, match=msg):
b > a
with pytest.raises(TypeError, match=msg):
b >= a
assert not a == b.to_pydatetime()
assert not a.to_pydatetime() == b
def test_timestamp_compare_scalars(self):
Reported by Pylint.
pandas/_testing/__init__.py
132 issues
Line: 427
Column: 13
"""
index = pd.date_range(start=start, end=end, freq=freq, name="timestamp")
n = len(index)
state = np.random.RandomState(seed)
columns = {
"name": state.choice(_names, size=n),
"id": state.poisson(1000, size=n),
"x": state.rand(n) * 2 - 1,
"y": state.rand(n) * 2 - 1,
Reported by Pylint.
Line: 769
Column: 24
if random_state is None:
random_state = np.random
else:
random_state = np.random.RandomState(random_state)
# below is cribbed from scipy.sparse
size = round((1 - density) * nrows * ncols)
# generate a few more to ensure unique values
min_rows = 5
Reported by Pylint.
Line: 944
Column: 5
Callable
Regular `pytest.raises` function with `match` equal to `None`.
"""
import pytest
return pytest.raises(expected_exception, match=None) # noqa: PDF010
cython_table = pd.core.common._cython_table.items()
Reported by Pylint.
Line: 218
Column: 47
if box_cls is pd.array:
if isinstance(expected, RangeIndex):
# pd.array would return an IntegerArray
expected = PandasArray(np.asarray(expected._values))
else:
expected = pd.array(expected)
elif box_cls is Index:
expected = Index._with_infer(expected)
elif box_cls is Series:
Reported by Pylint.
Line: 222
Column: 20
else:
expected = pd.array(expected)
elif box_cls is Index:
expected = Index._with_infer(expected)
elif box_cls is Series:
expected = Series(expected)
elif box_cls is DataFrame:
expected = Series(expected).to_frame()
if transpose:
Reported by Pylint.
Line: 257
Column: 16
if is_period_dtype(dtype):
return period_array(obj)
elif is_datetime64_dtype(dtype) or is_datetime64tz_dtype(dtype):
return DatetimeArray._from_sequence(obj)
elif is_timedelta64_dtype(dtype):
return TimedeltaArray._from_sequence(obj)
else:
return np.array(obj)
Reported by Pylint.
Line: 259
Column: 16
elif is_datetime64_dtype(dtype) or is_datetime64tz_dtype(dtype):
return DatetimeArray._from_sequence(obj)
elif is_timedelta64_dtype(dtype):
return TimedeltaArray._from_sequence(obj)
else:
return np.array(obj)
# -----------------------------------------------------------------------------
Reported by Pylint.
Line: 355
Column: 20
return pd.period_range(start=dt, periods=k, freq="B", name=name, **kwargs)
def makeMultiIndex(k=10, names=None, **kwargs):
return MultiIndex.from_product((("foo", "bar"), (1, 2)), names=names, **kwargs)
_names = [
"Alice",
Reported by Pylint.
Line: 626
Column: 13
for i in range(nlevels):
def keyfunc(x):
import re
numeric_tuple = re.sub(r"[^\d_]_?", "", x).split("_")
return [int(num) for num in numeric_tuple]
# build a list of lists to create the index from
Reported by Pylint.
Line: 626
Column: 13
for i in range(nlevels):
def keyfunc(x):
import re
numeric_tuple = re.sub(r"[^\d_]_?", "", x).split("_")
return [int(num) for num in numeric_tuple]
# build a list of lists to create the index from
Reported by Pylint.
pandas/tests/frame/methods/test_reset_index.py
132 issues
Line: 5
Column: 1
from itertools import product
import numpy as np
import pytest
from pandas.core.dtypes.common import (
is_float_dtype,
is_integer_dtype,
)
Reported by Pylint.
Line: 147
Column: 3
df = float_frame.reset_index().set_index(["index", "A", "B"])
rs = df.reset_index(["A", "B"])
# TODO should reset_index check_names ?
tm.assert_frame_equal(rs, float_frame, check_names=False)
rs = df.reset_index(["index", "A", "B"])
tm.assert_frame_equal(rs, float_frame.reset_index(), check_names=False)
Reported by Pylint.
Line: 1
Column: 1
from datetime import datetime
from itertools import product
import numpy as np
import pytest
from pandas.core.dtypes.common import (
is_float_dtype,
is_integer_dtype,
Reported by Pylint.
Line: 28
Column: 1
import pandas._testing as tm
class TestResetIndex:
def test_set_reset(self):
idx = Index([2 ** 63, 2 ** 63 + 5, 2 ** 63 + 10], name="foo")
# set/reset
Reported by Pylint.
Line: 29
Column: 5
class TestResetIndex:
def test_set_reset(self):
idx = Index([2 ** 63, 2 ** 63 + 5, 2 ** 63 + 10], name="foo")
# set/reset
df = DataFrame({"A": [0, 1, 2]}, index=idx)
Reported by Pylint.
Line: 29
Column: 5
class TestResetIndex:
def test_set_reset(self):
idx = Index([2 ** 63, 2 ** 63 + 5, 2 ** 63 + 10], name="foo")
# set/reset
df = DataFrame({"A": [0, 1, 2]}, index=idx)
Reported by Pylint.
Line: 34
Column: 9
idx = Index([2 ** 63, 2 ** 63 + 5, 2 ** 63 + 10], name="foo")
# set/reset
df = DataFrame({"A": [0, 1, 2]}, index=idx)
result = df.reset_index()
assert result["foo"].dtype == np.dtype("uint64")
df = result.set_index("foo")
tm.assert_index_equal(df.index, idx)
Reported by Pylint.
Line: 36
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
# set/reset
df = DataFrame({"A": [0, 1, 2]}, index=idx)
result = df.reset_index()
assert result["foo"].dtype == np.dtype("uint64")
df = result.set_index("foo")
tm.assert_index_equal(df.index, idx)
def test_set_index_reset_index_dt64tz(self):
Reported by Bandit.
Line: 38
Column: 9
result = df.reset_index()
assert result["foo"].dtype == np.dtype("uint64")
df = result.set_index("foo")
tm.assert_index_equal(df.index, idx)
def test_set_index_reset_index_dt64tz(self):
idx = Index(date_range("20130101", periods=3, tz="US/Eastern"), name="foo")
Reported by Pylint.
Line: 41
Column: 5
df = result.set_index("foo")
tm.assert_index_equal(df.index, idx)
def test_set_index_reset_index_dt64tz(self):
idx = Index(date_range("20130101", periods=3, tz="US/Eastern"), name="foo")
# set/reset
df = DataFrame({"A": [0, 1, 2]}, index=idx)
Reported by Pylint.
pandas/tests/extension/test_sparse.py
132 issues
Line: 18
Column: 1
"""
import numpy as np
import pytest
from pandas.errors import PerformanceWarning
from pandas.core.dtypes.common import is_object_dtype
Reported by Pylint.
Line: 109
Column: 9
@pytest.mark.xfail(reason="SparseArray does not support setitem")
def test_ravel(self, data):
super().test_ravel(data)
class TestDtype(BaseSparseTests, base.BaseDtypeTests):
def test_array_type_with_arg(self, data, dtype):
assert dtype.construct_array_type() is SparseArray
Reported by Pylint.
Line: 390
Column: 9
@pytest.mark.xfail(raises=TypeError, reason="no sparse StringDtype")
def test_astype_string(self, data):
super().test_astype_string(data)
class TestArithmeticOps(BaseSparseTests, base.BaseArithmeticOpsTests):
series_scalar_exc = None
frame_scalar_exc = None
Reported by Pylint.
Line: 33
Column: 9
def make_data(fill_value):
if np.isnan(fill_value):
data = np.random.uniform(size=100)
else:
data = np.random.randint(1, 100, size=100)
if data[0] == data[1]:
data[0] += 1
Reported by Pylint.
Line: 56
Column: 19
@pytest.fixture
def data_for_twos(request):
return SparseArray(np.ones(100) * 2)
@pytest.fixture(params=[0, np.nan])
def data_missing(request):
Reported by Pylint.
Line: 103
Column: 34
class BaseSparseTests:
def _check_unsupported(self, data):
if data.dtype == SparseDtype(int, 0):
pytest.skip("Can't store nan in int array.")
@pytest.mark.xfail(reason="SparseArray does not support setitem")
def test_ravel(self, data):
Reported by Pylint.
Line: 108
Column: 26
pytest.skip("Can't store nan in int array.")
@pytest.mark.xfail(reason="SparseArray does not support setitem")
def test_ravel(self, data):
super().test_ravel(data)
class TestDtype(BaseSparseTests, base.BaseDtypeTests):
def test_array_type_with_arg(self, data, dtype):
Reported by Pylint.
Line: 113
Column: 40
class TestDtype(BaseSparseTests, base.BaseDtypeTests):
def test_array_type_with_arg(self, data, dtype):
assert dtype.construct_array_type() is SparseArray
class TestInterface(BaseSparseTests, base.BaseInterfaceTests):
def test_no_values_attribute(self, data):
Reported by Pylint.
Line: 113
Column: 46
class TestDtype(BaseSparseTests, base.BaseDtypeTests):
def test_array_type_with_arg(self, data, dtype):
assert dtype.construct_array_type() is SparseArray
class TestInterface(BaseSparseTests, base.BaseInterfaceTests):
def test_no_values_attribute(self, data):
Reported by Pylint.
Line: 113
Column: 40
class TestDtype(BaseSparseTests, base.BaseDtypeTests):
def test_array_type_with_arg(self, data, dtype):
assert dtype.construct_array_type() is SparseArray
class TestInterface(BaseSparseTests, base.BaseInterfaceTests):
def test_no_values_attribute(self, data):
Reported by Pylint.