The following issues were found
pandas/tests/indexes/ranges/test_constructors.py
35 issues
Line: 4
Column: 1
from datetime import datetime
import numpy as np
import pytest
from pandas import (
Index,
RangeIndex,
Series,
Reported by Pylint.
Line: 126
Column: 13
r"(RangeIndex.)?from_range\(\) got an unexpected keyword argument( 'copy')?"
)
with pytest.raises(TypeError, match=msg):
RangeIndex.from_range(range(10), copy=True)
def test_constructor_name(self):
# GH#12288
orig = RangeIndex(10)
orig.name = "original"
Reported by Pylint.
Line: 33
Column: 16
expected = Index(np.arange(start, stop, step, dtype=np.int64), name=name)
assert isinstance(result, RangeIndex)
assert result.name is name
assert result._range == range(start, stop, step)
tm.assert_index_equal(result, expected)
def test_constructor_invalid_args(self):
msg = "RangeIndex\\(\\.\\.\\.\\) must be called with integers"
with pytest.raises(TypeError, match=msg):
Reported by Pylint.
Line: 1
Column: 1
from datetime import datetime
import numpy as np
import pytest
from pandas import (
Index,
RangeIndex,
Series,
Reported by Pylint.
Line: 14
Column: 1
import pandas._testing as tm
class TestRangeIndexConstructors:
@pytest.mark.parametrize("name", [None, "foo"])
@pytest.mark.parametrize(
"args, kwargs, start, stop, step",
[
((5,), {}, 0, 5, 1),
Reported by Pylint.
Line: 26
Column: 5
((0, 0), {}, 0, 0, 1),
((), {"start": 0}, 0, 0, 1),
((), {"stop": 0}, 0, 0, 1),
],
)
def test_constructor(self, args, kwargs, start, stop, step, name):
result = RangeIndex(*args, name=name, **kwargs)
expected = Index(np.arange(start, stop, step, dtype=np.int64), name=name)
assert isinstance(result, RangeIndex)
Reported by Pylint.
Line: 26
Column: 5
((0, 0), {}, 0, 0, 1),
((), {"start": 0}, 0, 0, 1),
((), {"stop": 0}, 0, 0, 1),
],
)
def test_constructor(self, args, kwargs, start, stop, step, name):
result = RangeIndex(*args, name=name, **kwargs)
expected = Index(np.arange(start, stop, step, dtype=np.int64), name=name)
assert isinstance(result, RangeIndex)
Reported by Pylint.
Line: 26
Column: 5
((0, 0), {}, 0, 0, 1),
((), {"start": 0}, 0, 0, 1),
((), {"stop": 0}, 0, 0, 1),
],
)
def test_constructor(self, args, kwargs, start, stop, step, name):
result = RangeIndex(*args, name=name, **kwargs)
expected = Index(np.arange(start, stop, step, dtype=np.int64), name=name)
assert isinstance(result, RangeIndex)
Reported by Pylint.
Line: 31
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def test_constructor(self, args, kwargs, start, stop, step, name):
result = RangeIndex(*args, name=name, **kwargs)
expected = Index(np.arange(start, stop, step, dtype=np.int64), name=name)
assert isinstance(result, RangeIndex)
assert result.name is name
assert result._range == range(start, stop, step)
tm.assert_index_equal(result, expected)
def test_constructor_invalid_args(self):
Reported by Bandit.
Line: 32
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
result = RangeIndex(*args, name=name, **kwargs)
expected = Index(np.arange(start, stop, step, dtype=np.int64), name=name)
assert isinstance(result, RangeIndex)
assert result.name is name
assert result._range == range(start, stop, step)
tm.assert_index_equal(result, expected)
def test_constructor_invalid_args(self):
msg = "RangeIndex\\(\\.\\.\\.\\) must be called with integers"
Reported by Bandit.
pandas/tests/plotting/test_style.py
35 issues
Line: 1
Column: 1
import pytest
from pandas import Series
pytest.importorskip("matplotlib")
from pandas.plotting._matplotlib.style import get_standard_colors
pytestmark = pytest.mark.slow
Reported by Pylint.
Line: 1
Column: 1
import pytest
from pandas import Series
pytest.importorskip("matplotlib")
from pandas.plotting._matplotlib.style import get_standard_colors
pytestmark = pytest.mark.slow
Reported by Pylint.
Line: 6
Column: 1
from pandas import Series
pytest.importorskip("matplotlib")
from pandas.plotting._matplotlib.style import get_standard_colors
pytestmark = pytest.mark.slow
class TestGetStandardColors:
Reported by Pylint.
Line: 11
Column: 1
pytestmark = pytest.mark.slow
class TestGetStandardColors:
@pytest.mark.parametrize(
"num_colors, expected",
[
(3, ["red", "green", "blue"]),
(5, ["red", "green", "blue", "red", "green"]),
Reported by Pylint.
Line: 20
Column: 5
(7, ["red", "green", "blue", "red", "green", "blue", "red"]),
(2, ["red", "green"]),
(1, ["red"]),
],
)
def test_default_colors_named_from_prop_cycle(self, num_colors, expected):
import matplotlib as mpl
from matplotlib.pyplot import cycler
Reported by Pylint.
Line: 20
Column: 5
(7, ["red", "green", "blue", "red", "green", "blue", "red"]),
(2, ["red", "green"]),
(1, ["red"]),
],
)
def test_default_colors_named_from_prop_cycle(self, num_colors, expected):
import matplotlib as mpl
from matplotlib.pyplot import cycler
Reported by Pylint.
Line: 23
Column: 9
],
)
def test_default_colors_named_from_prop_cycle(self, num_colors, expected):
import matplotlib as mpl
from matplotlib.pyplot import cycler
mpl_params = {
"axes.prop_cycle": cycler(color=["red", "green", "blue"]),
}
Reported by Pylint.
Line: 24
Column: 9
)
def test_default_colors_named_from_prop_cycle(self, num_colors, expected):
import matplotlib as mpl
from matplotlib.pyplot import cycler
mpl_params = {
"axes.prop_cycle": cycler(color=["red", "green", "blue"]),
}
with mpl.rc_context(rc=mpl_params):
Reported by Pylint.
Line: 31
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
}
with mpl.rc_context(rc=mpl_params):
result = get_standard_colors(num_colors=num_colors)
assert result == expected
@pytest.mark.parametrize(
"num_colors, expected",
[
(1, ["b"]),
Reported by Bandit.
Line: 41
Column: 5
(4, ["b", "g", "r", "y"]),
(5, ["b", "g", "r", "y", "b"]),
(7, ["b", "g", "r", "y", "b", "g", "r"]),
],
)
def test_default_colors_named_from_prop_cycle_string(self, num_colors, expected):
import matplotlib as mpl
from matplotlib.pyplot import cycler
Reported by Pylint.
pandas/tests/frame/methods/test_nlargest.py
35 issues
Line: 8
Column: 1
from string import ascii_lowercase
import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
Reported by Pylint.
Line: 84
Column: 31
],
)
@pytest.mark.parametrize("n", range(1, 11))
def test_nlargest_n(self, df_strings, nselect_method, n, order):
# GH#10393
df = df_strings
if "b" in order:
error_msg = (
Reported by Pylint.
Line: 104
Column: 35
@pytest.mark.parametrize(
"columns", [["group", "category_string"], ["group", "string"]]
)
def test_nlargest_error(self, df_main_dtypes, nselect_method, columns):
df = df_main_dtypes
col = columns[1]
error_msg = (
f"Column '{col}' has dtype {df[col].dtype}, "
f"cannot use method '{nselect_method}' with this dtype"
Reported by Pylint.
Line: 121
Column: 40
with pytest.raises(TypeError, match=error_msg):
getattr(df, nselect_method)(2, columns)
def test_nlargest_all_dtypes(self, df_main_dtypes):
df = df_main_dtypes
df.nsmallest(2, list(set(df) - {"category_string", "string"}))
df.nlargest(2, list(set(df) - {"category_string", "string"}))
def test_nlargest_duplicates_on_starter_columns(self):
Reported by Pylint.
Line: 160
Column: 47
[["a", "b", "c"], ["c", "b", "a"], ["a"], ["b"], ["a", "b"], ["c", "b"]],
)
@pytest.mark.parametrize("n", range(1, 6))
def test_nlargest_n_duplicate_index(self, df_duplicates, n, order):
# GH#13412
df = df_duplicates
result = df.nsmallest(n, order)
expected = df.sort_values(order).head(n)
Reported by Pylint.
Line: 15
Column: 1
@pytest.fixture
def df_duplicates():
return pd.DataFrame(
{"a": [1, 2, 3, 4, 4], "b": [1, 1, 1, 1, 1], "c": [0, 1, 2, 5, 4]},
index=[0, 0, 1, 1, 1],
)
Reported by Pylint.
Line: 23
Column: 1
@pytest.fixture
def df_strings():
return pd.DataFrame(
{
"a": np.random.permutation(10),
"b": list(ascii_lowercase[:10]),
"c": np.random.permutation(10).astype("float64"),
Reported by Pylint.
Line: 34
Column: 1
@pytest.fixture
def df_main_dtypes():
return pd.DataFrame(
{
"group": [1, 1, 2],
"int": [1, 2, 3],
"float": [4.0, 5.0, 6.0],
Reported by Pylint.
Line: 61
Column: 1
)
class TestNLargestNSmallest:
# ----------------------------------------------------------------------
# Top / bottom
@pytest.mark.parametrize(
"order",
Reported by Pylint.
Line: 82
Column: 5
# dups!
["b", "c", "c"],
],
)
@pytest.mark.parametrize("n", range(1, 11))
def test_nlargest_n(self, df_strings, nselect_method, n, order):
# GH#10393
df = df_strings
if "b" in order:
Reported by Pylint.
pandas/tests/window/test_win_type.py
35 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas.errors import UnsupportedFunctionCall
import pandas.util._test_decorators as td
from pandas import (
DataFrame,
Series,
Reported by Pylint.
Line: 155
Column: 9
@td.skip_if_no_scipy
def test_win_type_not_implemented():
class CustomIndexer(BaseIndexer):
def get_window_bounds(self, num_values, min_periods, center, closed):
return np.array([0, 1]), np.array([1, 2])
df = DataFrame({"values": range(2)})
indexer = CustomIndexer()
with pytest.raises(NotImplementedError, match="BaseIndexer subclasses not"):
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas.errors import UnsupportedFunctionCall
import pandas.util._test_decorators as td
from pandas import (
DataFrame,
Series,
Reported by Pylint.
Line: 19
Column: 1
@td.skip_if_no_scipy
def test_constructor(frame_or_series):
# GH 12669
c = frame_or_series(range(5)).rolling
# valid
c(win_type="boxcar", window=2, min_periods=1)
Reported by Pylint.
Line: 21
Column: 5
@td.skip_if_no_scipy
def test_constructor(frame_or_series):
# GH 12669
c = frame_or_series(range(5)).rolling
# valid
c(win_type="boxcar", window=2, min_periods=1)
c(win_type="boxcar", window=2, min_periods=1, center=True)
c(win_type="boxcar", window=2, min_periods=1, center=False)
Reported by Pylint.
Line: 31
Column: 1
@pytest.mark.parametrize("w", [2.0, "foo", np.array([2])])
@td.skip_if_no_scipy
def test_invalid_constructor(frame_or_series, w):
# not valid
c = frame_or_series(range(5)).rolling
with pytest.raises(ValueError, match="min_periods must be an integer"):
c(win_type="boxcar", window=2, min_periods=w)
Reported by Pylint.
Line: 31
Column: 1
@pytest.mark.parametrize("w", [2.0, "foo", np.array([2])])
@td.skip_if_no_scipy
def test_invalid_constructor(frame_or_series, w):
# not valid
c = frame_or_series(range(5)).rolling
with pytest.raises(ValueError, match="min_periods must be an integer"):
c(win_type="boxcar", window=2, min_periods=w)
Reported by Pylint.
Line: 34
Column: 5
def test_invalid_constructor(frame_or_series, w):
# not valid
c = frame_or_series(range(5)).rolling
with pytest.raises(ValueError, match="min_periods must be an integer"):
c(win_type="boxcar", window=2, min_periods=w)
with pytest.raises(ValueError, match="center must be a boolean"):
c(win_type="boxcar", window=2, min_periods=1, center=w)
Reported by Pylint.
Line: 43
Column: 1
@pytest.mark.parametrize("wt", ["foobar", 1])
@td.skip_if_no_scipy
def test_invalid_constructor_wintype(frame_or_series, wt):
c = frame_or_series(range(5)).rolling
with pytest.raises(ValueError, match="Invalid win_type"):
c(win_type=wt, window=2)
Reported by Pylint.
Line: 43
Column: 1
@pytest.mark.parametrize("wt", ["foobar", 1])
@td.skip_if_no_scipy
def test_invalid_constructor_wintype(frame_or_series, wt):
c = frame_or_series(range(5)).rolling
with pytest.raises(ValueError, match="Invalid win_type"):
c(win_type=wt, window=2)
Reported by Pylint.
pandas/tests/indexes/object/test_indexing.py
34 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas._libs.missing import is_matching_na
import pandas as pd
from pandas import Index
import pandas._testing as tm
Reported by Pylint.
Line: 4
Column: 1
import numpy as np
import pytest
from pandas._libs.missing import is_matching_na
import pandas as pd
from pandas import Index
import pandas._testing as tm
Reported by Pylint.
Line: 4
Column: 1
import numpy as np
import pytest
from pandas._libs.missing import is_matching_na
import pandas as pd
from pandas import Index
import pandas._testing as tm
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas._libs.missing import is_matching_na
import pandas as pd
from pandas import Index
import pandas._testing as tm
Reported by Pylint.
Line: 11
Column: 1
import pandas._testing as tm
class TestGetLoc:
def test_get_loc_raises_object_nearest(self):
index = Index(["a", "c"])
with pytest.raises(TypeError, match="unsupported operand type"):
with tm.assert_produces_warning(FutureWarning, match="deprecated"):
index.get_loc("a", method="nearest")
Reported by Pylint.
Line: 12
Column: 5
class TestGetLoc:
def test_get_loc_raises_object_nearest(self):
index = Index(["a", "c"])
with pytest.raises(TypeError, match="unsupported operand type"):
with tm.assert_produces_warning(FutureWarning, match="deprecated"):
index.get_loc("a", method="nearest")
Reported by Pylint.
Line: 12
Column: 5
class TestGetLoc:
def test_get_loc_raises_object_nearest(self):
index = Index(["a", "c"])
with pytest.raises(TypeError, match="unsupported operand type"):
with tm.assert_produces_warning(FutureWarning, match="deprecated"):
index.get_loc("a", method="nearest")
Reported by Pylint.
Line: 18
Column: 5
with tm.assert_produces_warning(FutureWarning, match="deprecated"):
index.get_loc("a", method="nearest")
def test_get_loc_raises_object_tolerance(self):
index = Index(["a", "c"])
with pytest.raises(TypeError, match="unsupported operand type"):
with tm.assert_produces_warning(FutureWarning, match="deprecated"):
index.get_loc("a", method="pad", tolerance="invalid")
Reported by Pylint.
Line: 18
Column: 5
with tm.assert_produces_warning(FutureWarning, match="deprecated"):
index.get_loc("a", method="nearest")
def test_get_loc_raises_object_tolerance(self):
index = Index(["a", "c"])
with pytest.raises(TypeError, match="unsupported operand type"):
with tm.assert_produces_warning(FutureWarning, match="deprecated"):
index.get_loc("a", method="pad", tolerance="invalid")
Reported by Pylint.
Line: 25
Column: 1
index.get_loc("a", method="pad", tolerance="invalid")
class TestGetIndexer:
@pytest.mark.parametrize(
"method,expected",
[
("pad", np.array([-1, 0, 1, 1], dtype=np.intp)),
("backfill", np.array([0, 0, 1, -1], dtype=np.intp)),
Reported by Pylint.
pandas/tests/window/test_base_indexer.py
34 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas import (
DataFrame,
Series,
date_range,
)
import pandas._testing as tm
Reported by Pylint.
Line: 50
Column: 20
start = np.empty(num_values, dtype=np.int64)
end = np.empty(num_values, dtype=np.int64)
for i in range(num_values):
if self.use_expanding[i]:
start[i] = 0
end[i] = i + 1
else:
start[i] = i
end[i] = i + self.window_size
Reported by Pylint.
Line: 281
Column: 20
start = np.empty(num_values, dtype=np.int64)
end = np.empty(num_values, dtype=np.int64)
for i in range(num_values):
if self.use_expanding[i]:
start[i] = 0
end[i] = max(i + end_value, 1)
else:
start[i] = i
end[i] = i + self.window_size
Reported by Pylint.
Line: 24
Column: 9
def test_bad_get_window_bounds_signature():
class BadIndexer(BaseIndexer):
def get_window_bounds(self):
return None
indexer = BadIndexer()
with pytest.raises(ValueError, match="BadIndexer does not implement"):
Series(range(5)).rolling(indexer)
Reported by Pylint.
Line: 46
Column: 9
df = DataFrame({"values": range(5)})
class CustomIndexer(BaseIndexer):
def get_window_bounds(self, num_values, min_periods, center, closed):
start = np.empty(num_values, dtype=np.int64)
end = np.empty(num_values, dtype=np.int64)
for i in range(num_values):
if self.use_expanding[i]:
start[i] = 0
Reported by Pylint.
Line: 68
Column: 9
df = DataFrame({"values": range(5)})
class CustomIndexer(BaseIndexer):
def get_window_bounds(self, num_values, min_periods, center, closed):
start = np.empty(num_values, dtype=np.int64)
end = np.empty(num_values, dtype=np.int64)
for i in range(num_values):
if center and min_periods == 1 and closed == "both" and i == 2:
start[i] = 0
Reported by Pylint.
Line: 167
Column: 43
# Check that the rolling function output matches applying an alternative
# function to the rolling window object
expected2 = constructor(rolling.apply(lambda x: np_func(x, **np_kwargs)))
tm.assert_equal(result, expected2)
# Check that the function output matches applying an alternative function
# if min_periods isn't specified
# GH 39604: After count-min_periods deprecation, apply(lambda x: len(x))
Reported by Pylint.
Line: 177
Column: 44
min_periods = 0 if func == "count" else None
rolling3 = constructor(values).rolling(window=indexer, min_periods=min_periods)
result3 = getattr(rolling3, func)()
expected3 = constructor(rolling3.apply(lambda x: np_func(x, **np_kwargs)))
tm.assert_equal(result3, expected3)
@pytest.mark.parametrize("constructor", [Series, DataFrame])
def test_rolling_forward_skewness(constructor):
Reported by Pylint.
Line: 277
Column: 9
def test_indexer_quantile_sum(end_value, values, func, args):
# GH 37153
class CustomIndexer(BaseIndexer):
def get_window_bounds(self, num_values, min_periods, center, closed):
start = np.empty(num_values, dtype=np.int64)
end = np.empty(num_values, dtype=np.int64)
for i in range(num_values):
if self.use_expanding[i]:
start[i] = 0
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas import (
DataFrame,
Series,
date_range,
)
import pandas._testing as tm
Reported by Pylint.
pandas/tests/base/test_misc.py
34 issues
Line: 4
Column: 1
import sys
import numpy as np
import pytest
from pandas.compat import (
IS64,
PYPY,
)
Reported by Pylint.
Line: 154
Column: 9
msg = f"index {size} is out of bounds for axis 0 with size {size}"
with pytest.raises(IndexError, match=msg):
index[size]
msg = "single positional indexer is out-of-bounds"
with pytest.raises(IndexError, match=msg):
series.iloc[size]
Reported by Pylint.
Line: 157
Column: 9
index[size]
msg = "single positional indexer is out-of-bounds"
with pytest.raises(IndexError, match=msg):
series.iloc[size]
Reported by Pylint.
Line: 1
Column: 1
import sys
import numpy as np
import pytest
from pandas.compat import (
IS64,
PYPY,
)
Reported by Pylint.
Line: 35
Column: 1
("truediv", "/"),
("floordiv", "//"),
],
)
@pytest.mark.parametrize("klass", [Series, DataFrame])
def test_binary_ops_docstring(klass, op_name, op):
# not using the all_arithmetic_functions fixture with _get_opstr
# as _get_opstr is used internally in the dynamic implementation of the docstring
operand1 = klass.__name__.lower()
Reported by Pylint.
Line: 35
Column: 1
("truediv", "/"),
("floordiv", "//"),
],
)
@pytest.mark.parametrize("klass", [Series, DataFrame])
def test_binary_ops_docstring(klass, op_name, op):
# not using the all_arithmetic_functions fixture with _get_opstr
# as _get_opstr is used internally in the dynamic implementation of the docstring
operand1 = klass.__name__.lower()
Reported by Pylint.
Line: 43
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
operand1 = klass.__name__.lower()
operand2 = "other"
expected_str = " ".join([operand1, op, operand2])
assert expected_str in getattr(klass, op_name).__doc__
# reverse version of the binary ops
expected_str = " ".join([operand2, op, operand1])
assert expected_str in getattr(klass, "r" + op_name).__doc__
Reported by Bandit.
Line: 47
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
# reverse version of the binary ops
expected_str = " ".join([operand2, op, operand1])
assert expected_str in getattr(klass, "r" + op_name).__doc__
def test_ndarray_compat_properties(index_or_series_obj):
obj = index_or_series_obj
Reported by Bandit.
Line: 50
Column: 1
assert expected_str in getattr(klass, "r" + op_name).__doc__
def test_ndarray_compat_properties(index_or_series_obj):
obj = index_or_series_obj
# Check that we work.
for p in ["shape", "dtype", "T", "nbytes"]:
assert getattr(obj, p, None) is not None
Reported by Pylint.
Line: 54
Column: 9
obj = index_or_series_obj
# Check that we work.
for p in ["shape", "dtype", "T", "nbytes"]:
assert getattr(obj, p, None) is not None
# deprecated properties
for p in ["strides", "itemsize", "base", "data"]:
assert not hasattr(obj, p)
Reported by Pylint.
pandas/tests/resample/test_deprecated.py
34 issues
Line: 7
Column: 1
)
import numpy as np
import pytest
import pandas as pd
from pandas import (
DataFrame,
Series,
Reported by Pylint.
Line: 83
Column: 43
@all_ts
@pytest.mark.parametrize("arg", ["mean", {"value": "mean"}, ["mean"]])
def test_resample_loffset_arg_type(frame, create_index, arg):
# GH 13218, 15002
df = frame
expected_means = [df.values[i : i + 2].mean() for i in range(0, len(df.values), 2)]
expected_index = create_index(df.index[0], periods=len(df.index) / 2, freq="2D")
Reported by Pylint.
Line: 262
Column: 3
with tm.assert_produces_warning(FutureWarning):
expected = s.to_timestamp().resample(end_freq, base=base).mean()
if end_freq == "M":
# TODO: is non-tick the relevant characteristic? (GH 33815)
expected.index = expected.index._with_freq(None)
tm.assert_series_equal(result, expected)
def test_resample_base_with_timedeltaindex():
Reported by Pylint.
Line: 263
Column: 26
expected = s.to_timestamp().resample(end_freq, base=base).mean()
if end_freq == "M":
# TODO: is non-tick the relevant characteristic? (GH 33815)
expected.index = expected.index._with_freq(None)
tm.assert_series_equal(result, expected)
def test_resample_base_with_timedeltaindex():
# GH 10530
Reported by Pylint.
Line: 306
Column: 5
)
expected = Series([1.0, 1.0, 1.0, 1.0], index=idx)
expected.index._data.freq = "3s"
tm.assert_series_equal(result, expected)
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: 43
Column: 1
@pytest.fixture
def create_index(_index_factory):
def _create_index(*args, **kwargs):
"""return the _index_factory created using the args, kwargs"""
return _index_factory(*args, **kwargs)
return _create_index
Reported by Pylint.
Line: 52
Column: 1
# new test to check that all FutureWarning are triggered
def test_deprecating_on_loffset_and_base():
# GH 31809
idx = date_range("2001-01-01", periods=4, freq="T")
df = DataFrame(data=4 * [range(2)], index=idx, columns=["a", "b"])
Reported by Pylint.
Line: 56
Column: 5
# GH 31809
idx = date_range("2001-01-01", periods=4, freq="T")
df = DataFrame(data=4 * [range(2)], index=idx, columns=["a", "b"])
with tm.assert_produces_warning(FutureWarning):
pd.Grouper(freq="10s", base=0)
with tm.assert_produces_warning(FutureWarning):
pd.Grouper(freq="10s", loffset="0s")
Reported by Pylint.
Line: 83
Column: 1
@all_ts
@pytest.mark.parametrize("arg", ["mean", {"value": "mean"}, ["mean"]])
def test_resample_loffset_arg_type(frame, create_index, arg):
# GH 13218, 15002
df = frame
expected_means = [df.values[i : i + 2].mean() for i in range(0, len(df.values), 2)]
expected_index = create_index(df.index[0], periods=len(df.index) / 2, freq="2D")
Reported by Pylint.
pandas/tests/test_flags.py
34 issues
Line: 1
Column: 1
import pytest
import pandas as pd
class TestFlags:
def test_equality(self):
a = pd.DataFrame().set_flags(allows_duplicate_labels=True).flags
b = pd.DataFrame().set_flags(allows_duplicate_labels=False).flags
Reported by Pylint.
Line: 45
Column: 13
assert flags["allows_duplicate_labels"] is False
with pytest.raises(KeyError, match="a"):
flags["a"]
with pytest.raises(ValueError, match="a"):
flags["a"] = 10
Reported by Pylint.
Line: 1
Column: 1
import pytest
import pandas as pd
class TestFlags:
def test_equality(self):
a = pd.DataFrame().set_flags(allows_duplicate_labels=True).flags
b = pd.DataFrame().set_flags(allows_duplicate_labels=False).flags
Reported by Pylint.
Line: 6
Column: 1
import pandas as pd
class TestFlags:
def test_equality(self):
a = pd.DataFrame().set_flags(allows_duplicate_labels=True).flags
b = pd.DataFrame().set_flags(allows_duplicate_labels=False).flags
assert a == a
Reported by Pylint.
Line: 7
Column: 5
class TestFlags:
def test_equality(self):
a = pd.DataFrame().set_flags(allows_duplicate_labels=True).flags
b = pd.DataFrame().set_flags(allows_duplicate_labels=False).flags
assert a == a
assert b == b
Reported by Pylint.
Line: 7
Column: 5
class TestFlags:
def test_equality(self):
a = pd.DataFrame().set_flags(allows_duplicate_labels=True).flags
b = pd.DataFrame().set_flags(allows_duplicate_labels=False).flags
assert a == a
assert b == b
Reported by Pylint.
Line: 8
Column: 9
class TestFlags:
def test_equality(self):
a = pd.DataFrame().set_flags(allows_duplicate_labels=True).flags
b = pd.DataFrame().set_flags(allows_duplicate_labels=False).flags
assert a == a
assert b == b
assert a != b
Reported by Pylint.
Line: 9
Column: 9
class TestFlags:
def test_equality(self):
a = pd.DataFrame().set_flags(allows_duplicate_labels=True).flags
b = pd.DataFrame().set_flags(allows_duplicate_labels=False).flags
assert a == a
assert b == b
assert a != b
assert a != 2
Reported by Pylint.
Line: 11
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
a = pd.DataFrame().set_flags(allows_duplicate_labels=True).flags
b = pd.DataFrame().set_flags(allows_duplicate_labels=False).flags
assert a == a
assert b == b
assert a != b
assert a != 2
def test_set(self):
Reported by Bandit.
Line: 11
Column: 16
a = pd.DataFrame().set_flags(allows_duplicate_labels=True).flags
b = pd.DataFrame().set_flags(allows_duplicate_labels=False).flags
assert a == a
assert b == b
assert a != b
assert a != 2
def test_set(self):
Reported by Pylint.
pandas/tests/indexes/period/test_setops.py
34 issues
Line: 156
Column: 3
expected = index.astype(object).union(index2.astype(object), sort=sort)
tm.assert_index_equal(result, expected)
# TODO: belongs elsewhere
def test_union_dataframe_index(self):
rng1 = period_range("1/1/1999", "1/1/2012", freq="M")
s1 = pd.Series(np.random.randn(len(rng1)), rng1)
rng2 = period_range("1/1/1980", "12/1/2001", freq="M")
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pandas as pd
from pandas import (
PeriodIndex,
date_range,
period_range,
)
import pandas._testing as tm
Reported by Pylint.
Line: 16
Column: 1
return obj.take(np.random.permutation(len(obj)))
class TestPeriodIndex:
def test_union(self, sort):
# union
other1 = period_range("1/1/2000", freq="D", periods=5)
rng1 = period_range("1/6/2000", freq="D", periods=5)
expected1 = PeriodIndex(
Reported by Pylint.
Line: 17
Column: 5
class TestPeriodIndex:
def test_union(self, sort):
# union
other1 = period_range("1/1/2000", freq="D", periods=5)
rng1 = period_range("1/6/2000", freq="D", periods=5)
expected1 = PeriodIndex(
[
Reported by Pylint.
Line: 17
Column: 5
class TestPeriodIndex:
def test_union(self, sort):
# union
other1 = period_range("1/1/2000", freq="D", periods=5)
rng1 = period_range("1/6/2000", freq="D", periods=5)
expected1 = PeriodIndex(
[
Reported by Pylint.
Line: 17
Column: 5
class TestPeriodIndex:
def test_union(self, sort):
# union
other1 = period_range("1/1/2000", freq="D", periods=5)
rng1 = period_range("1/6/2000", freq="D", periods=5)
expected1 = PeriodIndex(
[
Reported by Pylint.
Line: 137
Column: 5
expected = expected.sort_values()
tm.assert_index_equal(result_union, expected)
def test_union_misc(self, sort):
index = period_range("1/1/2000", "1/20/2000", freq="D")
result = index[:-5].union(index[10:], sort=sort)
tm.assert_index_equal(result, index)
Reported by Pylint.
Line: 137
Column: 5
expected = expected.sort_values()
tm.assert_index_equal(result_union, expected)
def test_union_misc(self, sort):
index = period_range("1/1/2000", "1/20/2000", freq="D")
result = index[:-5].union(index[10:], sort=sort)
tm.assert_index_equal(result, index)
Reported by Pylint.
Line: 147
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
result = _permute(index[:-5]).union(_permute(index[10:]), sort=sort)
if sort is None:
tm.assert_index_equal(result, index)
assert tm.equalContents(result, index)
# cast if different frequencies
index = period_range("1/1/2000", "1/20/2000", freq="D")
index2 = period_range("1/1/2000", "1/20/2000", freq="W-WED")
result = index.union(index2, sort=sort)
Reported by Bandit.
Line: 157
Column: 5
tm.assert_index_equal(result, expected)
# TODO: belongs elsewhere
def test_union_dataframe_index(self):
rng1 = period_range("1/1/1999", "1/1/2012", freq="M")
s1 = pd.Series(np.random.randn(len(rng1)), rng1)
rng2 = period_range("1/1/1980", "12/1/2001", freq="M")
s2 = pd.Series(np.random.randn(len(rng2)), rng2)
Reported by Pylint.