The following issues were found
pandas/tests/frame/indexing/test_delitem.py
25 issues
Line: 4
Column: 1
import re
import numpy as np
import pytest
from pandas import (
DataFrame,
MultiIndex,
)
Reported by Pylint.
Line: 1
Column: 1
import re
import numpy as np
import pytest
from pandas import (
DataFrame,
MultiIndex,
)
Reported by Pylint.
Line: 12
Column: 1
)
class TestDataFrameDelItem:
def test_delitem(self, float_frame):
del float_frame["A"]
assert "A" not in float_frame
def test_delitem_multiindex(self):
Reported by Pylint.
Line: 13
Column: 5
class TestDataFrameDelItem:
def test_delitem(self, float_frame):
del float_frame["A"]
assert "A" not in float_frame
def test_delitem_multiindex(self):
midx = MultiIndex.from_product([["A", "B"], [1, 2]])
Reported by Pylint.
Line: 13
Column: 5
class TestDataFrameDelItem:
def test_delitem(self, float_frame):
del float_frame["A"]
assert "A" not in float_frame
def test_delitem_multiindex(self):
midx = MultiIndex.from_product([["A", "B"], [1, 2]])
Reported by Pylint.
Line: 15
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
class TestDataFrameDelItem:
def test_delitem(self, float_frame):
del float_frame["A"]
assert "A" not in float_frame
def test_delitem_multiindex(self):
midx = MultiIndex.from_product([["A", "B"], [1, 2]])
df = DataFrame(np.random.randn(4, 4), columns=midx)
assert len(df.columns) == 4
Reported by Bandit.
Line: 17
Column: 5
del float_frame["A"]
assert "A" not in float_frame
def test_delitem_multiindex(self):
midx = MultiIndex.from_product([["A", "B"], [1, 2]])
df = DataFrame(np.random.randn(4, 4), columns=midx)
assert len(df.columns) == 4
assert ("A",) in df.columns
assert "A" in df.columns
Reported by Pylint.
Line: 17
Column: 5
del float_frame["A"]
assert "A" not in float_frame
def test_delitem_multiindex(self):
midx = MultiIndex.from_product([["A", "B"], [1, 2]])
df = DataFrame(np.random.randn(4, 4), columns=midx)
assert len(df.columns) == 4
assert ("A",) in df.columns
assert "A" in df.columns
Reported by Pylint.
Line: 19
Column: 9
def test_delitem_multiindex(self):
midx = MultiIndex.from_product([["A", "B"], [1, 2]])
df = DataFrame(np.random.randn(4, 4), columns=midx)
assert len(df.columns) == 4
assert ("A",) in df.columns
assert "A" in df.columns
result = df["A"]
Reported by Pylint.
Line: 20
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def test_delitem_multiindex(self):
midx = MultiIndex.from_product([["A", "B"], [1, 2]])
df = DataFrame(np.random.randn(4, 4), columns=midx)
assert len(df.columns) == 4
assert ("A",) in df.columns
assert "A" in df.columns
result = df["A"]
assert isinstance(result, DataFrame)
Reported by Bandit.
asv_bench/benchmarks/io/excel.py
25 issues
Line: 4
Column: 1
from io import BytesIO
import numpy as np
from odf.opendocument import OpenDocumentSpreadsheet
from odf.table import (
Table,
TableCell,
TableRow,
)
Reported by Pylint.
Line: 5
Column: 1
import numpy as np
from odf.opendocument import OpenDocumentSpreadsheet
from odf.table import (
Table,
TableCell,
TableRow,
)
from odf.text import P
Reported by Pylint.
Line: 10
Column: 1
TableCell,
TableRow,
)
from odf.text import P
from pandas import (
DataFrame,
ExcelWriter,
date_range,
Reported by Pylint.
Line: 12
Column: 1
)
from odf.text import P
from pandas import (
DataFrame,
ExcelWriter,
date_range,
read_excel,
)
Reported by Pylint.
Line: 19
Column: 1
read_excel,
)
from ..pandas_vb_common import tm
def _generate_dataframe():
N = 2000
C = 5
Reported by Pylint.
Line: 89
Column: 1
read_excel(fname, engine=engine)
from ..pandas_vb_common import setup # noqa: F401 isort:skip
Reported by Pylint.
Line: 39
Column: 21
params = ["openpyxl", "xlsxwriter", "xlwt"]
param_names = ["engine"]
def setup(self, engine):
self.df = _generate_dataframe()
def time_write_excel(self, engine):
bio = BytesIO()
bio.seek(0)
Reported by Pylint.
Line: 40
Column: 9
param_names = ["engine"]
def setup(self, engine):
self.df = _generate_dataframe()
def time_write_excel(self, engine):
bio = BytesIO()
bio.seek(0)
writer = ExcelWriter(bio, engine=engine)
Reported by Pylint.
Line: 73
Column: 9
doc.save(self.fname_odf)
def setup_cache(self):
self.df = _generate_dataframe()
self.df.to_excel(self.fname_excel, sheet_name="Sheet1")
self.df.to_excel(self.fname_excel_xls, sheet_name="Sheet1")
self._create_odf()
Reported by Pylint.
Line: 89
Column: 1
read_excel(fname, engine=engine)
from ..pandas_vb_common import setup # noqa: F401 isort:skip
Reported by Pylint.
pandas/tests/indexes/test_frozen.py
25 issues
Line: 3
Column: 1
import re
import pytest
from pandas.core.indexes.frozen import FrozenList
class TestFrozenList:
Reported by Pylint.
Line: 13
Column: 9
unicode_container = FrozenList(["\u05d0", "\u05d1", "c"])
def setup_method(self, _):
self.lst = [1, 2, 3, 4, 5]
self.container = FrozenList(self.lst)
def check_mutable_error(self, *args, **kwargs):
# Pass whatever function you normally would to pytest.raises
# (after the Exception kind).
Reported by Pylint.
Line: 14
Column: 9
def setup_method(self, _):
self.lst = [1, 2, 3, 4, 5]
self.container = FrozenList(self.lst)
def check_mutable_error(self, *args, **kwargs):
# Pass whatever function you normally would to pytest.raises
# (after the Exception kind).
mutable_regex = re.compile("does not support mutable operations")
Reported by Pylint.
Line: 1
Column: 1
import re
import pytest
from pandas.core.indexes.frozen import FrozenList
class TestFrozenList:
Reported by Pylint.
Line: 8
Column: 1
from pandas.core.indexes.frozen import FrozenList
class TestFrozenList:
unicode_container = FrozenList(["\u05d0", "\u05d1", "c"])
def setup_method(self, _):
self.lst = [1, 2, 3, 4, 5]
Reported by Pylint.
Line: 12
Column: 5
unicode_container = FrozenList(["\u05d0", "\u05d1", "c"])
def setup_method(self, _):
self.lst = [1, 2, 3, 4, 5]
self.container = FrozenList(self.lst)
def check_mutable_error(self, *args, **kwargs):
# Pass whatever function you normally would to pytest.raises
Reported by Pylint.
Line: 16
Column: 5
self.lst = [1, 2, 3, 4, 5]
self.container = FrozenList(self.lst)
def check_mutable_error(self, *args, **kwargs):
# Pass whatever function you normally would to pytest.raises
# (after the Exception kind).
mutable_regex = re.compile("does not support mutable operations")
msg = "'(_s)?re.(SRE_)?Pattern' object is not callable"
with pytest.raises(TypeError, match=msg):
Reported by Pylint.
Line: 16
Column: 5
self.lst = [1, 2, 3, 4, 5]
self.container = FrozenList(self.lst)
def check_mutable_error(self, *args, **kwargs):
# Pass whatever function you normally would to pytest.raises
# (after the Exception kind).
mutable_regex = re.compile("does not support mutable operations")
msg = "'(_s)?re.(SRE_)?Pattern' object is not callable"
with pytest.raises(TypeError, match=msg):
Reported by Pylint.
Line: 24
Column: 5
with pytest.raises(TypeError, match=msg):
mutable_regex(*args, **kwargs)
def test_no_mutable_funcs(self):
def setitem():
self.container[0] = 5
self.check_mutable_error(setitem)
Reported by Pylint.
Line: 50
Column: 5
for meth in mutable_methods:
self.check_mutable_error(getattr(self.container, meth))
def test_slicing_maintains_type(self):
result = self.container[1:2]
expected = self.lst[1:2]
self.check_result(result, expected)
def check_result(self, result, expected):
Reported by Pylint.
pandas/tests/indexes/ranges/test_setops.py
25 issues
Line: 7
Column: 1
)
import numpy as np
import pytest
from pandas import (
Index,
Int64Index,
RangeIndex,
Reported by Pylint.
Line: 289
Column: 16
tm.assert_index_equal(res1, expected_notsorted, exact=True)
res2 = idx2.union(idx1, sort=None)
res3 = idx1._int64index.union(idx2, sort=None)
tm.assert_index_equal(res2, expected_sorted, exact=True)
tm.assert_index_equal(res3, expected_sorted)
def test_difference(self):
# GH#12034 Cases where we operate against another RangeIndex and may
Reported by Pylint.
Line: 325
Column: 20
obj = RangeIndex.from_range(range(1, 10), name="foo")
result = obj.difference(obj[::2])
expected = obj[1::2]._int64index
tm.assert_index_equal(result, expected, exact=True)
result = obj.difference(obj[1::2])
expected = obj[::2]._int64index
tm.assert_index_equal(result, expected, exact=True)
Reported by Pylint.
Line: 329
Column: 20
tm.assert_index_equal(result, expected, exact=True)
result = obj.difference(obj[1::2])
expected = obj[::2]._int64index
tm.assert_index_equal(result, expected, exact=True)
def test_symmetric_difference(self):
# GH#12034 Cases where we operate against another RangeIndex and may
# get back another RangeIndex
Reported by Pylint.
Line: 1
Column: 1
from datetime import (
datetime,
timedelta,
)
import numpy as np
import pytest
from pandas import (
Reported by Pylint.
Line: 18
Column: 1
import pandas._testing as tm
class TestRangeIndexSetOps:
@pytest.mark.parametrize("klass", [RangeIndex, Int64Index, UInt64Index])
def test_intersection_mismatched_dtype(self, klass):
# check that we cast to float, not object
index = RangeIndex(start=0, stop=20, step=2, name="foo")
index = klass(index)
Reported by Pylint.
Line: 20
Column: 5
class TestRangeIndexSetOps:
@pytest.mark.parametrize("klass", [RangeIndex, Int64Index, UInt64Index])
def test_intersection_mismatched_dtype(self, klass):
# check that we cast to float, not object
index = RangeIndex(start=0, stop=20, step=2, name="foo")
index = klass(index)
flt = index.astype(np.float64)
Reported by Pylint.
Line: 20
Column: 5
class TestRangeIndexSetOps:
@pytest.mark.parametrize("klass", [RangeIndex, Int64Index, UInt64Index])
def test_intersection_mismatched_dtype(self, klass):
# check that we cast to float, not object
index = RangeIndex(start=0, stop=20, step=2, name="foo")
index = klass(index)
flt = index.astype(np.float64)
Reported by Pylint.
Line: 48
Column: 5
result = flt[:0].intersection(index)
tm.assert_index_equal(result, flt[:0], exact=True)
def test_intersection_empty(self, sort, names):
# name retention on empty intersections
index = RangeIndex(start=0, stop=20, step=2, name=names[0])
# empty other
result = index.intersection(index[:0].rename(names[1]), sort=sort)
Reported by Pylint.
Line: 48
Column: 5
result = flt[:0].intersection(index)
tm.assert_index_equal(result, flt[:0], exact=True)
def test_intersection_empty(self, sort, names):
# name retention on empty intersections
index = RangeIndex(start=0, stop=20, step=2, name=names[0])
# empty other
result = index.intersection(index[:0].rename(names[1]), sort=sort)
Reported by Pylint.
pandas/tests/io/pytables/test_keys.py
25 issues
Line: 1
Column: 1
import pytest
from pandas import (
DataFrame,
HDFStore,
_testing as tm,
)
from pandas.tests.io.pytables.common import (
ensure_clean_path,
Reported by Pylint.
Line: 77
Column: 9
assert store.keys() == ["/df"]
store._handle.create_soft_link(store._handle.root, "symlink", "df")
# Should ignore the softlink
assert store.keys() == ["/df"]
Reported by Pylint.
Line: 77
Column: 40
assert store.keys() == ["/df"]
store._handle.create_soft_link(store._handle.root, "symlink", "df")
# Should ignore the softlink
assert store.keys() == ["/df"]
Reported by Pylint.
Line: 1
Column: 1
import pytest
from pandas import (
DataFrame,
HDFStore,
_testing as tm,
)
from pandas.tests.io.pytables.common import (
ensure_clean_path,
Reported by Pylint.
Line: 17
Column: 1
pytestmark = pytest.mark.single
def test_keys(setup_path):
with ensure_clean_store(setup_path) as store:
store["a"] = tm.makeTimeSeries()
store["b"] = tm.makeStringSeries()
store["c"] = tm.makeDataFrame()
Reported by Pylint.
Line: 24
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
store["b"] = tm.makeStringSeries()
store["c"] = tm.makeDataFrame()
assert len(store) == 3
expected = {"/a", "/b", "/c"}
assert set(store.keys()) == expected
assert set(store) == expected
Reported by Bandit.
Line: 26
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert len(store) == 3
expected = {"/a", "/b", "/c"}
assert set(store.keys()) == expected
assert set(store) == expected
def test_non_pandas_keys(setup_path):
class Table1(tables.IsDescription):
Reported by Bandit.
Line: 27
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert len(store) == 3
expected = {"/a", "/b", "/c"}
assert set(store.keys()) == expected
assert set(store) == expected
def test_non_pandas_keys(setup_path):
class Table1(tables.IsDescription):
value1 = tables.Float32Col()
Reported by Bandit.
Line: 30
Column: 1
assert set(store) == expected
def test_non_pandas_keys(setup_path):
class Table1(tables.IsDescription):
value1 = tables.Float32Col()
class Table2(tables.IsDescription):
value2 = tables.Float32Col()
Reported by Pylint.
Line: 31
Column: 5
def test_non_pandas_keys(setup_path):
class Table1(tables.IsDescription):
value1 = tables.Float32Col()
class Table2(tables.IsDescription):
value2 = tables.Float32Col()
Reported by Pylint.
pandas/tests/indexes/timedeltas/methods/test_astype.py
25 issues
Line: 4
Column: 1
from datetime import timedelta
import numpy as np
import pytest
import pandas as pd
from pandas import (
Float64Index,
Index,
Reported by Pylint.
Line: 115
Column: 18
expected = pd.CategoricalIndex([Timedelta("1H"), Timedelta("2H")])
tm.assert_index_equal(result, expected)
result = obj._data.astype("category")
expected = expected.values
tm.assert_categorical_equal(result, expected)
def test_astype_array_fallback(self):
obj = timedelta_range("1H", periods=2)
Reported by Pylint.
Line: 125
Column: 18
expected = Index(np.array([True, True]))
tm.assert_index_equal(result, expected)
result = obj._data.astype(bool)
expected = np.array([True, True])
tm.assert_numpy_array_equal(result, expected)
Reported by Pylint.
Line: 1
Column: 1
from datetime import timedelta
import numpy as np
import pytest
import pandas as pd
from pandas import (
Float64Index,
Index,
Reported by Pylint.
Line: 19
Column: 1
import pandas._testing as tm
class TestTimedeltaIndex:
def test_astype_object(self):
idx = timedelta_range(start="1 days", periods=4, freq="D", name="idx")
expected_list = [
Timedelta("1 days"),
Timedelta("2 days"),
Reported by Pylint.
Line: 20
Column: 5
class TestTimedeltaIndex:
def test_astype_object(self):
idx = timedelta_range(start="1 days", periods=4, freq="D", name="idx")
expected_list = [
Timedelta("1 days"),
Timedelta("2 days"),
Timedelta("3 days"),
Reported by Pylint.
Line: 20
Column: 5
class TestTimedeltaIndex:
def test_astype_object(self):
idx = timedelta_range(start="1 days", periods=4, freq="D", name="idx")
expected_list = [
Timedelta("1 days"),
Timedelta("2 days"),
Timedelta("3 days"),
Reported by Pylint.
Line: 31
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
result = idx.astype(object)
expected = Index(expected_list, dtype=object, name="idx")
tm.assert_index_equal(result, expected)
assert idx.tolist() == expected_list
def test_astype_object_with_nat(self):
idx = TimedeltaIndex(
[timedelta(days=1), timedelta(days=2), NaT, timedelta(days=4)], name="idx"
)
Reported by Bandit.
Line: 33
Column: 5
tm.assert_index_equal(result, expected)
assert idx.tolist() == expected_list
def test_astype_object_with_nat(self):
idx = TimedeltaIndex(
[timedelta(days=1), timedelta(days=2), NaT, timedelta(days=4)], name="idx"
)
expected_list = [
Timedelta("1 days"),
Reported by Pylint.
Line: 33
Column: 5
tm.assert_index_equal(result, expected)
assert idx.tolist() == expected_list
def test_astype_object_with_nat(self):
idx = TimedeltaIndex(
[timedelta(days=1), timedelta(days=2), NaT, timedelta(days=4)], name="idx"
)
expected_list = [
Timedelta("1 days"),
Reported by Pylint.
pandas/tests/io/parser/usecols/test_usecols_basic.py
25 issues
Line: 8
Column: 1
from io import StringIO
import numpy as np
import pytest
from pandas import (
DataFrame,
Index,
)
Reported by Pylint.
Line: 16
Column: 1
)
import pandas._testing as tm
_msg_validate_usecols_arg = (
"'usecols' must either be list-like "
"of all strings, all unicode, all "
"integers or a callable."
)
_msg_validate_usecols_names = (
Reported by Pylint.
Line: 21
Column: 1
"of all strings, all unicode, all "
"integers or a callable."
)
_msg_validate_usecols_names = (
"Usecols do not match columns, columns expected but not found: {0}"
)
def test_raise_on_mixed_dtype_usecols(all_parsers):
Reported by Pylint.
Line: 26
Column: 1
)
def test_raise_on_mixed_dtype_usecols(all_parsers):
# See gh-12678
data = """a,b,c
1000,2000,3000
4000,5000,6000
"""
Reported by Pylint.
Line: 40
Column: 1
@pytest.mark.parametrize("usecols", [(1, 2), ("b", "c")])
def test_usecols(all_parsers, usecols):
data = """\
a,b,c
1,2,3
4,5,6
7,8,9
Reported by Pylint.
Line: 54
Column: 1
tm.assert_frame_equal(result, expected)
def test_usecols_with_names(all_parsers):
data = """\
a,b,c
1,2,3
4,5,6
7,8,9
Reported by Pylint.
Line: 71
Column: 1
@pytest.mark.parametrize(
"names,usecols", [(["b", "c"], [1, 2]), (["a", "b", "c"], ["b", "c"])]
)
def test_usecols_relative_to_names(all_parsers, names, usecols):
data = """\
1,2,3
4,5,6
7,8,9
Reported by Pylint.
Line: 85
Column: 1
tm.assert_frame_equal(result, expected)
def test_usecols_relative_to_names2(all_parsers):
# see gh-5766
data = """\
1,2,3
4,5,6
7,8,9
Reported by Pylint.
Line: 101
Column: 1
tm.assert_frame_equal(result, expected)
def test_usecols_name_length_conflict(all_parsers):
data = """\
1,2,3
4,5,6
7,8,9
10,11,12"""
Reported by Pylint.
Line: 114
Column: 1
parser.read_csv(StringIO(data), names=["a", "b"], header=None, usecols=[1])
def test_usecols_single_string(all_parsers):
# see gh-20558
parser = all_parsers
data = """foo, bar, baz
1000, 2000, 3000
4000, 5000, 6000"""
Reported by Pylint.
pandas/tests/strings/test_api.py
25 issues
Line: 1
Column: 1
import pytest
from pandas import (
DataFrame,
Index,
MultiIndex,
Series,
_testing as tm,
get_option,
Reported by Pylint.
Line: 26
Column: 9
mi = MultiIndex.from_arrays([["a", "b", "c"]])
msg = "Can only use .str accessor with Index, not MultiIndex"
with pytest.raises(AttributeError, match=msg):
mi.str
assert not hasattr(mi, "str")
@pytest.mark.parametrize("dtype", [object, "category"])
def test_api_per_dtype(index_or_series, dtype, any_skipna_inferred_dtype):
Reported by Pylint.
Line: 53
Column: 13
# GH 9184, GH 23011, GH 23163
msg = "Can only use .str accessor with string values.*"
with pytest.raises(AttributeError, match=msg):
t.str
assert not hasattr(t, "str")
@pytest.mark.parametrize("dtype", [object, "category"])
def test_api_per_method(
Reported by Pylint.
Line: 74
Column: 3
inferred_dtype, values = any_allowed_skipna_inferred_dtype
method_name, args, kwargs = any_string_method
# TODO: get rid of these xfails
reason = None
if box is Index and values.size == 0:
if method_name in ["partition", "rpartition"] and kwargs.get("expand", True):
raises = TypeError
reason = "Method cannot deal with empty Index"
Reported by Pylint.
Line: 1
Column: 1
import pytest
from pandas import (
DataFrame,
Index,
MultiIndex,
Series,
_testing as tm,
get_option,
Reported by Pylint.
Line: 11
Column: 1
_testing as tm,
get_option,
)
from pandas.core import strings as strings
def test_api(any_string_dtype):
# GH 6106, GH 9322
Reported by Pylint.
Line: 14
Column: 1
from pandas.core import strings as strings
def test_api(any_string_dtype):
# GH 6106, GH 9322
assert Series.str is strings.StringMethods
assert isinstance(Series([""], dtype=any_string_dtype).str, strings.StringMethods)
Reported by Pylint.
Line: 17
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def test_api(any_string_dtype):
# GH 6106, GH 9322
assert Series.str is strings.StringMethods
assert isinstance(Series([""], dtype=any_string_dtype).str, strings.StringMethods)
def test_api_mi_raises():
# GH 23679
Reported by Bandit.
Line: 18
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
# GH 6106, GH 9322
assert Series.str is strings.StringMethods
assert isinstance(Series([""], dtype=any_string_dtype).str, strings.StringMethods)
def test_api_mi_raises():
# GH 23679
mi = MultiIndex.from_arrays([["a", "b", "c"]])
Reported by Bandit.
Line: 21
Column: 1
assert isinstance(Series([""], dtype=any_string_dtype).str, strings.StringMethods)
def test_api_mi_raises():
# GH 23679
mi = MultiIndex.from_arrays([["a", "b", "c"]])
msg = "Can only use .str accessor with Index, not MultiIndex"
with pytest.raises(AttributeError, match=msg):
mi.str
Reported by Pylint.
pandas/tests/series/test_iteration.py
25 issues
Line: 1
Column: 1
class TestIteration:
def test_keys(self, datetime_series):
assert datetime_series.keys() is datetime_series.index
def test_iter_datetimes(self, datetime_series):
for i, val in enumerate(datetime_series):
assert val == datetime_series[i]
def test_iter_strings(self, string_series):
Reported by Pylint.
Line: 1
Column: 1
class TestIteration:
def test_keys(self, datetime_series):
assert datetime_series.keys() is datetime_series.index
def test_iter_datetimes(self, datetime_series):
for i, val in enumerate(datetime_series):
assert val == datetime_series[i]
def test_iter_strings(self, string_series):
Reported by Pylint.
Line: 2
Column: 5
class TestIteration:
def test_keys(self, datetime_series):
assert datetime_series.keys() is datetime_series.index
def test_iter_datetimes(self, datetime_series):
for i, val in enumerate(datetime_series):
assert val == datetime_series[i]
def test_iter_strings(self, string_series):
Reported by Pylint.
Line: 2
Column: 5
class TestIteration:
def test_keys(self, datetime_series):
assert datetime_series.keys() is datetime_series.index
def test_iter_datetimes(self, datetime_series):
for i, val in enumerate(datetime_series):
assert val == datetime_series[i]
def test_iter_strings(self, string_series):
Reported by Pylint.
Line: 3
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
class TestIteration:
def test_keys(self, datetime_series):
assert datetime_series.keys() is datetime_series.index
def test_iter_datetimes(self, datetime_series):
for i, val in enumerate(datetime_series):
assert val == datetime_series[i]
def test_iter_strings(self, string_series):
Reported by Bandit.
Line: 5
Column: 5
def test_keys(self, datetime_series):
assert datetime_series.keys() is datetime_series.index
def test_iter_datetimes(self, datetime_series):
for i, val in enumerate(datetime_series):
assert val == datetime_series[i]
def test_iter_strings(self, string_series):
for i, val in enumerate(string_series):
Reported by Pylint.
Line: 5
Column: 5
def test_keys(self, datetime_series):
assert datetime_series.keys() is datetime_series.index
def test_iter_datetimes(self, datetime_series):
for i, val in enumerate(datetime_series):
assert val == datetime_series[i]
def test_iter_strings(self, string_series):
for i, val in enumerate(string_series):
Reported by Pylint.
Line: 7
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def test_iter_datetimes(self, datetime_series):
for i, val in enumerate(datetime_series):
assert val == datetime_series[i]
def test_iter_strings(self, string_series):
for i, val in enumerate(string_series):
assert val == string_series[i]
Reported by Bandit.
Line: 9
Column: 5
for i, val in enumerate(datetime_series):
assert val == datetime_series[i]
def test_iter_strings(self, string_series):
for i, val in enumerate(string_series):
assert val == string_series[i]
def test_iteritems_datetimes(self, datetime_series):
for idx, val in datetime_series.iteritems():
Reported by Pylint.
Line: 9
Column: 5
for i, val in enumerate(datetime_series):
assert val == datetime_series[i]
def test_iter_strings(self, string_series):
for i, val in enumerate(string_series):
assert val == string_series[i]
def test_iteritems_datetimes(self, datetime_series):
for idx, val in datetime_series.iteritems():
Reported by Pylint.
pandas/tests/indexes/period/methods/test_to_timestamp.py
25 issues
Line: 4
Column: 1
from datetime import datetime
import numpy as np
import pytest
from pandas import (
DatetimeIndex,
NaT,
PeriodIndex,
Reported by Pylint.
Line: 65
Column: 31
stamps = pindex.to_timestamp("D", "end")
expected = DatetimeIndex([x.to_timestamp("D", "end") for x in pindex])
tm.assert_index_equal(stamps, expected)
assert stamps.freq == expected.freq
def test_to_timestamp_pi_mult(self):
idx = PeriodIndex(["2011-01", "NaT", "2011-02"], freq="2M", name="idx")
result = idx.to_timestamp()
Reported by Pylint.
Line: 1
Column: 1
from datetime import datetime
import numpy as np
import pytest
from pandas import (
DatetimeIndex,
NaT,
PeriodIndex,
Reported by Pylint.
Line: 18
Column: 1
import pandas._testing as tm
class TestToTimestamp:
def test_to_timestamp_freq(self):
idx = period_range("2017", periods=12, freq="A-DEC")
result = idx.to_timestamp()
expected = date_range("2017", periods=12, freq="AS-JAN")
tm.assert_index_equal(result, expected)
Reported by Pylint.
Line: 19
Column: 5
class TestToTimestamp:
def test_to_timestamp_freq(self):
idx = period_range("2017", periods=12, freq="A-DEC")
result = idx.to_timestamp()
expected = date_range("2017", periods=12, freq="AS-JAN")
tm.assert_index_equal(result, expected)
Reported by Pylint.
Line: 19
Column: 5
class TestToTimestamp:
def test_to_timestamp_freq(self):
idx = period_range("2017", periods=12, freq="A-DEC")
result = idx.to_timestamp()
expected = date_range("2017", periods=12, freq="AS-JAN")
tm.assert_index_equal(result, expected)
Reported by Pylint.
Line: 25
Column: 5
expected = date_range("2017", periods=12, freq="AS-JAN")
tm.assert_index_equal(result, expected)
def test_to_timestamp_pi_nat(self):
# GH#7228
index = PeriodIndex(["NaT", "2011-01", "2011-02"], freq="M", name="idx")
result = index.to_timestamp("D")
expected = DatetimeIndex(
Reported by Pylint.
Line: 25
Column: 5
expected = date_range("2017", periods=12, freq="AS-JAN")
tm.assert_index_equal(result, expected)
def test_to_timestamp_pi_nat(self):
# GH#7228
index = PeriodIndex(["NaT", "2011-01", "2011-02"], freq="M", name="idx")
result = index.to_timestamp("D")
expected = DatetimeIndex(
Reported by Pylint.
Line: 34
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
[NaT, datetime(2011, 1, 1), datetime(2011, 2, 1)], name="idx"
)
tm.assert_index_equal(result, expected)
assert result.name == "idx"
result2 = result.to_period(freq="M")
tm.assert_index_equal(result2, index)
assert result2.name == "idx"
Reported by Bandit.
Line: 38
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
result2 = result.to_period(freq="M")
tm.assert_index_equal(result2, index)
assert result2.name == "idx"
result3 = result.to_period(freq="3M")
exp = PeriodIndex(["NaT", "2011-01", "2011-02"], freq="3M", name="idx")
tm.assert_index_equal(result3, exp)
assert result3.freqstr == "3M"
Reported by Bandit.