The following issues were found
asv_bench/benchmarks/ctors.py
40 issues
Line: 3
Column: 1
import numpy as np
from pandas import (
DatetimeIndex,
Index,
MultiIndex,
Series,
Timestamp,
)
Reported by Pylint.
Line: 11
Column: 1
Timestamp,
)
from .pandas_vb_common import tm
def no_change(arr):
return arr
Reported by Pylint.
Line: 124
Column: 1
MultiIndex.from_product(self.iterables)
from .pandas_vb_common import setup # noqa: F401 isort:skip
Reported by Pylint.
Line: 84
Column: 9
arr = np.random.randn(N)
else:
arr = np.arange(N)
self.data = data_fmt(arr)
self.index = np.arange(N) if with_index else None
def time_series_constructor(self, data_fmt, with_index, dtype):
Series(self.data, index=self.index)
Reported by Pylint.
Line: 85
Column: 9
else:
arr = np.arange(N)
self.data = data_fmt(arr)
self.index = np.arange(N) if with_index else None
def time_series_constructor(self, data_fmt, with_index, dtype):
Series(self.data, index=self.index)
Reported by Pylint.
Line: 87
Column: 39
self.data = data_fmt(arr)
self.index = np.arange(N) if with_index else None
def time_series_constructor(self, data_fmt, with_index, dtype):
Series(self.data, index=self.index)
class SeriesDtypesConstructors:
def setup(self):
Reported by Pylint.
Line: 87
Column: 61
self.data = data_fmt(arr)
self.index = np.arange(N) if with_index else None
def time_series_constructor(self, data_fmt, with_index, dtype):
Series(self.data, index=self.index)
class SeriesDtypesConstructors:
def setup(self):
Reported by Pylint.
Line: 87
Column: 49
self.data = data_fmt(arr)
self.index = np.arange(N) if with_index else None
def time_series_constructor(self, data_fmt, with_index, dtype):
Series(self.data, index=self.index)
class SeriesDtypesConstructors:
def setup(self):
Reported by Pylint.
Line: 94
Column: 9
class SeriesDtypesConstructors:
def setup(self):
N = 10 ** 4
self.arr = np.random.randn(N)
self.arr_str = np.array(["foo", "bar", "baz"], dtype=object)
self.s = Series(
[Timestamp("20110101"), Timestamp("20120101"), Timestamp("20130101")]
* N
* 10
Reported by Pylint.
Line: 95
Column: 9
def setup(self):
N = 10 ** 4
self.arr = np.random.randn(N)
self.arr_str = np.array(["foo", "bar", "baz"], dtype=object)
self.s = Series(
[Timestamp("20110101"), Timestamp("20120101"), Timestamp("20130101")]
* N
* 10
)
Reported by Pylint.
pandas/tests/indexes/interval/test_astype.py
39 issues
Line: 4
Column: 1
import re
import numpy as np
import pytest
from pandas.compat import is_platform_arm
from pandas.core.dtypes.dtypes import (
CategoricalDtype,
Reported by Pylint.
Line: 1
Column: 1
import re
import numpy as np
import pytest
from pandas.compat import is_platform_arm
from pandas.core.dtypes.dtypes import (
CategoricalDtype,
Reported by Pylint.
Line: 28
Column: 5
class AstypeTests:
"""Tests common to IntervalIndex with any subtype"""
def test_astype_idempotent(self, index):
result = index.astype("interval")
tm.assert_index_equal(result, index)
result = index.astype(index.dtype)
tm.assert_index_equal(result, index)
Reported by Pylint.
Line: 28
Column: 5
class AstypeTests:
"""Tests common to IntervalIndex with any subtype"""
def test_astype_idempotent(self, index):
result = index.astype("interval")
tm.assert_index_equal(result, index)
result = index.astype(index.dtype)
tm.assert_index_equal(result, index)
Reported by Pylint.
Line: 35
Column: 5
result = index.astype(index.dtype)
tm.assert_index_equal(result, index)
def test_astype_object(self, index):
result = index.astype(object)
expected = Index(index.values, dtype="object")
tm.assert_index_equal(result, expected)
assert not result.equals(index)
Reported by Pylint.
Line: 35
Column: 5
result = index.astype(index.dtype)
tm.assert_index_equal(result, index)
def test_astype_object(self, index):
result = index.astype(object)
expected = Index(index.values, dtype="object")
tm.assert_index_equal(result, expected)
assert not result.equals(index)
Reported by Pylint.
Line: 39
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
result = index.astype(object)
expected = Index(index.values, dtype="object")
tm.assert_index_equal(result, expected)
assert not result.equals(index)
def test_astype_category(self, index):
result = index.astype("category")
expected = CategoricalIndex(index.values)
tm.assert_index_equal(result, expected)
Reported by Bandit.
Line: 41
Column: 5
tm.assert_index_equal(result, expected)
assert not result.equals(index)
def test_astype_category(self, index):
result = index.astype("category")
expected = CategoricalIndex(index.values)
tm.assert_index_equal(result, expected)
result = index.astype(CategoricalDtype())
Reported by Pylint.
Line: 41
Column: 5
tm.assert_index_equal(result, expected)
assert not result.equals(index)
def test_astype_category(self, index):
result = index.astype("category")
expected = CategoricalIndex(index.values)
tm.assert_index_equal(result, expected)
result = index.astype(CategoricalDtype())
Reported by Pylint.
Line: 69
Column: 5
"datetime64",
"datetime64[ns]",
"datetime64[ns, US/Eastern]",
],
)
def test_astype_cannot_cast(self, index, dtype):
msg = "Cannot cast IntervalIndex to dtype"
with pytest.raises(TypeError, match=msg):
index.astype(dtype)
Reported by Pylint.
pandas/tests/internals/test_managers.py
39 issues
Line: 20
Column: 23
with pd.option_context("mode.data_manager", "block"):
df_block = pd.DataFrame({"a": [1, 2, 3], "b": [0.1, 0.2, 0.3], "c": [4, 5, 6]})
assert isinstance(df_block._mgr, BlockManager)
with pd.option_context("mode.data_manager", "array"):
df_array = pd.DataFrame({"a": [1, 2, 3], "b": [0.1, 0.2, 0.3], "c": [4, 5, 6]})
assert isinstance(df_array._mgr, ArrayManager)
Reported by Pylint.
Line: 24
Column: 23
with pd.option_context("mode.data_manager", "array"):
df_array = pd.DataFrame({"a": [1, 2, 3], "b": [0.1, 0.2, 0.3], "c": [4, 5, 6]})
assert isinstance(df_array._mgr, ArrayManager)
# also ensure both are seen as equal
tm.assert_frame_equal(df_block, df_array)
# conversion from one manager to the other
Reported by Pylint.
Line: 30
Column: 14
tm.assert_frame_equal(df_block, df_array)
# conversion from one manager to the other
result = df_block._as_manager("block")
assert isinstance(result._mgr, BlockManager)
result = df_block._as_manager("array")
assert isinstance(result._mgr, ArrayManager)
tm.assert_frame_equal(result, df_block)
assert all(
Reported by Pylint.
Line: 31
Column: 23
# conversion from one manager to the other
result = df_block._as_manager("block")
assert isinstance(result._mgr, BlockManager)
result = df_block._as_manager("array")
assert isinstance(result._mgr, ArrayManager)
tm.assert_frame_equal(result, df_block)
assert all(
array_equivalent(left, right)
Reported by Pylint.
Line: 32
Column: 14
# conversion from one manager to the other
result = df_block._as_manager("block")
assert isinstance(result._mgr, BlockManager)
result = df_block._as_manager("array")
assert isinstance(result._mgr, ArrayManager)
tm.assert_frame_equal(result, df_block)
assert all(
array_equivalent(left, right)
for left, right in zip(result._mgr.arrays, df_array._mgr.arrays)
Reported by Pylint.
Line: 33
Column: 23
result = df_block._as_manager("block")
assert isinstance(result._mgr, BlockManager)
result = df_block._as_manager("array")
assert isinstance(result._mgr, ArrayManager)
tm.assert_frame_equal(result, df_block)
assert all(
array_equivalent(left, right)
for left, right in zip(result._mgr.arrays, df_array._mgr.arrays)
)
Reported by Pylint.
Line: 37
Column: 32
tm.assert_frame_equal(result, df_block)
assert all(
array_equivalent(left, right)
for left, right in zip(result._mgr.arrays, df_array._mgr.arrays)
)
result = df_array._as_manager("array")
assert isinstance(result._mgr, ArrayManager)
result = df_array._as_manager("block")
Reported by Pylint.
Line: 37
Column: 52
tm.assert_frame_equal(result, df_block)
assert all(
array_equivalent(left, right)
for left, right in zip(result._mgr.arrays, df_array._mgr.arrays)
)
result = df_array._as_manager("array")
assert isinstance(result._mgr, ArrayManager)
result = df_array._as_manager("block")
Reported by Pylint.
Line: 40
Column: 14
for left, right in zip(result._mgr.arrays, df_array._mgr.arrays)
)
result = df_array._as_manager("array")
assert isinstance(result._mgr, ArrayManager)
result = df_array._as_manager("block")
assert isinstance(result._mgr, BlockManager)
tm.assert_frame_equal(result, df_array)
assert len(result._mgr.blocks) == 2
Reported by Pylint.
Line: 41
Column: 23
)
result = df_array._as_manager("array")
assert isinstance(result._mgr, ArrayManager)
result = df_array._as_manager("block")
assert isinstance(result._mgr, BlockManager)
tm.assert_frame_equal(result, df_array)
assert len(result._mgr.blocks) == 2
Reported by Pylint.
pandas/tests/io/parser/test_read_fwf.py
39 issues
Line: 15
Column: 1
from pathlib import Path
import numpy as np
import pytest
from pandas.errors import EmptyDataError
from pandas import (
DataFrame,
Reported by Pylint.
Line: 31
Column: 1
)
def test_basic():
data = """\
A B C D
201158 360.242940 149.910199 11950.7
201159 444.953632 166.985655 11788.4
201160 364.136849 183.628767 11806.2
Reported by Pylint.
Line: 54
Column: 1
tm.assert_frame_equal(result, expected)
def test_colspecs():
data = """\
A B C D E
201158 360.242940 149.910199 11950.7
201159 444.953632 166.985655 11788.4
201160 364.136849 183.628767 11806.2
Reported by Pylint.
Line: 79
Column: 1
tm.assert_frame_equal(result, expected)
def test_widths():
data = """\
A B C D E
2011 58 360.242940 149.910199 11950.7
2011 59 444.953632 166.985655 11788.4
2011 60 364.136849 183.628767 11806.2
Reported by Pylint.
Line: 103
Column: 1
tm.assert_frame_equal(result, expected)
def test_non_space_filler():
# From Thomas Kluyver:
#
# Apparently, some non-space filler characters can be seen, this is
# supported by specifying the 'delimiter' character:
#
Reported by Pylint.
Line: 134
Column: 1
tm.assert_frame_equal(result, expected)
def test_over_specified():
data = """\
A B C D E
201158 360.242940 149.910199 11950.7
201159 444.953632 166.985655 11788.4
201160 364.136849 183.628767 11806.2
Reported by Pylint.
Line: 149
Column: 1
read_fwf(StringIO(data), colspecs=colspecs, widths=[6, 10, 10, 7])
def test_under_specified():
data = """\
A B C D E
201158 360.242940 149.910199 11950.7
201159 444.953632 166.985655 11788.4
201160 364.136849 183.628767 11806.2
Reported by Pylint.
Line: 162
Column: 1
read_fwf(StringIO(data), colspecs=None, widths=None)
def test_read_csv_compat():
csv_data = """\
A,B,C,D,E
2011,58,360.242940,149.910199,11950.7
2011,59,444.953632,166.985655,11788.4
2011,60,364.136849,183.628767,11806.2
Reported by Pylint.
Line: 186
Column: 1
tm.assert_frame_equal(result, expected)
def test_bytes_io_input():
result = read_fwf(BytesIO("שלום\nשלום".encode()), widths=[2, 2], encoding="utf8")
expected = DataFrame([["של", "ום"]], columns=["של", "ום"])
tm.assert_frame_equal(result, expected)
Reported by Pylint.
Line: 192
Column: 1
tm.assert_frame_equal(result, expected)
def test_fwf_colspecs_is_list_or_tuple():
data = """index,A,B,C,D
foo,2,3,4,5
bar,7,8,9,10
baz,12,13,14,15
qux,12,13,14,15
Reported by Pylint.
pandas/tests/indexes/datetimes/test_delete.py
39 issues
Line: 1
Column: 1
import pytest
from pandas import (
DatetimeIndex,
Series,
date_range,
)
import pandas._testing as tm
Reported by Pylint.
Line: 55
Column: 33
tm.assert_index_equal(result, expected)
assert result.name == expected.name
assert result.freqstr == "H"
assert result.tz == expected.tz
expected = date_range(
start="2000-01-01 09:00", periods=9, freq="H", name="idx", tz=tz
)
result = idx.delete(-1)
Reported by Pylint.
Line: 55
Column: 33
tm.assert_index_equal(result, expected)
assert result.name == expected.name
assert result.freqstr == "H"
assert result.tz == expected.tz
expected = date_range(
start="2000-01-01 09:00", periods=9, freq="H", name="idx", tz=tz
)
result = idx.delete(-1)
Reported by Pylint.
Line: 64
Column: 33
tm.assert_index_equal(result, expected)
assert result.name == expected.name
assert result.freqstr == "H"
assert result.tz == expected.tz
def test_delete_slice(self):
idx = date_range(start="2000-01-01", periods=10, freq="D", name="idx")
# preserve freq
Reported by Pylint.
Line: 64
Column: 33
tm.assert_index_equal(result, expected)
assert result.name == expected.name
assert result.freqstr == "H"
assert result.tz == expected.tz
def test_delete_slice(self):
idx = date_range(start="2000-01-01", periods=10, freq="D", name="idx")
# preserve freq
Reported by Pylint.
Line: 118
Column: 35
)
tm.assert_index_equal(result, expected)
assert result.name == expected.name
assert result.freq == expected.freq
assert result.tz == expected.tz
# reset freq to None
result = ts.drop(ts.index[[1, 3, 5, 7, 9]]).index
expected = DatetimeIndex(
Reported by Pylint.
Line: 118
Column: 35
)
tm.assert_index_equal(result, expected)
assert result.name == expected.name
assert result.freq == expected.freq
assert result.tz == expected.tz
# reset freq to None
result = ts.drop(ts.index[[1, 3, 5, 7, 9]]).index
expected = DatetimeIndex(
Reported by Pylint.
Line: 119
Column: 33
tm.assert_index_equal(result, expected)
assert result.name == expected.name
assert result.freq == expected.freq
assert result.tz == expected.tz
# reset freq to None
result = ts.drop(ts.index[[1, 3, 5, 7, 9]]).index
expected = DatetimeIndex(
[
Reported by Pylint.
Line: 119
Column: 33
tm.assert_index_equal(result, expected)
assert result.name == expected.name
assert result.freq == expected.freq
assert result.tz == expected.tz
# reset freq to None
result = ts.drop(ts.index[[1, 3, 5, 7, 9]]).index
expected = DatetimeIndex(
[
Reported by Pylint.
Line: 137
Column: 35
)
tm.assert_index_equal(result, expected)
assert result.name == expected.name
assert result.freq == expected.freq
assert result.tz == expected.tz
Reported by Pylint.
pandas/tests/series/methods/test_sort_values.py
39 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas import (
Categorical,
DataFrame,
Series,
)
import pandas._testing as tm
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas import (
Categorical,
DataFrame,
Series,
)
import pandas._testing as tm
Reported by Pylint.
Line: 12
Column: 1
import pandas._testing as tm
class TestSeriesSortValues:
def test_sort_values(self, datetime_series):
# check indexes are reordered corresponding with the values
ser = Series([3, 2, 4, 1], ["A", "B", "C", "D"])
expected = Series([1, 2, 3, 4], ["D", "B", "A", "C"])
Reported by Pylint.
Line: 13
Column: 5
class TestSeriesSortValues:
def test_sort_values(self, datetime_series):
# check indexes are reordered corresponding with the values
ser = Series([3, 2, 4, 1], ["A", "B", "C", "D"])
expected = Series([1, 2, 3, 4], ["D", "B", "A", "C"])
result = ser.sort_values()
Reported by Pylint.
Line: 13
Column: 5
class TestSeriesSortValues:
def test_sort_values(self, datetime_series):
# check indexes are reordered corresponding with the values
ser = Series([3, 2, 4, 1], ["A", "B", "C", "D"])
expected = Series([1, 2, 3, 4], ["D", "B", "A", "C"])
result = ser.sort_values()
Reported by Pylint.
Line: 13
Column: 5
class TestSeriesSortValues:
def test_sort_values(self, datetime_series):
# check indexes are reordered corresponding with the values
ser = Series([3, 2, 4, 1], ["A", "B", "C", "D"])
expected = Series([1, 2, 3, 4], ["D", "B", "A", "C"])
result = ser.sort_values()
Reported by Pylint.
Line: 21
Column: 9
result = ser.sort_values()
tm.assert_series_equal(expected, result)
ts = datetime_series.copy()
ts[:5] = np.NaN
vals = ts.values
result = ts.sort_values()
assert np.isnan(result[-5:]).all()
Reported by Pylint.
Line: 26
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
vals = ts.values
result = ts.sort_values()
assert np.isnan(result[-5:]).all()
tm.assert_numpy_array_equal(result[:-5].values, np.sort(vals[5:]))
# na_position
result = ts.sort_values(na_position="first")
assert np.isnan(result[:5]).all()
Reported by Bandit.
Line: 31
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
# na_position
result = ts.sort_values(na_position="first")
assert np.isnan(result[:5]).all()
tm.assert_numpy_array_equal(result[5:].values, np.sort(vals[5:]))
# something object-type
ser = Series(["A", "B"], [1, 2])
# no failure
Reported by Bandit.
Line: 71
Column: 9
ts.sort_values(ascending="foobar")
# inplace=True
ts = datetime_series.copy()
return_value = ts.sort_values(ascending=False, inplace=True)
assert return_value is None
tm.assert_series_equal(ts, datetime_series.sort_values(ascending=False))
tm.assert_index_equal(
ts.index, datetime_series.sort_values(ascending=False).index
Reported by Pylint.
pandas/core/ops/array_ops.py
39 issues
Line: 12
Column: 1
import numpy as np
from pandas._libs import (
NaT,
Timedelta,
Timestamp,
lib,
ops as libops,
Reported by Pylint.
Line: 12
Column: 1
import numpy as np
from pandas._libs import (
NaT,
Timedelta,
Timestamp,
lib,
ops as libops,
Reported by Pylint.
Line: 67
Column: 17
y = y.astype(np.object_)
if isinstance(y, (ABCSeries, ABCIndex)):
y = y._values
if x.shape != y.shape:
raise ValueError("Shapes must match", x.shape, y.shape)
result = libops.vec_compare(x.ravel(), y.ravel(), op)
else:
Reported by Pylint.
Line: 220
Column: 3
# because numexpr will fail on it, see GH#31457
res_values = op(left, right)
else:
# TODO we should handle EAs consistently and move this check before the if/else
# (https://github.com/pandas-dev/pandas/issues/41165)
_bool_arith_check(op, left, right)
res_values = _na_arithmetic_op(left, right, op)
Reported by Pylint.
Line: 253
Column: 3
rvalues = lib.item_from_zerodim(rvalues)
if isinstance(rvalues, list):
# TODO: same for tuples?
rvalues = np.asarray(rvalues)
if isinstance(rvalues, (np.ndarray, ABCExtensionArray)):
# TODO: make this treatment consistent across ops and classes.
# We are not catching all listlikes here (e.g. frozenset, tuple)
Reported by Pylint.
Line: 257
Column: 3
rvalues = np.asarray(rvalues)
if isinstance(rvalues, (np.ndarray, ABCExtensionArray)):
# TODO: make this treatment consistent across ops and classes.
# We are not catching all listlikes here (e.g. frozenset, tuple)
# The ambiguous case is object-dtype. See GH#27803
if len(lvalues) != len(rvalues):
raise ValueError(
"Lengths must match to compare", lvalues.shape, rvalues.shape
Reported by Pylint.
Line: 414
Column: 3
"""
if isinstance(op, partial):
# We get here via dispatch_to_series in DataFrame case
# TODO: avoid getting here
return op
op_name = op.__name__.strip("_").lstrip("r")
if op_name == "arith_op":
# Reached via DataFrame._combine_frame
Reported by Pylint.
Line: 58
Column: 1
from pandas.core.ops.invalid import invalid_comparison
def comp_method_OBJECT_ARRAY(op, x, y):
if isinstance(y, list):
y = construct_1d_object_array_from_listlike(y)
if isinstance(y, (np.ndarray, ABCSeries, ABCIndex)):
if not is_object_dtype(y.dtype):
Reported by Pylint.
Line: 58
Column: 1
from pandas.core.ops.invalid import invalid_comparison
def comp_method_OBJECT_ARRAY(op, x, y):
if isinstance(y, list):
y = construct_1d_object_array_from_listlike(y)
if isinstance(y, (np.ndarray, ABCSeries, ABCIndex)):
if not is_object_dtype(y.dtype):
Reported by Pylint.
Line: 58
Column: 1
from pandas.core.ops.invalid import invalid_comparison
def comp_method_OBJECT_ARRAY(op, x, y):
if isinstance(y, list):
y = construct_1d_object_array_from_listlike(y)
if isinstance(y, (np.ndarray, ABCSeries, ABCIndex)):
if not is_object_dtype(y.dtype):
Reported by Pylint.
pandas/tests/series/methods/test_to_csv.py
39 issues
Line: 5
Column: 1
from io import StringIO
import numpy as np
import pytest
import pandas as pd
from pandas import Series
import pandas._testing as tm
Reported by Pylint.
Line: 29
Column: 33
def test_from_csv(self, datetime_series, string_series):
# freq doesn't round-trip
datetime_series.index = datetime_series.index._with_freq(None)
with tm.ensure_clean() as path:
datetime_series.to_csv(path, header=False)
ts = self.read_csv(path)
tm.assert_series_equal(datetime_series, ts, check_names=False)
Reported by Pylint.
Line: 1
Column: 1
from datetime import datetime
from io import StringIO
import numpy as np
import pytest
import pandas as pd
from pandas import Series
import pandas._testing as tm
Reported by Pylint.
Line: 14
Column: 1
from pandas.io.common import get_handle
class TestSeriesToCSV:
def read_csv(self, path, **kwargs):
params = {"squeeze": True, "index_col": 0, "header": None, "parse_dates": True}
params.update(**kwargs)
header = params.get("header")
Reported by Pylint.
Line: 15
Column: 5
class TestSeriesToCSV:
def read_csv(self, path, **kwargs):
params = {"squeeze": True, "index_col": 0, "header": None, "parse_dates": True}
params.update(**kwargs)
header = params.get("header")
out = pd.read_csv(path, **params)
Reported by Pylint.
Line: 15
Column: 5
class TestSeriesToCSV:
def read_csv(self, path, **kwargs):
params = {"squeeze": True, "index_col": 0, "header": None, "parse_dates": True}
params.update(**kwargs)
header = params.get("header")
out = pd.read_csv(path, **params)
Reported by Pylint.
Line: 27
Column: 5
return out
def test_from_csv(self, datetime_series, string_series):
# freq doesn't round-trip
datetime_series.index = datetime_series.index._with_freq(None)
with tm.ensure_clean() as path:
datetime_series.to_csv(path, header=False)
Reported by Pylint.
Line: 33
Column: 13
with tm.ensure_clean() as path:
datetime_series.to_csv(path, header=False)
ts = self.read_csv(path)
tm.assert_series_equal(datetime_series, ts, check_names=False)
assert ts.name is None
assert ts.index.name is None
Reported by Pylint.
Line: 36
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
ts = self.read_csv(path)
tm.assert_series_equal(datetime_series, ts, check_names=False)
assert ts.name is None
assert ts.index.name is None
# see gh-10483
datetime_series.to_csv(path, header=True)
ts_h = self.read_csv(path, header=0)
Reported by Bandit.
Line: 37
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
tm.assert_series_equal(datetime_series, ts, check_names=False)
assert ts.name is None
assert ts.index.name is None
# see gh-10483
datetime_series.to_csv(path, header=True)
ts_h = self.read_csv(path, header=0)
assert ts_h.name == "ts"
Reported by Bandit.
pandas/tests/plotting/test_backend.py
39 issues
Line: 5
Column: 1
import types
import pkg_resources
import pytest
import pandas.util._test_decorators as td
import pandas
Reported by Pylint.
Line: 65
Column: 36
backends = pkg_resources.get_entry_map("pandas")
my_entrypoint = pkg_resources.EntryPoint(
"pandas_plotting_backend", mod.__name__, dist=dist
)
backends["pandas_plotting_backends"]["my_backend"] = my_entrypoint
# TODO: the docs recommend importlib.util.module_from_spec. But this works for now.
sys.modules["my_backend"] = mod
Reported by Pylint.
Line: 34
Column: 42
assert pandas.options.plotting.backend == "matplotlib"
def test_backend_is_correct(monkeypatch, restore_backend):
monkeypatch.setitem(sys.modules, "pandas_dummy_backend", dummy_backend)
pandas.set_option("plotting.backend", "pandas_dummy_backend")
assert pandas.get_option("plotting.backend") == "pandas_dummy_backend"
assert (
Reported by Pylint.
Line: 34
Column: 42
assert pandas.options.plotting.backend == "matplotlib"
def test_backend_is_correct(monkeypatch, restore_backend):
monkeypatch.setitem(sys.modules, "pandas_dummy_backend", dummy_backend)
pandas.set_option("plotting.backend", "pandas_dummy_backend")
assert pandas.get_option("plotting.backend") == "pandas_dummy_backend"
assert (
Reported by Pylint.
Line: 40
Column: 9
pandas.set_option("plotting.backend", "pandas_dummy_backend")
assert pandas.get_option("plotting.backend") == "pandas_dummy_backend"
assert (
pandas.plotting._core._get_plot_backend("pandas_dummy_backend") is dummy_backend
)
def test_backend_can_be_set_in_plot_call(monkeypatch, restore_backend):
monkeypatch.setitem(sys.modules, "pandas_dummy_backend", dummy_backend)
Reported by Pylint.
Line: 40
Column: 9
pandas.set_option("plotting.backend", "pandas_dummy_backend")
assert pandas.get_option("plotting.backend") == "pandas_dummy_backend"
assert (
pandas.plotting._core._get_plot_backend("pandas_dummy_backend") is dummy_backend
)
def test_backend_can_be_set_in_plot_call(monkeypatch, restore_backend):
monkeypatch.setitem(sys.modules, "pandas_dummy_backend", dummy_backend)
Reported by Pylint.
Line: 44
Column: 55
)
def test_backend_can_be_set_in_plot_call(monkeypatch, restore_backend):
monkeypatch.setitem(sys.modules, "pandas_dummy_backend", dummy_backend)
df = pandas.DataFrame([1, 2, 3])
assert pandas.get_option("plotting.backend") == "matplotlib"
assert df.plot(backend="pandas_dummy_backend") == "used_dummy"
Reported by Pylint.
Line: 44
Column: 55
)
def test_backend_can_be_set_in_plot_call(monkeypatch, restore_backend):
monkeypatch.setitem(sys.modules, "pandas_dummy_backend", dummy_backend)
df = pandas.DataFrame([1, 2, 3])
assert pandas.get_option("plotting.backend") == "matplotlib"
assert df.plot(backend="pandas_dummy_backend") == "used_dummy"
Reported by Pylint.
Line: 53
Column: 30
@td.skip_if_no_mpl
def test_register_entrypoint(restore_backend):
dist = pkg_resources.get_distribution("pandas")
if dist.module_path not in pandas.__file__:
# We are running from a non-installed pandas, and this test is invalid
pytest.skip("Testing a non-installed pandas")
Reported by Pylint.
Line: 53
Column: 30
@td.skip_if_no_mpl
def test_register_entrypoint(restore_backend):
dist = pkg_resources.get_distribution("pandas")
if dist.module_path not in pandas.__file__:
# We are running from a non-installed pandas, and this test is invalid
pytest.skip("Testing a non-installed pandas")
Reported by Pylint.
pandas/tests/indexing/common.py
39 issues
Line: 44
Column: 28
"multi",
}
def setup_method(self, method):
self.series_ints = Series(np.random.rand(4), index=np.arange(0, 8, 2))
self.frame_ints = DataFrame(
np.random.randn(4, 4), index=np.arange(0, 8, 2), columns=np.arange(0, 12, 3)
)
Reported by Pylint.
Line: 46
Column: 9
def setup_method(self, method):
self.series_ints = Series(np.random.rand(4), index=np.arange(0, 8, 2))
self.frame_ints = DataFrame(
np.random.randn(4, 4), index=np.arange(0, 8, 2), columns=np.arange(0, 12, 3)
)
self.series_uints = Series(
Reported by Pylint.
Line: 47
Column: 9
def setup_method(self, method):
self.series_ints = Series(np.random.rand(4), index=np.arange(0, 8, 2))
self.frame_ints = DataFrame(
np.random.randn(4, 4), index=np.arange(0, 8, 2), columns=np.arange(0, 12, 3)
)
self.series_uints = Series(
np.random.rand(4), index=UInt64Index(np.arange(0, 8, 2))
Reported by Pylint.
Line: 51
Column: 9
np.random.randn(4, 4), index=np.arange(0, 8, 2), columns=np.arange(0, 12, 3)
)
self.series_uints = Series(
np.random.rand(4), index=UInt64Index(np.arange(0, 8, 2))
)
self.frame_uints = DataFrame(
np.random.randn(4, 4),
index=UInt64Index(range(0, 8, 2)),
Reported by Pylint.
Line: 54
Column: 9
self.series_uints = Series(
np.random.rand(4), index=UInt64Index(np.arange(0, 8, 2))
)
self.frame_uints = DataFrame(
np.random.randn(4, 4),
index=UInt64Index(range(0, 8, 2)),
columns=UInt64Index(range(0, 12, 3)),
)
Reported by Pylint.
Line: 60
Column: 9
columns=UInt64Index(range(0, 12, 3)),
)
self.series_floats = Series(
np.random.rand(4), index=Float64Index(range(0, 8, 2))
)
self.frame_floats = DataFrame(
np.random.randn(4, 4),
index=Float64Index(range(0, 8, 2)),
Reported by Pylint.
Line: 63
Column: 9
self.series_floats = Series(
np.random.rand(4), index=Float64Index(range(0, 8, 2))
)
self.frame_floats = DataFrame(
np.random.randn(4, 4),
index=Float64Index(range(0, 8, 2)),
columns=Float64Index(range(0, 12, 3)),
)
Reported by Pylint.
Line: 75
Column: 9
MultiIndex.from_product([[9, 10], [11, 12]]),
]
self.series_multi = Series(np.random.rand(4), index=m_idces[0])
self.frame_multi = DataFrame(
np.random.randn(4, 4), index=m_idces[0], columns=m_idces[1]
)
self.series_labels = Series(np.random.randn(4), index=list("abcd"))
Reported by Pylint.
Line: 76
Column: 9
]
self.series_multi = Series(np.random.rand(4), index=m_idces[0])
self.frame_multi = DataFrame(
np.random.randn(4, 4), index=m_idces[0], columns=m_idces[1]
)
self.series_labels = Series(np.random.randn(4), index=list("abcd"))
self.frame_labels = DataFrame(
Reported by Pylint.
Line: 80
Column: 9
np.random.randn(4, 4), index=m_idces[0], columns=m_idces[1]
)
self.series_labels = Series(np.random.randn(4), index=list("abcd"))
self.frame_labels = DataFrame(
np.random.randn(4, 4), index=list("abcd"), columns=list("ABCD")
)
self.series_mixed = Series(np.random.randn(4), index=[2, 4, "null", 8])
Reported by Pylint.