The following issues were found
pandas/tests/indexes/timedeltas/test_constructors.py
62 issues
Line: 4
Column: 1
from datetime import timedelta
import numpy as np
import pytest
import pandas as pd
from pandas import (
Timedelta,
TimedeltaIndex,
Reported by Pylint.
Line: 57
Column: 31
tdi = timedelta_range("1 second", periods=10 ** 7, freq="1s")
result = TimedeltaIndex(tdi, freq="infer")
assert result.freq == tdi.freq
# check that inferred_freq was not called by checking that the
# value has not been cached
assert "inferred_freq" not in getattr(result, "_cache", {})
Reported by Pylint.
Line: 57
Column: 31
tdi = timedelta_range("1 second", periods=10 ** 7, freq="1s")
result = TimedeltaIndex(tdi, freq="infer")
assert result.freq == tdi.freq
# check that inferred_freq was not called by checking that the
# value has not been cached
assert "inferred_freq" not in getattr(result, "_cache", {})
Reported by Pylint.
Line: 57
Column: 16
tdi = timedelta_range("1 second", periods=10 ** 7, freq="1s")
result = TimedeltaIndex(tdi, freq="infer")
assert result.freq == tdi.freq
# check that inferred_freq was not called by checking that the
# value has not been cached
assert "inferred_freq" not in getattr(result, "_cache", {})
Reported by Pylint.
Line: 94
Column: 28
msg = "cannot be converted to timedelta64"
with pytest.raises(TypeError, match=msg):
TimedeltaIndex(dti.tz_localize("Europe/Brussels"))
with pytest.raises(TypeError, match=msg):
TimedeltaIndex(dti)
with pytest.raises(TypeError, match=msg):
Reported by Pylint.
Line: 94
Column: 28
msg = "cannot be converted to timedelta64"
with pytest.raises(TypeError, match=msg):
TimedeltaIndex(dti.tz_localize("Europe/Brussels"))
with pytest.raises(TypeError, match=msg):
TimedeltaIndex(dti)
with pytest.raises(TypeError, match=msg):
Reported by Pylint.
Line: 258
Column: 16
def test_explicit_none_freq(self):
# Explicitly passing freq=None is respected
tdi = timedelta_range(1, periods=5)
assert tdi.freq is not None
result = TimedeltaIndex(tdi, freq=None)
assert result.freq is None
result = TimedeltaIndex(tdi._data, freq=None)
Reported by Pylint.
Line: 258
Column: 16
def test_explicit_none_freq(self):
# Explicitly passing freq=None is respected
tdi = timedelta_range(1, periods=5)
assert tdi.freq is not None
result = TimedeltaIndex(tdi, freq=None)
assert result.freq is None
result = TimedeltaIndex(tdi._data, freq=None)
Reported by Pylint.
Line: 261
Column: 16
assert tdi.freq is not None
result = TimedeltaIndex(tdi, freq=None)
assert result.freq is None
result = TimedeltaIndex(tdi._data, freq=None)
assert result.freq is None
def test_from_categorical(self):
Reported by Pylint.
Line: 264
Column: 16
assert result.freq is None
result = TimedeltaIndex(tdi._data, freq=None)
assert result.freq is None
def test_from_categorical(self):
tdi = timedelta_range(1, periods=5)
cat = pd.Categorical(tdi)
Reported by Pylint.
pandas/core/api.py
62 issues
Line: 9
Column: 1
Timedelta,
Timestamp,
)
from pandas._libs.missing import NA
from pandas.core.dtypes.dtypes import (
CategoricalDtype,
DatetimeTZDtype,
IntervalDtype,
Reported by Pylint.
Line: 9
Column: 1
Timedelta,
Timestamp,
)
from pandas._libs.missing import NA
from pandas.core.dtypes.dtypes import (
CategoricalDtype,
DatetimeTZDtype,
IntervalDtype,
Reported by Pylint.
Line: 3
Column: 1
# flake8: noqa
from pandas._libs import (
NaT,
Period,
Timedelta,
Timestamp,
)
from pandas._libs.missing import NA
Reported by Pylint.
Line: 3
Column: 1
# flake8: noqa
from pandas._libs import (
NaT,
Period,
Timedelta,
Timestamp,
)
from pandas._libs.missing import NA
Reported by Pylint.
Line: 3
Column: 1
# flake8: noqa
from pandas._libs import (
NaT,
Period,
Timedelta,
Timestamp,
)
from pandas._libs.missing import NA
Reported by Pylint.
Line: 3
Column: 1
# flake8: noqa
from pandas._libs import (
NaT,
Period,
Timedelta,
Timestamp,
)
from pandas._libs.missing import NA
Reported by Pylint.
Line: 9
Column: 1
Timedelta,
Timestamp,
)
from pandas._libs.missing import NA
from pandas.core.dtypes.dtypes import (
CategoricalDtype,
DatetimeTZDtype,
IntervalDtype,
Reported by Pylint.
Line: 11
Column: 1
)
from pandas._libs.missing import NA
from pandas.core.dtypes.dtypes import (
CategoricalDtype,
DatetimeTZDtype,
IntervalDtype,
PeriodDtype,
)
Reported by Pylint.
Line: 11
Column: 1
)
from pandas._libs.missing import NA
from pandas.core.dtypes.dtypes import (
CategoricalDtype,
DatetimeTZDtype,
IntervalDtype,
PeriodDtype,
)
Reported by Pylint.
Line: 11
Column: 1
)
from pandas._libs.missing import NA
from pandas.core.dtypes.dtypes import (
CategoricalDtype,
DatetimeTZDtype,
IntervalDtype,
PeriodDtype,
)
Reported by Pylint.
pandas/tests/io/formats/style/test_highlight.py
62 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas import (
NA,
DataFrame,
IndexSlice,
)
Reported by Pylint.
Line: 21
Column: 12
@pytest.fixture
def styler(df):
return Styler(df, uuid_len=0)
def test_highlight_null(styler):
result = styler.highlight_null()._compute().ctx
Reported by Pylint.
Line: 25
Column: 25
return Styler(df, uuid_len=0)
def test_highlight_null(styler):
result = styler.highlight_null()._compute().ctx
expected = {
(1, 0): [("background-color", "red")],
(1, 1): [("background-color", "red")],
}
Reported by Pylint.
Line: 26
Column: 14
def test_highlight_null(styler):
result = styler.highlight_null()._compute().ctx
expected = {
(1, 0): [("background-color", "red")],
(1, 1): [("background-color", "red")],
}
assert result == expected
Reported by Pylint.
Line: 34
Column: 32
assert result == expected
def test_highlight_null_subset(styler):
# GH 31345
result = (
styler.highlight_null(null_color="red", subset=["A"])
.highlight_null(null_color="green", subset=["B"])
._compute()
Reported by Pylint.
Line: 37
Column: 9
def test_highlight_null_subset(styler):
# GH 31345
result = (
styler.highlight_null(null_color="red", subset=["A"])
.highlight_null(null_color="green", subset=["B"])
._compute()
.ctx
)
expected = {
Reported by Pylint.
Line: 50
Column: 33
@pytest.mark.parametrize("f", ["highlight_min", "highlight_max"])
def test_highlight_minmax_basic(df, f):
expected = {
(0, 1): [("background-color", "red")],
# ignores NaN row,
(2, 0): [("background-color", "red")],
}
Reported by Pylint.
Line: 58
Column: 14
}
if f == "highlight_min":
df = -df
result = getattr(df.style, f)(axis=1, color="red")._compute().ctx
assert result == expected
@pytest.mark.parametrize("f", ["highlight_min", "highlight_max"])
@pytest.mark.parametrize(
Reported by Pylint.
Line: 71
Column: 31
{"axis": None, "props": "background-color: red"}, # test props
],
)
def test_highlight_minmax_ext(df, f, kwargs):
expected = {(2, 0): [("background-color", "red")]}
if f == "highlight_min":
df = -df
result = getattr(df.style, f)(**kwargs)._compute().ctx
assert result == expected
Reported by Pylint.
Line: 75
Column: 14
expected = {(2, 0): [("background-color", "red")]}
if f == "highlight_min":
df = -df
result = getattr(df.style, f)(**kwargs)._compute().ctx
assert result == expected
@pytest.mark.parametrize("f", ["highlight_min", "highlight_max"])
@pytest.mark.parametrize("axis", [None, 0, 1])
Reported by Pylint.
pandas/tests/arrays/categorical/test_analytics.py
62 issues
Line: 5
Column: 1
import sys
import numpy as np
import pytest
from pandas.compat import PYPY
from pandas import (
Categorical,
Reported by Pylint.
Line: 1
Column: 1
import re
import sys
import numpy as np
import pytest
from pandas.compat import PYPY
from pandas import (
Reported by Pylint.
Line: 21
Column: 1
from pandas.api.types import is_scalar
class TestCategoricalAnalytics:
@pytest.mark.parametrize("aggregation", ["min", "max"])
def test_min_max_not_ordered_raises(self, aggregation):
# unordered cats have no min/max
cat = Categorical(["a", "b", "c", "d"], ordered=False)
msg = f"Categorical is not ordered for operation {aggregation}"
Reported by Pylint.
Line: 23
Column: 5
class TestCategoricalAnalytics:
@pytest.mark.parametrize("aggregation", ["min", "max"])
def test_min_max_not_ordered_raises(self, aggregation):
# unordered cats have no min/max
cat = Categorical(["a", "b", "c", "d"], ordered=False)
msg = f"Categorical is not ordered for operation {aggregation}"
agg_func = getattr(cat, aggregation)
Reported by Pylint.
Line: 23
Column: 5
class TestCategoricalAnalytics:
@pytest.mark.parametrize("aggregation", ["min", "max"])
def test_min_max_not_ordered_raises(self, aggregation):
# unordered cats have no min/max
cat = Categorical(["a", "b", "c", "d"], ordered=False)
msg = f"Categorical is not ordered for operation {aggregation}"
agg_func = getattr(cat, aggregation)
Reported by Pylint.
Line: 32
Column: 5
with pytest.raises(TypeError, match=msg):
agg_func()
def test_min_max_ordered(self):
cat = Categorical(["a", "b", "c", "d"], ordered=True)
_min = cat.min()
_max = cat.max()
assert _min == "a"
assert _max == "d"
Reported by Pylint.
Line: 32
Column: 5
with pytest.raises(TypeError, match=msg):
agg_func()
def test_min_max_ordered(self):
cat = Categorical(["a", "b", "c", "d"], ordered=True)
_min = cat.min()
_max = cat.max()
assert _min == "a"
assert _max == "d"
Reported by Pylint.
Line: 36
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
cat = Categorical(["a", "b", "c", "d"], ordered=True)
_min = cat.min()
_max = cat.max()
assert _min == "a"
assert _max == "d"
cat = Categorical(
["a", "b", "c", "d"], categories=["d", "c", "b", "a"], ordered=True
)
Reported by Bandit.
Line: 37
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
_min = cat.min()
_max = cat.max()
assert _min == "a"
assert _max == "d"
cat = Categorical(
["a", "b", "c", "d"], categories=["d", "c", "b", "a"], ordered=True
)
_min = cat.min()
Reported by Bandit.
Line: 44
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
)
_min = cat.min()
_max = cat.max()
assert _min == "d"
assert _max == "a"
@pytest.mark.parametrize(
"categories,expected",
[
Reported by Bandit.
pandas/tests/io/formats/style/test_deprecated.py
62 issues
Line: 5
Column: 1
modules collects tests for Styler methods which have been deprecated
"""
import numpy as np
import pytest
jinja2 = pytest.importorskip("jinja2")
from pandas import (
DataFrame,
Reported by Pylint.
Line: 25
Column: 5
def test_set_non_numeric_na():
# GH 21527 28358
df = DataFrame(
{
"object": [None, np.nan, "foo"],
"datetime": [None, NaT, Timestamp("20120101")],
}
)
Reported by Pylint.
Line: 33
Column: 15
)
with tm.assert_produces_warning(FutureWarning):
ctx = df.style.set_na_rep("NA")._translate(True, True)
assert ctx["body"][0][1]["display_value"] == "NA"
assert ctx["body"][0][2]["display_value"] == "NA"
assert ctx["body"][1][1]["display_value"] == "NA"
assert ctx["body"][1][2]["display_value"] == "NA"
Reported by Pylint.
Line: 40
Column: 31
assert ctx["body"][1][2]["display_value"] == "NA"
def test_where_with_one_style(df):
# GH 17474
def f(x):
return x > 0.5
style1 = "foo: bar"
Reported by Pylint.
Line: 48
Column: 18
style1 = "foo: bar"
with tm.assert_produces_warning(FutureWarning):
result = df.style.where(f, style1)._compute().ctx
expected = {
(r, c): [("foo", "bar")]
for r, row in enumerate(df.index)
for c, col in enumerate(df.columns)
if f(df.loc[row, col])
Reported by Pylint.
Line: 68
Column: 23
IndexSlice[:2, ["A", "B"]],
],
)
def test_where_subset(df, slice_):
# GH 17474
def f(x):
return x > 0.5
style1 = "foo: bar"
Reported by Pylint.
Line: 77
Column: 15
style2 = "baz: foo"
with tm.assert_produces_warning(FutureWarning):
res = df.style.where(f, style1, style2, subset=slice_)._compute().ctx
expected = {
(r, c): [("foo", "bar") if f(df.loc[row, col]) else ("baz", "foo")]
for r, row in enumerate(df.index)
for c, col in enumerate(df.columns)
if row in df.loc[slice_].index and col in df.loc[slice_].columns
Reported by Pylint.
Line: 87
Column: 45
assert res == expected
def test_where_subset_compare_with_applymap(df):
# GH 17474
def f(x):
return x > 0.5
style1 = "foo: bar"
Reported by Pylint.
Line: 108
Column: 22
for slice_ in slices:
with tm.assert_produces_warning(FutureWarning):
result = df.style.where(f, style1, style2, subset=slice_)._compute().ctx
expected = df.style.applymap(g, subset=slice_)._compute().ctx
assert result == expected
def test_where_kwargs():
Reported by Pylint.
Line: 109
Column: 20
for slice_ in slices:
with tm.assert_produces_warning(FutureWarning):
result = df.style.where(f, style1, style2, subset=slice_)._compute().ctx
expected = df.style.applymap(g, subset=slice_)._compute().ctx
assert result == expected
def test_where_kwargs():
df = DataFrame([[1, 2], [3, 4]])
Reported by Pylint.
pandas/tests/series/methods/test_reindex.py
61 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas import (
Categorical,
Index,
MultiIndex,
NaT,
Period,
Reported by Pylint.
Line: 87
Column: 22
result = ts.reindex(list(ts.index[5:10]))
expected = ts[5:10]
expected.index = expected.index._with_freq(None)
tm.assert_series_equal(result, expected)
result = ts[list(ts.index[5:10])]
tm.assert_series_equal(result, expected)
Reported by Pylint.
Line: 104
Column: 29
# pass non-Index
reindexed = datetime_series.reindex(list(datetime_series.index))
datetime_series.index = datetime_series.index._with_freq(None)
tm.assert_series_equal(datetime_series, reindexed)
# bad fill method
ts = datetime_series[::2]
msg = (
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas import (
Categorical,
Index,
MultiIndex,
NaT,
Period,
Reported by Pylint.
Line: 18
Column: 1
import pandas._testing as tm
def test_reindex(datetime_series, string_series):
identity = string_series.reindex(string_series.index)
# __array_interface__ is not defined for older numpies
# and on some pythons
try:
Reported by Pylint.
Line: 24
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
# __array_interface__ is not defined for older numpies
# and on some pythons
try:
assert np.may_share_memory(string_series.index, identity.index)
except AttributeError:
pass
assert identity.index.is_(string_series.index)
assert identity.index.identical(string_series.index)
Reported by Bandit.
Line: 28
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
except AttributeError:
pass
assert identity.index.is_(string_series.index)
assert identity.index.identical(string_series.index)
subIndex = string_series.index[10:20]
subSeries = string_series.reindex(subIndex)
Reported by Bandit.
Line: 29
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
pass
assert identity.index.is_(string_series.index)
assert identity.index.identical(string_series.index)
subIndex = string_series.index[10:20]
subSeries = string_series.reindex(subIndex)
for idx, val in subSeries.items():
Reported by Bandit.
Line: 31
Column: 5
assert identity.index.is_(string_series.index)
assert identity.index.identical(string_series.index)
subIndex = string_series.index[10:20]
subSeries = string_series.reindex(subIndex)
for idx, val in subSeries.items():
assert val == string_series[idx]
Reported by Pylint.
Line: 32
Column: 5
assert identity.index.identical(string_series.index)
subIndex = string_series.index[10:20]
subSeries = string_series.reindex(subIndex)
for idx, val in subSeries.items():
assert val == string_series[idx]
subIndex2 = datetime_series.index[10:20]
Reported by Pylint.
pandas/tests/generic/test_frame.py
61 issues
Line: 5
Column: 1
from operator import methodcaller
import numpy as np
import pytest
import pandas as pd
from pandas import (
DataFrame,
MultiIndex,
Reported by Pylint.
Line: 125
Column: 9
df1 = DataFrame(np.random.randint(0, 4, (3, 2)), columns=list("ab"))
df1.filename = "foo"
def finalize(self, other, method=None, **kwargs):
for name in self._metadata:
if method == "concat":
value = "+".join(
[getattr(o, name) for o in other.objs if getattr(o, name, None)]
)
Reported by Pylint.
Line: 175
Column: 13
msg = 'For argument "inplace" expected type bool, received type'
with pytest.raises(ValueError, match=msg):
super(DataFrame, df).rename_axis(
mapper={"a": "x", "b": "y"}, axis=1, inplace=value
)
with pytest.raises(ValueError, match=msg):
super(DataFrame, df).drop("a", axis=1, inplace=value)
Reported by Pylint.
Line: 180
Column: 13
)
with pytest.raises(ValueError, match=msg):
super(DataFrame, df).drop("a", axis=1, inplace=value)
with pytest.raises(ValueError, match=msg):
super(DataFrame, df).fillna(value=0, inplace=value)
with pytest.raises(ValueError, match=msg):
Reported by Pylint.
Line: 183
Column: 13
super(DataFrame, df).drop("a", axis=1, inplace=value)
with pytest.raises(ValueError, match=msg):
super(DataFrame, df).fillna(value=0, inplace=value)
with pytest.raises(ValueError, match=msg):
super(DataFrame, df).replace(to_replace=1, value=7, inplace=value)
with pytest.raises(ValueError, match=msg):
Reported by Pylint.
Line: 186
Column: 13
super(DataFrame, df).fillna(value=0, inplace=value)
with pytest.raises(ValueError, match=msg):
super(DataFrame, df).replace(to_replace=1, value=7, inplace=value)
with pytest.raises(ValueError, match=msg):
super(DataFrame, df).interpolate(inplace=value)
with pytest.raises(ValueError, match=msg):
Reported by Pylint.
Line: 189
Column: 13
super(DataFrame, df).replace(to_replace=1, value=7, inplace=value)
with pytest.raises(ValueError, match=msg):
super(DataFrame, df).interpolate(inplace=value)
with pytest.raises(ValueError, match=msg):
super(DataFrame, df)._where(cond=df.a > 2, inplace=value)
with pytest.raises(ValueError, match=msg):
Reported by Pylint.
Line: 192
Column: 13
super(DataFrame, df).interpolate(inplace=value)
with pytest.raises(ValueError, match=msg):
super(DataFrame, df)._where(cond=df.a > 2, inplace=value)
with pytest.raises(ValueError, match=msg):
super(DataFrame, df).mask(cond=df.a > 2, inplace=value)
def test_unexpected_keyword(self):
Reported by Pylint.
Line: 195
Column: 13
super(DataFrame, df)._where(cond=df.a > 2, inplace=value)
with pytest.raises(ValueError, match=msg):
super(DataFrame, df).mask(cond=df.a > 2, inplace=value)
def test_unexpected_keyword(self):
# GH8597
df = DataFrame(np.random.randn(5, 2), columns=["jim", "joe"])
ca = pd.Categorical([0, 0, 2, 2, 3, np.nan])
Reported by Pylint.
Line: 206
Column: 13
msg = "unexpected keyword"
with pytest.raises(TypeError, match=msg):
df.drop("joe", axis=1, in_place=True)
with pytest.raises(TypeError, match=msg):
df.reindex([1, 0], inplace=True)
with pytest.raises(TypeError, match=msg):
Reported by Pylint.
pandas/tests/series/methods/test_append.py
61 issues
Line: 2
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas import (
DataFrame,
DatetimeIndex,
Index,
Series,
Reported by Pylint.
Line: 133
Column: 9
def test_append_tz_explicit_pytz(self):
# see gh-2938
from pytz import timezone as timezone
rng = date_range(
"5/8/2012 1:45", periods=10, freq="5T", tz=timezone("US/Eastern")
)
rng2 = date_range(
Reported by Pylint.
Line: 193
Column: 38
)
exp = Series([1, 2], index=exp_index)
tm.assert_series_equal(ts_result, exp)
assert ts_result.index.tz == rng1.tz
rng1 = date_range("1/1/2011 01:00", periods=1, freq="H", tz="UTC")
rng2 = date_range("1/1/2011 02:00", periods=1, freq="H", tz="UTC")
ser1 = Series([1], index=rng1)
ser2 = Series([2], index=rng2)
Reported by Pylint.
Line: 193
Column: 38
)
exp = Series([1, 2], index=exp_index)
tm.assert_series_equal(ts_result, exp)
assert ts_result.index.tz == rng1.tz
rng1 = date_range("1/1/2011 01:00", periods=1, freq="H", tz="UTC")
rng2 = date_range("1/1/2011 02:00", periods=1, freq="H", tz="UTC")
ser1 = Series([1], index=rng1)
ser2 = Series([2], index=rng2)
Reported by Pylint.
Line: 206
Column: 15
)
exp = Series([1, 2], index=exp_index)
tm.assert_series_equal(ts_result, exp)
utc = rng1.tz
assert utc == ts_result.index.tz
# GH#7795
# different tz coerces to object dtype, not UTC
rng1 = date_range("1/1/2011 01:00", periods=1, freq="H", tz="US/Eastern")
Reported by Pylint.
Line: 206
Column: 15
)
exp = Series([1, 2], index=exp_index)
tm.assert_series_equal(ts_result, exp)
utc = rng1.tz
assert utc == ts_result.index.tz
# GH#7795
# different tz coerces to object dtype, not UTC
rng1 = date_range("1/1/2011 01:00", periods=1, freq="H", tz="US/Eastern")
Reported by Pylint.
Line: 265
Column: 38
)
exp = Series([1, 2, 3, 10, 11, 12], index=exp_index)
tm.assert_series_equal(ts_result, exp)
assert ts_result.index.tz == rng1.tz
Reported by Pylint.
Line: 265
Column: 38
)
exp = Series([1, 2, 3, 10, 11, 12], index=exp_index)
tm.assert_series_equal(ts_result, exp)
assert ts_result.index.tz == rng1.tz
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas import (
DataFrame,
DatetimeIndex,
Index,
Series,
Reported by Pylint.
Line: 16
Column: 1
import pandas._testing as tm
class TestSeriesAppend:
def test_append_preserve_name(self, datetime_series):
result = datetime_series[:5].append(datetime_series[5:])
assert result.name == datetime_series.name
def test_append(self, datetime_series, string_series, object_series):
Reported by Pylint.
pandas/tests/io/excel/test_openpyxl.py
61 issues
Line: 5
Column: 1
import re
import numpy as np
import pytest
import pandas as pd
from pandas import DataFrame
import pandas._testing as tm
Reported by Pylint.
Line: 22
Column: 5
def test_to_excel_styleconverter(ext):
from openpyxl import styles
hstyle = {
"font": {"color": "00FF0000", "bold": True},
"borders": {"top": "thin", "right": "thin", "bottom": "thin", "left": "thin"},
"alignment": {"horizontal": "center", "vertical": "top"},
Reported by Pylint.
Line: 96
Column: 18
with tm.ensure_clean(ext) as f:
msg = re.escape("Use of **kwargs is deprecated")
with tm.assert_produces_warning(FutureWarning, match=msg):
with ExcelWriter(f, engine="openpyxl", **kwargs) as writer:
# ExcelWriter won't allow us to close without writing something
DataFrame().to_excel(writer)
@pytest.mark.parametrize("write_only", [True, False])
Reported by Pylint.
Line: 107
Column: 14
# openpyxl doesn't utilize kwargs, only test that supplying a engine_kwarg works
engine_kwargs = {"write_only": write_only}
with tm.ensure_clean(ext) as f:
with ExcelWriter(f, engine="openpyxl", engine_kwargs=engine_kwargs) as writer:
# ExcelWriter won't allow us to close without writing something
DataFrame().to_excel(writer)
@pytest.mark.parametrize(
Reported by Pylint.
Line: 126
Column: 14
wb.worksheets[1]["A1"].value = "bar"
wb.save(f)
with ExcelWriter(f, engine="openpyxl", mode=mode) as writer:
df.to_excel(writer, sheet_name="baz", index=False)
wb2 = openpyxl.load_workbook(f)
result = [sheet.title for sheet in wb2.worksheets]
assert result == expected
Reported by Pylint.
Line: 151
Column: 14
with tm.ensure_clean(ext) as f:
df1.to_excel(f, engine="openpyxl", sheet_name="foo", index=False)
with ExcelWriter(
f, engine="openpyxl", mode="a", if_sheet_exists=if_sheet_exists
) as writer:
df2.to_excel(writer, sheet_name="foo", index=False)
wb = openpyxl.load_workbook(f)
Reported by Pylint.
Line: 191
Column: 18
with tm.ensure_clean(ext) as f:
with pytest.raises(ValueError, match=re.escape(msg)):
df.to_excel(f, "foo", engine="openpyxl")
with ExcelWriter(
f, engine="openpyxl", mode="a", if_sheet_exists=if_sheet_exists
) as writer:
df.to_excel(writer, sheet_name="foo")
Reported by Pylint.
Line: 263
Column: 14
with tm.ensure_clean(ext) as f:
df.to_excel(f, engine="openpyxl")
with ExcelWriter(
f, mode="a", engine="openpyxl", if_sheet_exists="new"
) as writer:
df.to_excel(writer)
# make sure that zip files are not concatenated by making sure that
Reported by Pylint.
Line: 21
Column: 34
pytestmark = pytest.mark.parametrize("ext", [".xlsx"])
def test_to_excel_styleconverter(ext):
from openpyxl import styles
hstyle = {
"font": {"color": "00FF0000", "bold": True},
"borders": {"top": "thin", "right": "thin", "bottom": "thin", "left": "thin"},
Reported by Pylint.
Line: 45
Column: 10
protection = styles.Protection(locked=True, hidden=False)
kw = _OpenpyxlWriter._convert_to_style_kwargs(hstyle)
assert kw["font"] == font
assert kw["border"] == border
assert kw["alignment"] == alignment
assert kw["fill"] == fill
assert kw["number_format"] == number_format
Reported by Pylint.
pandas/tests/frame/methods/test_between_time.py
61 issues
Line: 7
Column: 1
)
import numpy as np
import pytest
from pandas._libs.tslibs import timezones
import pandas.util._test_decorators as td
from pandas import (
Reported by Pylint.
Line: 9
Column: 1
import numpy as np
import pytest
from pandas._libs.tslibs import timezones
import pandas.util._test_decorators as td
from pandas import (
DataFrame,
Series,
Reported by Pylint.
Line: 1
Column: 1
from datetime import (
datetime,
time,
)
import numpy as np
import pytest
from pandas._libs.tslibs import timezones
Reported by Pylint.
Line: 20
Column: 1
import pandas._testing as tm
class TestBetweenTime:
@td.skip_if_has_locale
def test_between_time_formats(self, frame_or_series):
# GH#11818
rng = date_range("1/1/2000", "1/5/2000", freq="5min")
ts = DataFrame(np.random.randn(len(rng), 2), index=rng)
Reported by Pylint.
Line: 22
Column: 5
class TestBetweenTime:
@td.skip_if_has_locale
def test_between_time_formats(self, frame_or_series):
# GH#11818
rng = date_range("1/1/2000", "1/5/2000", freq="5min")
ts = DataFrame(np.random.randn(len(rng), 2), index=rng)
if frame_or_series is Series:
ts = ts[0]
Reported by Pylint.
Line: 22
Column: 5
class TestBetweenTime:
@td.skip_if_has_locale
def test_between_time_formats(self, frame_or_series):
# GH#11818
rng = date_range("1/1/2000", "1/5/2000", freq="5min")
ts = DataFrame(np.random.randn(len(rng), 2), index=rng)
if frame_or_series is Series:
ts = ts[0]
Reported by Pylint.
Line: 25
Column: 9
def test_between_time_formats(self, frame_or_series):
# GH#11818
rng = date_range("1/1/2000", "1/5/2000", freq="5min")
ts = DataFrame(np.random.randn(len(rng), 2), index=rng)
if frame_or_series is Series:
ts = ts[0]
strings = [
("2:00", "2:30"),
Reported by Pylint.
Line: 27
Column: 13
rng = date_range("1/1/2000", "1/5/2000", freq="5min")
ts = DataFrame(np.random.randn(len(rng), 2), index=rng)
if frame_or_series is Series:
ts = ts[0]
strings = [
("2:00", "2:30"),
("0200", "0230"),
("2:00am", "2:30am"),
Reported by Pylint.
Line: 42
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
expected_length = 28
for time_string in strings:
assert len(ts.between_time(*time_string)) == expected_length
@pytest.mark.parametrize("tzstr", ["US/Eastern", "dateutil/US/Eastern"])
def test_localized_between_time(self, tzstr, frame_or_series):
tz = timezones.maybe_get_tz(tzstr)
Reported by Bandit.
Line: 45
Column: 5
assert len(ts.between_time(*time_string)) == expected_length
@pytest.mark.parametrize("tzstr", ["US/Eastern", "dateutil/US/Eastern"])
def test_localized_between_time(self, tzstr, frame_or_series):
tz = timezones.maybe_get_tz(tzstr)
rng = date_range("4/16/2012", "5/1/2012", freq="H")
ts = Series(np.random.randn(len(rng)), index=rng)
if frame_or_series is DataFrame:
Reported by Pylint.