The following issues were found
pandas/tests/indexes/categorical/test_equals.py
59 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas import (
Categorical,
CategoricalIndex,
Index,
MultiIndex,
)
Reported by Pylint.
Line: 35
Column: 13
# invalid comparisons
with pytest.raises(ValueError, match="Lengths must match"):
ci1 == Index(["a", "b", "c"])
msg = "Categoricals can only be compared if 'categories' are the same"
with pytest.raises(TypeError, match=msg):
ci1 == ci2
with pytest.raises(TypeError, match=msg):
Reported by Pylint.
Line: 39
Column: 13
msg = "Categoricals can only be compared if 'categories' are the same"
with pytest.raises(TypeError, match=msg):
ci1 == ci2
with pytest.raises(TypeError, match=msg):
ci1 == Categorical(ci1.values, ordered=False)
with pytest.raises(TypeError, match=msg):
ci1 == Categorical(ci1.values, categories=list("abc"))
Reported by Pylint.
Line: 41
Column: 13
with pytest.raises(TypeError, match=msg):
ci1 == ci2
with pytest.raises(TypeError, match=msg):
ci1 == Categorical(ci1.values, ordered=False)
with pytest.raises(TypeError, match=msg):
ci1 == Categorical(ci1.values, categories=list("abc"))
# tests
# make sure that we are testing for category inclusion properly
Reported by Pylint.
Line: 43
Column: 13
with pytest.raises(TypeError, match=msg):
ci1 == Categorical(ci1.values, ordered=False)
with pytest.raises(TypeError, match=msg):
ci1 == Categorical(ci1.values, categories=list("abc"))
# tests
# make sure that we are testing for category inclusion properly
ci = CategoricalIndex(list("aabca"), categories=["c", "a", "b"])
assert not ci.equals(list("aabca"))
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas import (
Categorical,
CategoricalIndex,
Index,
MultiIndex,
)
Reported by Pylint.
Line: 12
Column: 1
)
class TestEquals:
def test_equals_categorical(self):
ci1 = CategoricalIndex(["a", "b"], categories=["a", "b"], ordered=True)
ci2 = CategoricalIndex(["a", "b"], categories=["a", "b", "c"], ordered=True)
assert ci1.equals(ci1)
Reported by Pylint.
Line: 13
Column: 5
class TestEquals:
def test_equals_categorical(self):
ci1 = CategoricalIndex(["a", "b"], categories=["a", "b"], ordered=True)
ci2 = CategoricalIndex(["a", "b"], categories=["a", "b", "c"], ordered=True)
assert ci1.equals(ci1)
assert not ci1.equals(ci2)
Reported by Pylint.
Line: 13
Column: 5
class TestEquals:
def test_equals_categorical(self):
ci1 = CategoricalIndex(["a", "b"], categories=["a", "b"], ordered=True)
ci2 = CategoricalIndex(["a", "b"], categories=["a", "b", "c"], ordered=True)
assert ci1.equals(ci1)
assert not ci1.equals(ci2)
Reported by Pylint.
Line: 17
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
ci1 = CategoricalIndex(["a", "b"], categories=["a", "b"], ordered=True)
ci2 = CategoricalIndex(["a", "b"], categories=["a", "b", "c"], ordered=True)
assert ci1.equals(ci1)
assert not ci1.equals(ci2)
assert ci1.equals(ci1.astype(object))
assert ci1.astype(object).equals(ci1)
assert (ci1 == ci1).all()
Reported by Bandit.
pandas/tests/series/methods/test_reset_index.py
59 issues
Line: 4
Column: 1
from datetime import datetime
import numpy as np
import pytest
import pandas as pd
from pandas import (
DataFrame,
Index,
Reported by Pylint.
Line: 20
Column: 15
class TestResetIndex:
def test_reset_index_dti_round_trip(self):
dti = date_range(start="1/1/2001", end="6/1/2001", freq="D")._with_freq(None)
d1 = DataFrame({"v": np.random.rand(len(dti))}, index=dti)
d2 = d1.reset_index()
assert d2.dtypes[0] == np.dtype("M8[ns]")
d3 = d2.set_index("index")
tm.assert_frame_equal(d1, d3, check_names=False)
Reported by Pylint.
Line: 20
Column: 15
class TestResetIndex:
def test_reset_index_dti_round_trip(self):
dti = date_range(start="1/1/2001", end="6/1/2001", freq="D")._with_freq(None)
d1 = DataFrame({"v": np.random.rand(len(dti))}, index=dti)
d2 = d1.reset_index()
assert d2.dtypes[0] == np.dtype("M8[ns]")
d3 = d2.set_index("index")
tm.assert_frame_equal(d1, d3, check_names=False)
Reported by Pylint.
Line: 20
Column: 15
class TestResetIndex:
def test_reset_index_dti_round_trip(self):
dti = date_range(start="1/1/2001", end="6/1/2001", freq="D")._with_freq(None)
d1 = DataFrame({"v": np.random.rand(len(dti))}, index=dti)
d2 = d1.reset_index()
assert d2.dtypes[0] == np.dtype("M8[ns]")
d3 = d2.set_index("index")
tm.assert_frame_equal(d1, d3, check_names=False)
Reported by Pylint.
Line: 1
Column: 1
from datetime import datetime
import numpy as np
import pytest
import pandas as pd
from pandas import (
DataFrame,
Index,
Reported by Pylint.
Line: 18
Column: 1
import pandas._testing as tm
class TestResetIndex:
def test_reset_index_dti_round_trip(self):
dti = date_range(start="1/1/2001", end="6/1/2001", freq="D")._with_freq(None)
d1 = DataFrame({"v": np.random.rand(len(dti))}, index=dti)
d2 = d1.reset_index()
assert d2.dtypes[0] == np.dtype("M8[ns]")
Reported by Pylint.
Line: 19
Column: 5
class TestResetIndex:
def test_reset_index_dti_round_trip(self):
dti = date_range(start="1/1/2001", end="6/1/2001", freq="D")._with_freq(None)
d1 = DataFrame({"v": np.random.rand(len(dti))}, index=dti)
d2 = d1.reset_index()
assert d2.dtypes[0] == np.dtype("M8[ns]")
d3 = d2.set_index("index")
Reported by Pylint.
Line: 19
Column: 5
class TestResetIndex:
def test_reset_index_dti_round_trip(self):
dti = date_range(start="1/1/2001", end="6/1/2001", freq="D")._with_freq(None)
d1 = DataFrame({"v": np.random.rand(len(dti))}, index=dti)
d2 = d1.reset_index()
assert d2.dtypes[0] == np.dtype("M8[ns]")
d3 = d2.set_index("index")
Reported by Pylint.
Line: 21
Column: 9
class TestResetIndex:
def test_reset_index_dti_round_trip(self):
dti = date_range(start="1/1/2001", end="6/1/2001", freq="D")._with_freq(None)
d1 = DataFrame({"v": np.random.rand(len(dti))}, index=dti)
d2 = d1.reset_index()
assert d2.dtypes[0] == np.dtype("M8[ns]")
d3 = d2.set_index("index")
tm.assert_frame_equal(d1, d3, check_names=False)
Reported by Pylint.
Line: 22
Column: 9
def test_reset_index_dti_round_trip(self):
dti = date_range(start="1/1/2001", end="6/1/2001", freq="D")._with_freq(None)
d1 = DataFrame({"v": np.random.rand(len(dti))}, index=dti)
d2 = d1.reset_index()
assert d2.dtypes[0] == np.dtype("M8[ns]")
d3 = d2.set_index("index")
tm.assert_frame_equal(d1, d3, check_names=False)
# GH#2329
Reported by Pylint.
pandas/tests/arrays/integer/test_arithmetic.py
59 issues
Line: 4
Column: 1
import operator
import numpy as np
import pytest
from pandas.compat import np_version_under1p20
import pandas as pd
import pandas._testing as tm
Reported by Pylint.
Line: 297
Column: 48
def test_unary_int_operators(any_signed_int_ea_dtype, source, neg_target, abs_target):
dtype = any_signed_int_ea_dtype
arr = pd.array(source, dtype=dtype)
neg_result, pos_result, abs_result = -arr, +arr, abs(arr)
neg_target = pd.array(neg_target, dtype=dtype)
abs_target = pd.array(abs_target, dtype=dtype)
tm.assert_extension_array_equal(neg_result, neg_target)
tm.assert_extension_array_equal(pos_result, arr)
Reported by Pylint.
Line: 297
Column: 42
def test_unary_int_operators(any_signed_int_ea_dtype, source, neg_target, abs_target):
dtype = any_signed_int_ea_dtype
arr = pd.array(source, dtype=dtype)
neg_result, pos_result, abs_result = -arr, +arr, abs(arr)
neg_target = pd.array(neg_target, dtype=dtype)
abs_target = pd.array(abs_target, dtype=dtype)
tm.assert_extension_array_equal(neg_result, neg_target)
tm.assert_extension_array_equal(pos_result, arr)
Reported by Pylint.
Line: 297
Column: 42
def test_unary_int_operators(any_signed_int_ea_dtype, source, neg_target, abs_target):
dtype = any_signed_int_ea_dtype
arr = pd.array(source, dtype=dtype)
neg_result, pos_result, abs_result = -arr, +arr, abs(arr)
neg_target = pd.array(neg_target, dtype=dtype)
abs_target = pd.array(abs_target, dtype=dtype)
tm.assert_extension_array_equal(neg_result, neg_target)
tm.assert_extension_array_equal(pos_result, arr)
Reported by Pylint.
Line: 297
Column: 42
def test_unary_int_operators(any_signed_int_ea_dtype, source, neg_target, abs_target):
dtype = any_signed_int_ea_dtype
arr = pd.array(source, dtype=dtype)
neg_result, pos_result, abs_result = -arr, +arr, abs(arr)
neg_target = pd.array(neg_target, dtype=dtype)
abs_target = pd.array(abs_target, dtype=dtype)
tm.assert_extension_array_equal(neg_result, neg_target)
tm.assert_extension_array_equal(pos_result, arr)
Reported by Pylint.
Line: 297
Column: 48
def test_unary_int_operators(any_signed_int_ea_dtype, source, neg_target, abs_target):
dtype = any_signed_int_ea_dtype
arr = pd.array(source, dtype=dtype)
neg_result, pos_result, abs_result = -arr, +arr, abs(arr)
neg_target = pd.array(neg_target, dtype=dtype)
abs_target = pd.array(abs_target, dtype=dtype)
tm.assert_extension_array_equal(neg_result, neg_target)
tm.assert_extension_array_equal(pos_result, arr)
Reported by Pylint.
Line: 297
Column: 48
def test_unary_int_operators(any_signed_int_ea_dtype, source, neg_target, abs_target):
dtype = any_signed_int_ea_dtype
arr = pd.array(source, dtype=dtype)
neg_result, pos_result, abs_result = -arr, +arr, abs(arr)
neg_target = pd.array(neg_target, dtype=dtype)
abs_target = pd.array(abs_target, dtype=dtype)
tm.assert_extension_array_equal(neg_result, neg_target)
tm.assert_extension_array_equal(pos_result, arr)
Reported by Pylint.
Line: 297
Column: 48
def test_unary_int_operators(any_signed_int_ea_dtype, source, neg_target, abs_target):
dtype = any_signed_int_ea_dtype
arr = pd.array(source, dtype=dtype)
neg_result, pos_result, abs_result = -arr, +arr, abs(arr)
neg_target = pd.array(neg_target, dtype=dtype)
abs_target = pd.array(abs_target, dtype=dtype)
tm.assert_extension_array_equal(neg_result, neg_target)
tm.assert_extension_array_equal(pos_result, arr)
Reported by Pylint.
Line: 297
Column: 42
def test_unary_int_operators(any_signed_int_ea_dtype, source, neg_target, abs_target):
dtype = any_signed_int_ea_dtype
arr = pd.array(source, dtype=dtype)
neg_result, pos_result, abs_result = -arr, +arr, abs(arr)
neg_target = pd.array(neg_target, dtype=dtype)
abs_target = pd.array(abs_target, dtype=dtype)
tm.assert_extension_array_equal(neg_result, neg_target)
tm.assert_extension_array_equal(pos_result, arr)
Reported by Pylint.
Line: 166
Column: 5
op = all_arithmetic_operators
s = pd.Series(data)
ops = getattr(s, op)
# invalid scalars
msg = (
r"(:?can only perform ops with numeric values)"
r"|(:?IntegerArray cannot perform the operation mod)"
Reported by Pylint.
pandas/tests/window/moments/test_moments_rolling.py
59 issues
Line: 2
Column: 1
import numpy as np
import pytest
import pandas.util._test_decorators as td
from pandas import (
DataFrame,
Series,
date_range,
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
import pandas.util._test_decorators as td
from pandas import (
DataFrame,
Series,
date_range,
Reported by Pylint.
Line: 14
Column: 1
import pandas._testing as tm
def test_centered_axis_validation():
# ok
Series(np.ones(10)).rolling(window=3, center=True, axis=0).mean()
# bad axis
Reported by Pylint.
Line: 35
Column: 1
@td.skip_if_no_scipy
def test_cmov_mean():
# GH 8238
vals = np.array([6.95, 15.21, 4.72, 9.12, 13.81, 13.49, 16.68, 9.48, 10.63, 14.48])
result = Series(vals).rolling(5, center=True).mean()
expected_values = [
np.nan,
Reported by Pylint.
Line: 56
Column: 1
@td.skip_if_no_scipy
def test_cmov_window():
# GH 8238
vals = np.array([6.95, 15.21, 4.72, 9.12, 13.81, 13.49, 16.68, 9.48, 10.63, 14.48])
result = Series(vals).rolling(5, win_type="boxcar", center=True).mean()
expected_values = [
np.nan,
Reported by Pylint.
Line: 77
Column: 1
@td.skip_if_no_scipy
def test_cmov_window_corner():
# GH 8238
# all nan
vals = Series([np.nan] * 10)
result = vals.rolling(5, center=True, win_type="boxcar").mean()
assert np.isnan(result).all()
Reported by Pylint.
Line: 82
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
# all nan
vals = Series([np.nan] * 10)
result = vals.rolling(5, center=True, win_type="boxcar").mean()
assert np.isnan(result).all()
# empty
vals = Series([], dtype=object)
result = vals.rolling(5, center=True, win_type="boxcar").mean()
assert len(result) == 0
Reported by Bandit.
Line: 87
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
# empty
vals = Series([], dtype=object)
result = vals.rolling(5, center=True, win_type="boxcar").mean()
assert len(result) == 0
# shorter than window
vals = Series(np.random.randn(5))
result = vals.rolling(10, win_type="boxcar").mean()
assert np.isnan(result).all()
Reported by Bandit.
Line: 92
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
# shorter than window
vals = Series(np.random.randn(5))
result = vals.rolling(10, win_type="boxcar").mean()
assert np.isnan(result).all()
assert len(result) == 5
@td.skip_if_no_scipy
@pytest.mark.parametrize(
Reported by Bandit.
Line: 93
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
vals = Series(np.random.randn(5))
result = vals.rolling(10, win_type="boxcar").mean()
assert np.isnan(result).all()
assert len(result) == 5
@td.skip_if_no_scipy
@pytest.mark.parametrize(
"f,xp",
Reported by Bandit.
pandas/plotting/_matplotlib/boxplot.py
59 issues
Line: 41
Column: 5
# namedtuple to hold results
BP = namedtuple("BP", ["ax", "lines"])
def __init__(self, data, return_type="axes", **kwargs):
# Do not call LinePlot.__init__ which may fill nan
if return_type not in self._valid_return_types:
raise ValueError("return_type must be {None, 'axes', 'dict', 'both'}")
self.return_type = return_type
Reported by Pylint.
Line: 47
Column: 9
raise ValueError("return_type must be {None, 'axes', 'dict', 'both'}")
self.return_type = return_type
MPLPlot.__init__(self, data, **kwargs)
def _args_adjust(self):
if self.subplots:
# Disable label ax sharing. Otherwise, all subplots shows last
# column label
Reported by Pylint.
Line: 59
Column: 5
self.sharey = False
@classmethod
def _plot(cls, ax, y, column_num=None, return_type="axes", **kwds):
if y.ndim == 2:
y = [remove_na_arraylike(v) for v in y]
# Boxplot fails with empty arrays, so need to add a NaN
# if any cols are empty
# GH 8181
Reported by Pylint.
Line: 137
Column: 13
def _make_plot(self):
if self.subplots:
self._return_obj = pd.Series(dtype=object)
# Re-create iterated data if `by` is assigned by users
data = (
create_iter_data_given_by(self.data, self._kind)
if self.by is not None
Reported by Pylint.
Line: 179
Column: 13
ax, y, column_num=0, return_type=self.return_type, **kwds
)
self.maybe_color_bp(bp)
self._return_obj = ret
labels = [left for left, _ in self._iter_data()]
labels = [pprint_thing(left) for left in labels]
if not self.use_index:
labels = [pprint_thing(key) for key in range(len(labels))]
Reported by Pylint.
Line: 219
Column: 5
data,
columns=None,
by=None,
numeric_only=True,
grid=False,
figsize=None,
ax=None,
layout=None,
return_type=None,
Reported by Pylint.
Line: 231
Column: 19
if columns is None:
if not isinstance(by, (list, tuple)):
by = [by]
columns = data._get_numeric_data().columns.difference(by)
naxes = len(columns)
fig, axes = create_subplots(
naxes=naxes, sharex=True, sharey=True, figsize=figsize, ax=ax, layout=layout
)
Reported by Pylint.
Line: 281
Column: 27
import matplotlib.pyplot as plt
# validate return_type:
if return_type not in BoxPlot._valid_return_types:
raise ValueError("return_type must be {'axes', 'dict', 'both'}")
if isinstance(data, pd.Series):
data = data.to_frame("x")
column = "x"
Reported by Pylint.
Line: 387
Column: 16
rc = {"figure.figsize": figsize} if figsize is not None else {}
with plt.rc_context(rc):
ax = plt.gca()
data = data._get_numeric_data()
if columns is None:
columns = data.columns
else:
data = data[columns]
Reported by Pylint.
Line: 1
Column: 1
from __future__ import annotations
from collections import namedtuple
from typing import TYPE_CHECKING
import warnings
from matplotlib.artist import setp
import numpy as np
Reported by Pylint.
pandas/io/parsers/base_parser.py
59 issues
Line: 21
Column: 1
import numpy as np
import pandas._libs.lib as lib
import pandas._libs.ops as libops
import pandas._libs.parsers as parsers
from pandas._libs.parsers import STR_NA_VALUES
from pandas._libs.tslibs import parsing
from pandas._typing import (
Reported by Pylint.
Line: 21
Column: 1
import numpy as np
import pandas._libs.lib as lib
import pandas._libs.ops as libops
import pandas._libs.parsers as parsers
from pandas._libs.parsers import STR_NA_VALUES
from pandas._libs.tslibs import parsing
from pandas._typing import (
Reported by Pylint.
Line: 22
Column: 1
import numpy as np
import pandas._libs.lib as lib
import pandas._libs.ops as libops
import pandas._libs.parsers as parsers
from pandas._libs.parsers import STR_NA_VALUES
from pandas._libs.tslibs import parsing
from pandas._typing import (
ArrayLike,
Reported by Pylint.
Line: 22
Column: 1
import numpy as np
import pandas._libs.lib as lib
import pandas._libs.ops as libops
import pandas._libs.parsers as parsers
from pandas._libs.parsers import STR_NA_VALUES
from pandas._libs.tslibs import parsing
from pandas._typing import (
ArrayLike,
Reported by Pylint.
Line: 23
Column: 1
import pandas._libs.lib as lib
import pandas._libs.ops as libops
import pandas._libs.parsers as parsers
from pandas._libs.parsers import STR_NA_VALUES
from pandas._libs.tslibs import parsing
from pandas._typing import (
ArrayLike,
DtypeArg,
Reported by Pylint.
Line: 23
Column: 1
import pandas._libs.lib as lib
import pandas._libs.ops as libops
import pandas._libs.parsers as parsers
from pandas._libs.parsers import STR_NA_VALUES
from pandas._libs.tslibs import parsing
from pandas._typing import (
ArrayLike,
DtypeArg,
Reported by Pylint.
Line: 24
Column: 1
import pandas._libs.lib as lib
import pandas._libs.ops as libops
import pandas._libs.parsers as parsers
from pandas._libs.parsers import STR_NA_VALUES
from pandas._libs.tslibs import parsing
from pandas._typing import (
ArrayLike,
DtypeArg,
FilePathOrBuffer,
Reported by Pylint.
Line: 24
Column: 1
import pandas._libs.lib as lib
import pandas._libs.ops as libops
import pandas._libs.parsers as parsers
from pandas._libs.parsers import STR_NA_VALUES
from pandas._libs.tslibs import parsing
from pandas._typing import (
ArrayLike,
DtypeArg,
FilePathOrBuffer,
Reported by Pylint.
Line: 25
Column: 1
import pandas._libs.ops as libops
import pandas._libs.parsers as parsers
from pandas._libs.parsers import STR_NA_VALUES
from pandas._libs.tslibs import parsing
from pandas._typing import (
ArrayLike,
DtypeArg,
FilePathOrBuffer,
)
Reported by Pylint.
Line: 750
Column: 3
)
if not is_object_dtype(values) and not known_cats:
# TODO: this is for consistency with
# c-parser which parses all categories
# as strings
values = astype_nansafe(values, np.dtype(str))
Reported by Pylint.
pandas/tests/plotting/frame/test_frame_legend.py
58 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas import (
DataFrame,
date_range,
)
from pandas.tests.plotting.common import TestPlotBase
Reported by Pylint.
Line: 116
Column: 19
def test_missing_marker_multi_plots_on_same_ax(self):
# GH 18222
df = DataFrame(data=[[1, 1, 1, 1], [2, 2, 4, 8]], columns=["x", "r", "g", "b"])
fig, ax = self.plt.subplots(nrows=1, ncols=3)
# Left plot
df.plot(x="x", y="r", linewidth=0, marker="o", color="r", ax=ax[0])
df.plot(x="x", y="g", linewidth=1, marker="x", color="g", ax=ax[0])
df.plot(x="x", y="b", linewidth=1, marker="o", color="b", ax=ax[0])
self._check_legend_labels(ax[0], labels=["r", "g", "b"])
Reported by Pylint.
Line: 190
Column: 19
}
)
fig, ax = self.plt.subplots()
for kind in "ABC":
df.plot("X", kind, label=kind, ax=ax, style=".")
self._check_legend_labels(ax, labels=["A", "B", "C"])
self._check_legend_marker(ax, expected_markers=[".", ".", "."])
Reported by Pylint.
Line: 116
Column: 9
def test_missing_marker_multi_plots_on_same_ax(self):
# GH 18222
df = DataFrame(data=[[1, 1, 1, 1], [2, 2, 4, 8]], columns=["x", "r", "g", "b"])
fig, ax = self.plt.subplots(nrows=1, ncols=3)
# Left plot
df.plot(x="x", y="r", linewidth=0, marker="o", color="r", ax=ax[0])
df.plot(x="x", y="g", linewidth=1, marker="x", color="g", ax=ax[0])
df.plot(x="x", y="b", linewidth=1, marker="o", color="b", ax=ax[0])
self._check_legend_labels(ax[0], labels=["r", "g", "b"])
Reported by Pylint.
Line: 190
Column: 9
}
)
fig, ax = self.plt.subplots()
for kind in "ABC":
df.plot("X", kind, label=kind, ax=ax, style=".")
self._check_legend_labels(ax, labels=["A", "B", "C"])
self._check_legend_marker(ax, expected_markers=[".", ".", "."])
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas import (
DataFrame,
date_range,
)
from pandas.tests.plotting.common import TestPlotBase
Reported by Pylint.
Line: 13
Column: 1
pytestmark = pytest.mark.slow
class TestFrameLegend(TestPlotBase):
@pytest.mark.xfail(
reason=(
"Open bug in matplotlib "
"https://github.com/matplotlib/matplotlib/issues/11357"
)
Reported by Pylint.
Line: 17
Column: 5
@pytest.mark.xfail(
reason=(
"Open bug in matplotlib "
"https://github.com/matplotlib/matplotlib/issues/11357"
)
)
def test_mixed_yerr(self):
# https://github.com/pandas-dev/pandas/issues/39522
from matplotlib.collections import LineCollection
Reported by Pylint.
Line: 17
Column: 5
@pytest.mark.xfail(
reason=(
"Open bug in matplotlib "
"https://github.com/matplotlib/matplotlib/issues/11357"
)
)
def test_mixed_yerr(self):
# https://github.com/pandas-dev/pandas/issues/39522
from matplotlib.collections import LineCollection
Reported by Pylint.
Line: 22
Column: 9
)
def test_mixed_yerr(self):
# https://github.com/pandas-dev/pandas/issues/39522
from matplotlib.collections import LineCollection
from matplotlib.lines import Line2D
df = DataFrame([{"x": 1, "a": 1, "b": 1}, {"x": 2, "a": 2, "b": 3}])
ax = df.plot("x", "a", c="orange", yerr=0.1, label="orange")
Reported by Pylint.
pandas/tests/indexes/timedeltas/test_setops.py
58 issues
Line: 2
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas import (
Int64Index,
TimedeltaIndex,
timedelta_range,
)
Reported by Pylint.
Line: 54
Column: 31
result = ordered[:0].union(ordered)
tm.assert_index_equal(result, ordered)
assert result.freq == ordered.freq
def test_union_bug_1730(self):
rng_a = timedelta_range("1 day", periods=4, freq="3H")
rng_b = timedelta_range("1 day", periods=4, freq="4H")
Reported by Pylint.
Line: 115
Column: 31
result = index_1 & index_2
expected = timedelta_range("1 day 01:00:00", periods=3, freq="h")
tm.assert_index_equal(result, expected)
assert result.freq == expected.freq
def test_intersection_equal(self, sort):
# GH 24471 Test intersection outcome given the sort keyword
# for equal indices intersection should return the original index
first = timedelta_range("1 day", periods=4, freq="h")
Reported by Pylint.
Line: 115
Column: 31
result = index_1 & index_2
expected = timedelta_range("1 day 01:00:00", periods=3, freq="h")
tm.assert_index_equal(result, expected)
assert result.freq == expected.freq
def test_intersection_equal(self, sort):
# GH 24471 Test intersection outcome given the sort keyword
# for equal indices intersection should return the original index
first = timedelta_range("1 day", periods=4, freq="h")
Reported by Pylint.
Line: 36
Column: 16
right = tdi[:3]
# Check that we are testing the desired code path
assert left._can_fast_union(right)
result = left.union(right)
tm.assert_index_equal(result, tdi)
result = left.union(right, sort=False)
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas import (
Int64Index,
TimedeltaIndex,
timedelta_range,
)
Reported by Pylint.
Line: 15
Column: 1
from pandas.tseries.offsets import Hour
class TestTimedeltaIndex:
def test_union(self):
i1 = timedelta_range("1day", periods=5)
i2 = timedelta_range("3day", periods=5)
result = i1.union(i2)
Reported by Pylint.
Line: 16
Column: 5
class TestTimedeltaIndex:
def test_union(self):
i1 = timedelta_range("1day", periods=5)
i2 = timedelta_range("3day", periods=5)
result = i1.union(i2)
expected = timedelta_range("1day", periods=7)
Reported by Pylint.
Line: 16
Column: 5
class TestTimedeltaIndex:
def test_union(self):
i1 = timedelta_range("1day", periods=5)
i2 = timedelta_range("3day", periods=5)
result = i1.union(i2)
expected = timedelta_range("1day", periods=7)
Reported by Pylint.
Line: 18
Column: 9
class TestTimedeltaIndex:
def test_union(self):
i1 = timedelta_range("1day", periods=5)
i2 = timedelta_range("3day", periods=5)
result = i1.union(i2)
expected = timedelta_range("1day", periods=7)
tm.assert_index_equal(result, expected)
Reported by Pylint.
pandas/tests/extension/test_datetime.py
58 issues
Line: 17
Column: 1
"""
import numpy as np
import pytest
from pandas.core.dtypes.dtypes import DatetimeTZDtype
import pandas as pd
from pandas.core.arrays import DatetimeArray
Reported by Pylint.
Line: 32
Column: 10
@pytest.fixture
def data(dtype):
data = DatetimeArray(pd.date_range("2000", periods=100, tz=dtype.tz), dtype=dtype)
return data
@pytest.fixture
Reported by Pylint.
Line: 33
Column: 5
@pytest.fixture
def data(dtype):
data = DatetimeArray(pd.date_range("2000", periods=100, tz=dtype.tz), dtype=dtype)
return data
@pytest.fixture
def data_missing(dtype):
Reported by Pylint.
Line: 38
Column: 18
@pytest.fixture
def data_missing(dtype):
return DatetimeArray(
np.array(["NaT", "2000-01-01"], dtype="datetime64[ns]"), dtype=dtype
)
Reported by Pylint.
Line: 45
Column: 22
@pytest.fixture
def data_for_sorting(dtype):
a = pd.Timestamp("2000-01-01")
b = pd.Timestamp("2000-01-02")
c = pd.Timestamp("2000-01-03")
return DatetimeArray(np.array([b, c, a], dtype="datetime64[ns]"), dtype=dtype)
Reported by Pylint.
Line: 53
Column: 30
@pytest.fixture
def data_missing_for_sorting(dtype):
a = pd.Timestamp("2000-01-01")
b = pd.Timestamp("2000-01-02")
return DatetimeArray(np.array([b, "NaT", a], dtype="datetime64[ns]"), dtype=dtype)
Reported by Pylint.
Line: 60
Column: 23
@pytest.fixture
def data_for_grouping(dtype):
"""
Expected to be like [B, B, NA, NA, A, A, B, C]
Where A < B < C and NA is missing
"""
Reported by Pylint.
Line: 100
Column: 39
class TestConstructors(BaseDatetimeTests, base.BaseConstructorsTests):
def test_series_constructor(self, data):
# Series construction drops any .freq attr
data = data._with_freq(None)
super().test_series_constructor(data)
Reported by Pylint.
Line: 102
Column: 16
class TestConstructors(BaseDatetimeTests, base.BaseConstructorsTests):
def test_series_constructor(self, data):
# Series construction drops any .freq attr
data = data._with_freq(None)
super().test_series_constructor(data)
class TestGetitem(BaseDatetimeTests, base.BaseGetitemTests):
pass
Reported by Pylint.
Line: 121
Column: 36
class TestInterface(BaseDatetimeTests, base.BaseInterfaceTests):
def test_array_interface(self, data):
if data.tz:
# np.asarray(DTA) is currently always tz-naive.
pytest.skip("GH-23569")
else:
super().test_array_interface(data)
Reported by Pylint.
pandas/tests/extension/test_string.py
58 issues
Line: 19
Column: 1
import string
import numpy as np
import pytest
import pandas as pd
from pandas.core.arrays.string_ import StringDtype
from pandas.tests.extension import base
Reported by Pylint.
Line: 31
Column: 9
pytest.skip("chunked array n/a")
def _split_array(arr):
import pyarrow as pa
arrow_array = arr._data
split = len(arrow_array) // 2
arrow_array = pa.chunked_array(
[*arrow_array[:split].chunks, *arrow_array[split:].chunks]
Reported by Pylint.
Line: 33
Column: 23
def _split_array(arr):
import pyarrow as pa
arrow_array = arr._data
split = len(arrow_array) // 2
arrow_array = pa.chunked_array(
[*arrow_array[:split].chunks, *arrow_array[split:].chunks]
)
assert arrow_array.num_chunks == 2
Reported by Pylint.
Line: 55
Column: 10
@pytest.fixture
def data(dtype, chunked):
strings = np.random.choice(list(string.ascii_letters), size=100)
while strings[0] == strings[1]:
strings = np.random.choice(list(string.ascii_letters), size=100)
arr = dtype.construct_array_type()._from_sequence(strings)
Reported by Pylint.
Line: 55
Column: 17
@pytest.fixture
def data(dtype, chunked):
strings = np.random.choice(list(string.ascii_letters), size=100)
while strings[0] == strings[1]:
strings = np.random.choice(list(string.ascii_letters), size=100)
arr = dtype.construct_array_type()._from_sequence(strings)
Reported by Pylint.
Line: 60
Column: 11
while strings[0] == strings[1]:
strings = np.random.choice(list(string.ascii_letters), size=100)
arr = dtype.construct_array_type()._from_sequence(strings)
return split_array(arr) if chunked else arr
@pytest.fixture
def data_missing(dtype, chunked):
Reported by Pylint.
Line: 65
Column: 25
@pytest.fixture
def data_missing(dtype, chunked):
"""Length 2 array with [NA, Valid]"""
arr = dtype.construct_array_type()._from_sequence([pd.NA, "A"])
return split_array(arr) if chunked else arr
Reported by Pylint.
Line: 65
Column: 18
@pytest.fixture
def data_missing(dtype, chunked):
"""Length 2 array with [NA, Valid]"""
arr = dtype.construct_array_type()._from_sequence([pd.NA, "A"])
return split_array(arr) if chunked else arr
Reported by Pylint.
Line: 67
Column: 11
@pytest.fixture
def data_missing(dtype, chunked):
"""Length 2 array with [NA, Valid]"""
arr = dtype.construct_array_type()._from_sequence([pd.NA, "A"])
return split_array(arr) if chunked else arr
@pytest.fixture
def data_for_sorting(dtype, chunked):
Reported by Pylint.
Line: 72
Column: 29
@pytest.fixture
def data_for_sorting(dtype, chunked):
arr = dtype.construct_array_type()._from_sequence(["B", "C", "A"])
return split_array(arr) if chunked else arr
@pytest.fixture
Reported by Pylint.