The following issues were found
pandas/tests/tseries/offsets/test_business_hour.py
151 issues
Line: 9
Column: 1
time as dt_time,
)
import pytest
from pandas._libs.tslibs import (
Timedelta,
Timestamp,
)
Reported by Pylint.
Line: 15
Column: 1
Timedelta,
Timestamp,
)
from pandas._libs.tslibs.offsets import (
BDay,
BusinessHour,
Nano,
)
Reported by Pylint.
Line: 15
Column: 1
Timedelta,
Timestamp,
)
from pandas._libs.tslibs.offsets import (
BDay,
BusinessHour,
Nano,
)
Reported by Pylint.
Line: 35
Column: 28
class TestBusinessHour(Base):
_offset = BusinessHour
def setup_method(self, method):
self.d = datetime(2014, 7, 1, 10, 00)
self.offset1 = BusinessHour()
self.offset2 = BusinessHour(n=3)
Reported by Pylint.
Line: 38
Column: 9
def setup_method(self, method):
self.d = datetime(2014, 7, 1, 10, 00)
self.offset1 = BusinessHour()
self.offset2 = BusinessHour(n=3)
self.offset3 = BusinessHour(n=-1)
self.offset4 = BusinessHour(n=-4)
Reported by Pylint.
Line: 39
Column: 9
self.d = datetime(2014, 7, 1, 10, 00)
self.offset1 = BusinessHour()
self.offset2 = BusinessHour(n=3)
self.offset3 = BusinessHour(n=-1)
self.offset4 = BusinessHour(n=-4)
from datetime import time as dt_time
Reported by Pylint.
Line: 41
Column: 9
self.offset1 = BusinessHour()
self.offset2 = BusinessHour(n=3)
self.offset3 = BusinessHour(n=-1)
self.offset4 = BusinessHour(n=-4)
from datetime import time as dt_time
self.offset5 = BusinessHour(start=dt_time(11, 0), end=dt_time(14, 30))
Reported by Pylint.
Line: 42
Column: 9
self.offset2 = BusinessHour(n=3)
self.offset3 = BusinessHour(n=-1)
self.offset4 = BusinessHour(n=-4)
from datetime import time as dt_time
self.offset5 = BusinessHour(start=dt_time(11, 0), end=dt_time(14, 30))
self.offset6 = BusinessHour(start="20:00", end="05:00")
Reported by Pylint.
Line: 44
Column: 9
self.offset3 = BusinessHour(n=-1)
self.offset4 = BusinessHour(n=-4)
from datetime import time as dt_time
self.offset5 = BusinessHour(start=dt_time(11, 0), end=dt_time(14, 30))
self.offset6 = BusinessHour(start="20:00", end="05:00")
self.offset7 = BusinessHour(n=-2, start=dt_time(21, 30), end=dt_time(6, 30))
self.offset8 = BusinessHour(start=["09:00", "13:00"], end=["12:00", "17:00"])
Reported by Pylint.
Line: 44
Column: 9
self.offset3 = BusinessHour(n=-1)
self.offset4 = BusinessHour(n=-4)
from datetime import time as dt_time
self.offset5 = BusinessHour(start=dt_time(11, 0), end=dt_time(14, 30))
self.offset6 = BusinessHour(start="20:00", end="05:00")
self.offset7 = BusinessHour(n=-2, start=dt_time(21, 30), end=dt_time(6, 30))
self.offset8 = BusinessHour(start=["09:00", "13:00"], end=["12:00", "17:00"])
Reported by Pylint.
pandas/tests/indexing/test_partial.py
151 issues
Line: 8
Column: 1
"""
import numpy as np
import pytest
import pandas.util._test_decorators as td
import pandas as pd
from pandas import (
Reported by Pylint.
Line: 132
Column: 62
)
expected = pd.concat(
[df_orig, DataFrame({"A": 7}, index=dates[-1:] + dates.freq)], sort=True
)
df = df_orig.copy()
df.loc[dates[-1] + dates.freq, "A"] = 7
tm.assert_frame_equal(df, expected)
df = df_orig.copy()
Reported by Pylint.
Line: 132
Column: 62
)
expected = pd.concat(
[df_orig, DataFrame({"A": 7}, index=dates[-1:] + dates.freq)], sort=True
)
df = df_orig.copy()
df.loc[dates[-1] + dates.freq, "A"] = 7
tm.assert_frame_equal(df, expected)
df = df_orig.copy()
Reported by Pylint.
Line: 135
Column: 28
[df_orig, DataFrame({"A": 7}, index=dates[-1:] + dates.freq)], sort=True
)
df = df_orig.copy()
df.loc[dates[-1] + dates.freq, "A"] = 7
tm.assert_frame_equal(df, expected)
df = df_orig.copy()
df.at[dates[-1] + dates.freq, "A"] = 7
tm.assert_frame_equal(df, expected)
Reported by Pylint.
Line: 135
Column: 28
[df_orig, DataFrame({"A": 7}, index=dates[-1:] + dates.freq)], sort=True
)
df = df_orig.copy()
df.loc[dates[-1] + dates.freq, "A"] = 7
tm.assert_frame_equal(df, expected)
df = df_orig.copy()
df.at[dates[-1] + dates.freq, "A"] = 7
tm.assert_frame_equal(df, expected)
Reported by Pylint.
Line: 138
Column: 27
df.loc[dates[-1] + dates.freq, "A"] = 7
tm.assert_frame_equal(df, expected)
df = df_orig.copy()
df.at[dates[-1] + dates.freq, "A"] = 7
tm.assert_frame_equal(df, expected)
exp_other = DataFrame({0: 7}, index=dates[-1:] + dates.freq)
expected = pd.concat([df_orig, exp_other], axis=1)
Reported by Pylint.
Line: 138
Column: 27
df.loc[dates[-1] + dates.freq, "A"] = 7
tm.assert_frame_equal(df, expected)
df = df_orig.copy()
df.at[dates[-1] + dates.freq, "A"] = 7
tm.assert_frame_equal(df, expected)
exp_other = DataFrame({0: 7}, index=dates[-1:] + dates.freq)
expected = pd.concat([df_orig, exp_other], axis=1)
Reported by Pylint.
Line: 141
Column: 58
df.at[dates[-1] + dates.freq, "A"] = 7
tm.assert_frame_equal(df, expected)
exp_other = DataFrame({0: 7}, index=dates[-1:] + dates.freq)
expected = pd.concat([df_orig, exp_other], axis=1)
df = df_orig.copy()
df.loc[dates[-1] + dates.freq, 0] = 7
tm.assert_frame_equal(df, expected)
Reported by Pylint.
Line: 141
Column: 58
df.at[dates[-1] + dates.freq, "A"] = 7
tm.assert_frame_equal(df, expected)
exp_other = DataFrame({0: 7}, index=dates[-1:] + dates.freq)
expected = pd.concat([df_orig, exp_other], axis=1)
df = df_orig.copy()
df.loc[dates[-1] + dates.freq, 0] = 7
tm.assert_frame_equal(df, expected)
Reported by Pylint.
Line: 145
Column: 28
expected = pd.concat([df_orig, exp_other], axis=1)
df = df_orig.copy()
df.loc[dates[-1] + dates.freq, 0] = 7
tm.assert_frame_equal(df, expected)
df = df_orig.copy()
df.at[dates[-1] + dates.freq, 0] = 7
tm.assert_frame_equal(df, expected)
Reported by Pylint.
pandas/tests/plotting/test_converter.py
151 issues
Line: 9
Column: 1
import sys
import numpy as np
import pytest
import pandas._config.config as cf
from pandas.compat import (
is_platform_windows,
Reported by Pylint.
Line: 228
Column: 31
rs = self.dtc.convert(Index([ts - Day(1), ts]), None, None)
assert rs[1] == xp
rs = self.dtc.convert(Index([ts - Day(1), ts]).to_pydatetime(), None, None)
assert rs[1] == xp
def test_conversion_float(self):
rtol = 0.5 * 10 ** -9
Reported by Pylint.
Line: 144
Column: 9
def test_registry_resets(self):
units = pytest.importorskip("matplotlib.units")
dates = pytest.importorskip("matplotlib.dates")
# make a copy, to reset to
original = dict(units.registry)
try:
Reported by Pylint.
Line: 169
Column: 28
class TestDateTimeConverter:
def setup_method(self, method):
self.dtc = converter.DatetimeConverter()
self.tc = converter.TimeFormatter(None)
def test_convert_accepts_unicode(self):
r1 = self.dtc.convert("12:22", None, None)
Reported by Pylint.
Line: 170
Column: 9
class TestDateTimeConverter:
def setup_method(self, method):
self.dtc = converter.DatetimeConverter()
self.tc = converter.TimeFormatter(None)
def test_convert_accepts_unicode(self):
r1 = self.dtc.convert("12:22", None, None)
r2 = self.dtc.convert("12:22", None, None)
Reported by Pylint.
Line: 171
Column: 9
class TestDateTimeConverter:
def setup_method(self, method):
self.dtc = converter.DatetimeConverter()
self.tc = converter.TimeFormatter(None)
def test_convert_accepts_unicode(self):
r1 = self.dtc.convert("12:22", None, None)
r2 = self.dtc.convert("12:22", None, None)
assert r1 == r2, "DatetimeConverter.convert should accept unicode"
Reported by Pylint.
Line: 285
Column: 43
for freq in ("B", "L", "S"):
dateindex = tm.makeDateIndex(k=10, freq=freq)
rs = self.dtc.convert(dateindex, None, None)
xp = converter.dates.date2num(dateindex._mpl_repr())
tm.assert_almost_equal(rs, xp, rtol=rtol)
def test_resolution(self):
def _assert_less(ts1, ts2):
val1 = self.dtc.convert(ts1, None, None)
Reported by Pylint.
Line: 311
Column: 28
class TestPeriodConverter:
def setup_method(self, method):
self.pc = converter.PeriodConverter()
class Axis:
pass
Reported by Pylint.
Line: 312
Column: 9
class TestPeriodConverter:
def setup_method(self, method):
self.pc = converter.PeriodConverter()
class Axis:
pass
self.axis = Axis()
Reported by Pylint.
Line: 317
Column: 9
class Axis:
pass
self.axis = Axis()
self.axis.freq = "D"
def test_convert_accepts_unicode(self):
r1 = self.pc.convert("2012-1-1", None, self.axis)
r2 = self.pc.convert("2012-1-1", None, self.axis)
Reported by Pylint.
pandas/core/reshape/merge.py
151 issues
Line: 20
Column: 1
import numpy as np
from pandas._libs import (
Timedelta,
hashtable as libhashtable,
join as libjoin,
lib,
)
Reported by Pylint.
Line: 20
Column: 1
import numpy as np
from pandas._libs import (
Timedelta,
hashtable as libhashtable,
join as libjoin,
lib,
)
Reported by Pylint.
Line: 20
Column: 1
import numpy as np
from pandas._libs import (
Timedelta,
hashtable as libhashtable,
join as libjoin,
lib,
)
Reported by Pylint.
Line: 1007
Column: 18
self,
index: Index,
other_index: Index,
indexer: npt.NDArray[np.intp],
how: str = "left",
) -> Index:
"""
Create a join index by rearranging one index to match another
Reported by Pylint.
Line: 1452
Column: 12
def get_join_indexers(
left_keys, right_keys, sort: bool = False, how: str = "inner", **kwargs
) -> tuple[npt.NDArray[np.intp], npt.NDArray[np.intp]]:
"""
Parameters
----------
left_keys : ndarray, Index, Series
Reported by Pylint.
Line: 1452
Column: 34
def get_join_indexers(
left_keys, right_keys, sort: bool = False, how: str = "inner", **kwargs
) -> tuple[npt.NDArray[np.intp], npt.NDArray[np.intp]]:
"""
Parameters
----------
left_keys : ndarray, Index, Series
Reported by Pylint.
Line: 1511
Column: 15
right: MultiIndex,
dropped_level_names,
join_index: Index,
lindexer: npt.NDArray[np.intp],
rindexer: npt.NDArray[np.intp],
) -> tuple[list[Index], npt.NDArray[np.intp], list[Hashable]]:
"""
*this is an internal non-public method*
Reported by Pylint.
Line: 1512
Column: 15
dropped_level_names,
join_index: Index,
lindexer: npt.NDArray[np.intp],
rindexer: npt.NDArray[np.intp],
) -> tuple[list[Index], npt.NDArray[np.intp], list[Hashable]]:
"""
*this is an internal non-public method*
Returns the levels, labels and names of a multi-index to multi-index join.
Reported by Pylint.
Line: 1513
Column: 25
join_index: Index,
lindexer: npt.NDArray[np.intp],
rindexer: npt.NDArray[np.intp],
) -> tuple[list[Index], npt.NDArray[np.intp], list[Hashable]]:
"""
*this is an internal non-public method*
Returns the levels, labels and names of a multi-index to multi-index join.
Depending on the type of join, this method restores the appropriate
Reported by Pylint.
Line: 2069
Column: 34
def _factorize_keys(
lk: ArrayLike, rk: ArrayLike, sort: bool = True, how: str = "inner"
) -> tuple[npt.NDArray[np.intp], npt.NDArray[np.intp], int]:
"""
Encode left and right keys as enumerated types.
This is used to get the join indexers to be used when merging DataFrames.
Reported by Pylint.
pandas/tests/reshape/merge/test_join.py
150 issues
Line: 2
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas import (
Categorical,
DataFrame,
Index,
MultiIndex,
Reported by Pylint.
Line: 26
Column: 28
class TestJoin:
def setup_method(self, method):
# aggregate multiple columns
self.df = DataFrame(
{
"key1": get_test_data(),
"key2": get_test_data(),
Reported by Pylint.
Line: 28
Column: 9
class TestJoin:
def setup_method(self, method):
# aggregate multiple columns
self.df = DataFrame(
{
"key1": get_test_data(),
"key2": get_test_data(),
"data1": np.random.randn(N),
"data2": np.random.randn(N),
Reported by Pylint.
Line: 38
Column: 9
)
# exclude a couple keys for fun
self.df = self.df[self.df["key2"] > 1]
self.df2 = DataFrame(
{
"key1": get_test_data(n=N // 5),
"key2": get_test_data(ngroups=NGROUPS // 2, n=N // 5),
Reported by Pylint.
Line: 40
Column: 9
# exclude a couple keys for fun
self.df = self.df[self.df["key2"] > 1]
self.df2 = DataFrame(
{
"key1": get_test_data(n=N // 5),
"key2": get_test_data(ngroups=NGROUPS // 2, n=N // 5),
"value": np.random.randn(N // 5),
}
Reported by Pylint.
Line: 49
Column: 9
)
index, data = tm.getMixedTypeDict()
self.target = DataFrame(data, index=index)
# Join on string value
self.source = DataFrame(
{"MergedA": data["A"], "MergedD": data["D"]}, index=data["C"]
)
Reported by Pylint.
Line: 52
Column: 9
self.target = DataFrame(data, index=index)
# Join on string value
self.source = DataFrame(
{"MergedA": data["A"], "MergedD": data["D"]}, index=data["C"]
)
def test_left_outer_join(self):
joined_key2 = merge(self.df, self.df2, on="key2")
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas import (
Categorical,
DataFrame,
Index,
MultiIndex,
Reported by Pylint.
Line: 25
Column: 1
a_ = np.array
class TestJoin:
def setup_method(self, method):
# aggregate multiple columns
self.df = DataFrame(
{
"key1": get_test_data(),
Reported by Pylint.
Line: 25
Column: 1
a_ = np.array
class TestJoin:
def setup_method(self, method):
# aggregate multiple columns
self.df = DataFrame(
{
"key1": get_test_data(),
Reported by Pylint.
pandas/tests/indexes/datetimes/test_misc.py
149 issues
Line: 7
Column: 1
import unicodedata
import numpy as np
import pytest
import pandas as pd
from pandas import (
DatetimeIndex,
Index,
Reported by Pylint.
Line: 253
Column: 20
def test_datetimeindex_accessors2(self):
dti = date_range(freq="BQ-FEB", start=datetime(1998, 1, 1), periods=4)
assert sum(dti.is_quarter_start) == 0
assert sum(dti.is_quarter_end) == 4
assert sum(dti.is_year_start) == 0
assert sum(dti.is_year_end) == 1
def test_datetimeindex_accessors3(self):
Reported by Pylint.
Line: 253
Column: 20
def test_datetimeindex_accessors2(self):
dti = date_range(freq="BQ-FEB", start=datetime(1998, 1, 1), periods=4)
assert sum(dti.is_quarter_start) == 0
assert sum(dti.is_quarter_end) == 4
assert sum(dti.is_year_start) == 0
assert sum(dti.is_year_end) == 1
def test_datetimeindex_accessors3(self):
Reported by Pylint.
Line: 254
Column: 20
dti = date_range(freq="BQ-FEB", start=datetime(1998, 1, 1), periods=4)
assert sum(dti.is_quarter_start) == 0
assert sum(dti.is_quarter_end) == 4
assert sum(dti.is_year_start) == 0
assert sum(dti.is_year_end) == 1
def test_datetimeindex_accessors3(self):
# Ensure is_start/end accessors throw ValueError for CustomBusinessDay,
Reported by Pylint.
Line: 254
Column: 20
dti = date_range(freq="BQ-FEB", start=datetime(1998, 1, 1), periods=4)
assert sum(dti.is_quarter_start) == 0
assert sum(dti.is_quarter_end) == 4
assert sum(dti.is_year_start) == 0
assert sum(dti.is_year_end) == 1
def test_datetimeindex_accessors3(self):
# Ensure is_start/end accessors throw ValueError for CustomBusinessDay,
Reported by Pylint.
Line: 255
Column: 20
assert sum(dti.is_quarter_start) == 0
assert sum(dti.is_quarter_end) == 4
assert sum(dti.is_year_start) == 0
assert sum(dti.is_year_end) == 1
def test_datetimeindex_accessors3(self):
# Ensure is_start/end accessors throw ValueError for CustomBusinessDay,
bday_egypt = offsets.CustomBusinessDay(weekmask="Sun Mon Tue Wed Thu")
Reported by Pylint.
Line: 255
Column: 20
assert sum(dti.is_quarter_start) == 0
assert sum(dti.is_quarter_end) == 4
assert sum(dti.is_year_start) == 0
assert sum(dti.is_year_end) == 1
def test_datetimeindex_accessors3(self):
# Ensure is_start/end accessors throw ValueError for CustomBusinessDay,
bday_egypt = offsets.CustomBusinessDay(weekmask="Sun Mon Tue Wed Thu")
Reported by Pylint.
Line: 256
Column: 20
assert sum(dti.is_quarter_start) == 0
assert sum(dti.is_quarter_end) == 4
assert sum(dti.is_year_start) == 0
assert sum(dti.is_year_end) == 1
def test_datetimeindex_accessors3(self):
# Ensure is_start/end accessors throw ValueError for CustomBusinessDay,
bday_egypt = offsets.CustomBusinessDay(weekmask="Sun Mon Tue Wed Thu")
dti = date_range(datetime(2013, 4, 30), periods=5, freq=bday_egypt)
Reported by Pylint.
Line: 256
Column: 20
assert sum(dti.is_quarter_start) == 0
assert sum(dti.is_quarter_end) == 4
assert sum(dti.is_year_start) == 0
assert sum(dti.is_year_end) == 1
def test_datetimeindex_accessors3(self):
# Ensure is_start/end accessors throw ValueError for CustomBusinessDay,
bday_egypt = offsets.CustomBusinessDay(weekmask="Sun Mon Tue Wed Thu")
dti = date_range(datetime(2013, 4, 30), periods=5, freq=bday_egypt)
Reported by Pylint.
Line: 264
Column: 13
dti = date_range(datetime(2013, 4, 30), periods=5, freq=bday_egypt)
msg = "Custom business days is not supported by is_month_start"
with pytest.raises(ValueError, match=msg):
dti.is_month_start
def test_datetimeindex_accessors4(self):
dti = DatetimeIndex(["2000-01-01", "2000-01-02", "2000-01-03"])
assert dti.is_month_start[0] == 1
Reported by Pylint.
pandas/core/series.py
148 issues
Line: 29
Column: 1
from pandas._config import get_option
from pandas._libs import (
lib,
properties,
reshape,
tslibs,
)
Reported by Pylint.
Line: 29
Column: 1
from pandas._config import get_option
from pandas._libs import (
lib,
properties,
reshape,
tslibs,
)
Reported by Pylint.
Line: 29
Column: 1
from pandas._config import get_option
from pandas._libs import (
lib,
properties,
reshape,
tslibs,
)
Reported by Pylint.
Line: 35
Column: 1
reshape,
tslibs,
)
from pandas._libs.lib import no_default
from pandas._typing import (
AggFuncType,
ArrayLike,
Axis,
Dtype,
Reported by Pylint.
Line: 35
Column: 1
reshape,
tslibs,
)
from pandas._libs.lib import no_default
from pandas._typing import (
AggFuncType,
ArrayLike,
Axis,
Dtype,
Reported by Pylint.
Line: 302
Column: 9
# error: Incompatible types in assignment (expression has type "property",
# base class "IndexOpsMixin" defined the type as "Callable[[IndexOpsMixin], bool]")
hasnans = property( # type: ignore[assignment]
base.IndexOpsMixin.hasnans.func, doc=base.IndexOpsMixin.hasnans.__doc__
)
_mgr: SingleManager
div: Callable[[Series, Any], Series]
rdiv: Callable[[Series, Any], Series]
Reported by Pylint.
Line: 702
Column: 15
return self._mgr.internal_values()
# error: Decorated property not supported
@Appender(base.IndexOpsMixin.array.__doc__) # type: ignore[misc]
@property
def array(self) -> ExtensionArray:
return self._mgr.array_values()
# ops
Reported by Pylint.
Line: 1091
Column: 33
key = check_bool_indexer(self.index, key)
key = np.asarray(key, dtype=bool)
try:
self._where(~key, value, inplace=True)
except InvalidIndexError:
self.iloc[key] = value
return
else:
Reported by Pylint.
Line: 4386
Column: 49
return op(delegate, skipna=skipna, **kwds)
def _reindex_indexer(
self, new_index: Index | None, indexer: npt.NDArray[np.intp] | None, copy: bool
) -> Series:
# Note: new_index is None iff indexer is None
# if not None, indexer is np.intp
if indexer is None:
if copy:
Reported by Pylint.
Line: 485
Column: 3
# Input is now list-like, so rely on "standard" construction:
# TODO: passing np.float64 to not break anything yet. See GH-17261
s = create_series_with_explicit_dtype(
# error: Argument "index" to "create_series_with_explicit_dtype" has
# incompatible type "Tuple[Any, ...]"; expected "Union[ExtensionArray,
# ndarray, Index, None]"
values,
Reported by Pylint.
pandas/tests/plotting/test_misc.py
148 issues
Line: 4
Column: 1
""" Test cases for misc plot functions """
import numpy as np
import pytest
import pandas.util._test_decorators as td
from pandas import (
DataFrame,
Reported by Pylint.
Line: 111
Column: 21
ax = None
if pass_axis:
_, ax = self.plt.subplots(3, 3)
with tm.RNGContext(42):
df = DataFrame(np.random.randn(100, 3))
# we are plotting multiples on a sub-plot
Reported by Pylint.
Line: 177
Column: 69
)
ax = _check_plot_works(
andrews_curves, frame=df, class_column="Name", colormap=cm.jet
)
cmaps = [cm.jet(n) for n in np.linspace(0, 1, df["Name"].nunique())]
self._check_colors(
ax.get_lines()[:10], linecolors=cmaps, mapping=df["Name"][:10]
)
Reported by Pylint.
Line: 179
Column: 18
ax = _check_plot_works(
andrews_curves, frame=df, class_column="Name", colormap=cm.jet
)
cmaps = [cm.jet(n) for n in np.linspace(0, 1, df["Name"].nunique())]
self._check_colors(
ax.get_lines()[:10], linecolors=cmaps, mapping=df["Name"][:10]
)
length = 10
Reported by Pylint.
Line: 213
Column: 69
)
ax = _check_plot_works(
andrews_curves, frame=df, class_column="Name", colormap=cm.jet
)
cmaps = [cm.jet(n) for n in np.linspace(0, 1, df["Name"].nunique())]
self._check_colors(
ax.get_lines()[:10], linecolors=cmaps, mapping=df["Name"][:10]
)
Reported by Pylint.
Line: 215
Column: 18
ax = _check_plot_works(
andrews_curves, frame=df, class_column="Name", colormap=cm.jet
)
cmaps = [cm.jet(n) for n in np.linspace(0, 1, df["Name"].nunique())]
self._check_colors(
ax.get_lines()[:10], linecolors=cmaps, mapping=df["Name"][:10]
)
colors = ["b", "g", "r"]
Reported by Pylint.
Line: 254
Column: 75
)
ax = _check_plot_works(
parallel_coordinates, frame=df, class_column="Name", colormap=cm.jet
)
cmaps = [cm.jet(n) for n in np.linspace(0, 1, df["Name"].nunique())]
self._check_colors(
ax.get_lines()[:10], linecolors=cmaps, mapping=df["Name"][:10]
)
Reported by Pylint.
Line: 256
Column: 18
ax = _check_plot_works(
parallel_coordinates, frame=df, class_column="Name", colormap=cm.jet
)
cmaps = [cm.jet(n) for n in np.linspace(0, 1, df["Name"].nunique())]
self._check_colors(
ax.get_lines()[:10], linecolors=cmaps, mapping=df["Name"][:10]
)
ax = _check_plot_works(
Reported by Pylint.
Line: 320
Column: 75
patches = [p for p in ax.patches[:20] if p.get_label() != ""]
self._check_colors(patches, facecolors=cnames, mapping=df["Name"][:10])
_check_plot_works(radviz, frame=df, class_column="Name", colormap=cm.jet)
cmaps = [cm.jet(n) for n in np.linspace(0, 1, df["Name"].nunique())]
patches = [p for p in ax.patches[:20] if p.get_label() != ""]
self._check_colors(patches, facecolors=cmaps, mapping=df["Name"][:10])
colors = [[0.0, 0.0, 1.0, 1.0], [0.0, 0.5, 1.0, 1.0], [1.0, 0.0, 0.0, 1.0]]
Reported by Pylint.
Line: 321
Column: 18
self._check_colors(patches, facecolors=cnames, mapping=df["Name"][:10])
_check_plot_works(radviz, frame=df, class_column="Name", colormap=cm.jet)
cmaps = [cm.jet(n) for n in np.linspace(0, 1, df["Name"].nunique())]
patches = [p for p in ax.patches[:20] if p.get_label() != ""]
self._check_colors(patches, facecolors=cmaps, mapping=df["Name"][:10])
colors = [[0.0, 0.0, 1.0, 1.0], [0.0, 0.5, 1.0, 1.0], [1.0, 0.0, 0.0, 1.0]]
df = DataFrame(
Reported by Pylint.
pandas/tests/extension/base/methods.py
147 issues
Line: 5
Column: 1
import operator
import numpy as np
import pytest
from pandas.core.dtypes.common import is_bool_dtype
import pandas as pd
import pandas._testing as tm
Reported by Pylint.
Line: 90
Column: 78
expected = pd.Series(np.array([1, -1, 0], dtype=np.int64))
self.assert_series_equal(result, expected)
def test_argmin_argmax(self, data_for_sorting, data_missing_for_sorting, na_value):
# GH 24382
# data_for_sorting -> [B, C, A] with A < B < C
assert data_for_sorting.argmax() == 1
assert data_for_sorting.argmin() == 2
Reported by Pylint.
Line: 118
Column: 19
def test_argmin_argmax_all_na(self, method, data, na_value):
# all missing with skipna=True is the same as empty
err_msg = "attempt to get"
data_na = type(data)._from_sequence([na_value, na_value], dtype=data.dtype)
with pytest.raises(ValueError, match=err_msg):
getattr(data_na, method)()
@pytest.mark.parametrize(
"op_name, skipna, expected",
Reported by Pylint.
Line: 192
Column: 56
self.assert_series_equal(result, expected)
@pytest.mark.parametrize("ascending", [True, False])
def test_sort_values_frame(self, data_for_sorting, ascending):
df = pd.DataFrame({"A": [1, 2, 1], "B": data_for_sorting})
result = df.sort_values(["A", "B"])
expected = pd.DataFrame(
{"A": [1, 1, 2], "B": data_for_sorting.take([2, 0, 1])}, index=[2, 0, 1]
)
Reported by Pylint.
Line: 203
Column: 26
@pytest.mark.parametrize("box", [pd.Series, lambda x: x])
@pytest.mark.parametrize("method", [lambda x: x.unique(), pd.unique])
def test_unique(self, data, box, method):
duplicated = box(data._from_sequence([data[0], data[0]]))
result = method(duplicated)
assert len(result) == 1
assert isinstance(result, type(data))
Reported by Pylint.
Line: 235
Column: 28
def test_factorize_empty(self, data):
codes, uniques = pd.factorize(data[:0])
expected_codes = np.array([], dtype=np.intp)
expected_uniques = type(data)._from_sequence([], dtype=data[:0].dtype)
tm.assert_numpy_array_equal(codes, expected_codes)
self.assert_extension_array_equal(uniques, expected_uniques)
def test_fillna_copy_frame(self, data_missing):
Reported by Pylint.
Line: 256
Column: 16
filled_val = ser[0]
result = ser.fillna(filled_val)
assert ser._values is not result._values
assert ser._values is arr
def test_fillna_length_mismatch(self, data_missing):
msg = "Length of 'value' does not match."
with pytest.raises(ValueError, match=msg):
Reported by Pylint.
Line: 256
Column: 35
filled_val = ser[0]
result = ser.fillna(filled_val)
assert ser._values is not result._values
assert ser._values is arr
def test_fillna_length_mismatch(self, data_missing):
msg = "Length of 'value' does not match."
with pytest.raises(ValueError, match=msg):
Reported by Pylint.
Line: 257
Column: 16
result = ser.fillna(filled_val)
assert ser._values is not result._values
assert ser._values is arr
def test_fillna_length_mismatch(self, data_missing):
msg = "Length of 'value' does not match."
with pytest.raises(ValueError, match=msg):
data_missing.fillna(data_missing.take([1]))
Reported by Pylint.
Line: 289
Column: 17
result = s1.combine(s2, lambda x1, x2: x1 + x2)
with np.errstate(over="ignore"):
expected = pd.Series(
orig_data1._from_sequence(
[a + b for (a, b) in zip(list(orig_data1), list(orig_data2))]
)
)
self.assert_series_equal(result, expected)
Reported by Pylint.
pandas/tests/series/methods/test_replace.py
146 issues
Line: 4
Column: 1
import re
import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
Reported by Pylint.
Line: 1
Column: 1
import re
import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
Reported by Pylint.
Line: 10
Column: 1
import pandas._testing as tm
class TestSeriesReplace:
def test_replace(self, datetime_series):
N = 100
ser = pd.Series(np.random.randn(N))
ser[0:4] = np.nan
ser[6:10] = 0
Reported by Pylint.
Line: 10
Column: 1
import pandas._testing as tm
class TestSeriesReplace:
def test_replace(self, datetime_series):
N = 100
ser = pd.Series(np.random.randn(N))
ser[0:4] = np.nan
ser[6:10] = 0
Reported by Pylint.
Line: 11
Column: 5
class TestSeriesReplace:
def test_replace(self, datetime_series):
N = 100
ser = pd.Series(np.random.randn(N))
ser[0:4] = np.nan
ser[6:10] = 0
Reported by Pylint.
Line: 11
Column: 5
class TestSeriesReplace:
def test_replace(self, datetime_series):
N = 100
ser = pd.Series(np.random.randn(N))
ser[0:4] = np.nan
ser[6:10] = 0
Reported by Pylint.
Line: 12
Column: 9
class TestSeriesReplace:
def test_replace(self, datetime_series):
N = 100
ser = pd.Series(np.random.randn(N))
ser[0:4] = np.nan
ser[6:10] = 0
# replace list with a single value
Reported by Pylint.
Line: 19
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
# replace list with a single value
return_value = ser.replace([np.nan], -1, inplace=True)
assert return_value is None
exp = ser.fillna(-1)
tm.assert_series_equal(ser, exp)
rs = ser.replace(0.0, np.nan)
Reported by Bandit.
Line: 24
Column: 9
exp = ser.fillna(-1)
tm.assert_series_equal(ser, exp)
rs = ser.replace(0.0, np.nan)
ser[ser == 0.0] = np.nan
tm.assert_series_equal(rs, ser)
ser = pd.Series(np.fabs(np.random.randn(N)), tm.makeDateIndex(N), dtype=object)
ser[:5] = np.nan
Reported by Pylint.
Line: 34
Column: 9
ser[20:30] = "bar"
# replace list with a single value
rs = ser.replace([np.nan, "foo", "bar"], -1)
assert (rs[:5] == -1).all()
assert (rs[6:10] == -1).all()
assert (rs[20:30] == -1).all()
assert (pd.isna(ser[:5])).all()
Reported by Pylint.