The following issues were found
pandas/tests/frame/methods/test_swapaxes.py
12 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas import DataFrame
import pandas._testing as tm
class TestSwapAxes:
def test_swapaxes(self):
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas import DataFrame
import pandas._testing as tm
class TestSwapAxes:
def test_swapaxes(self):
Reported by Pylint.
Line: 8
Column: 1
import pandas._testing as tm
class TestSwapAxes:
def test_swapaxes(self):
df = DataFrame(np.random.randn(10, 5))
tm.assert_frame_equal(df.T, df.swapaxes(0, 1))
tm.assert_frame_equal(df.T, df.swapaxes(1, 0))
Reported by Pylint.
Line: 9
Column: 5
class TestSwapAxes:
def test_swapaxes(self):
df = DataFrame(np.random.randn(10, 5))
tm.assert_frame_equal(df.T, df.swapaxes(0, 1))
tm.assert_frame_equal(df.T, df.swapaxes(1, 0))
def test_swapaxes_noop(self):
Reported by Pylint.
Line: 9
Column: 5
class TestSwapAxes:
def test_swapaxes(self):
df = DataFrame(np.random.randn(10, 5))
tm.assert_frame_equal(df.T, df.swapaxes(0, 1))
tm.assert_frame_equal(df.T, df.swapaxes(1, 0))
def test_swapaxes_noop(self):
Reported by Pylint.
Line: 10
Column: 9
class TestSwapAxes:
def test_swapaxes(self):
df = DataFrame(np.random.randn(10, 5))
tm.assert_frame_equal(df.T, df.swapaxes(0, 1))
tm.assert_frame_equal(df.T, df.swapaxes(1, 0))
def test_swapaxes_noop(self):
df = DataFrame(np.random.randn(10, 5))
Reported by Pylint.
Line: 14
Column: 5
tm.assert_frame_equal(df.T, df.swapaxes(0, 1))
tm.assert_frame_equal(df.T, df.swapaxes(1, 0))
def test_swapaxes_noop(self):
df = DataFrame(np.random.randn(10, 5))
tm.assert_frame_equal(df, df.swapaxes(0, 0))
def test_swapaxes_invalid_axis(self):
df = DataFrame(np.random.randn(10, 5))
Reported by Pylint.
Line: 14
Column: 5
tm.assert_frame_equal(df.T, df.swapaxes(0, 1))
tm.assert_frame_equal(df.T, df.swapaxes(1, 0))
def test_swapaxes_noop(self):
df = DataFrame(np.random.randn(10, 5))
tm.assert_frame_equal(df, df.swapaxes(0, 0))
def test_swapaxes_invalid_axis(self):
df = DataFrame(np.random.randn(10, 5))
Reported by Pylint.
Line: 15
Column: 9
tm.assert_frame_equal(df.T, df.swapaxes(1, 0))
def test_swapaxes_noop(self):
df = DataFrame(np.random.randn(10, 5))
tm.assert_frame_equal(df, df.swapaxes(0, 0))
def test_swapaxes_invalid_axis(self):
df = DataFrame(np.random.randn(10, 5))
msg = "No axis named 2 for object type DataFrame"
Reported by Pylint.
Line: 18
Column: 5
df = DataFrame(np.random.randn(10, 5))
tm.assert_frame_equal(df, df.swapaxes(0, 0))
def test_swapaxes_invalid_axis(self):
df = DataFrame(np.random.randn(10, 5))
msg = "No axis named 2 for object type DataFrame"
with pytest.raises(ValueError, match=msg):
df.swapaxes(2, 5)
Reported by Pylint.
pandas/tests/frame/methods/test_pipe.py
12 issues
Line: 1
Column: 1
import pytest
from pandas import (
DataFrame,
Series,
)
import pandas._testing as tm
Reported by Pylint.
Line: 1
Column: 1
import pytest
from pandas import (
DataFrame,
Series,
)
import pandas._testing as tm
Reported by Pylint.
Line: 10
Column: 1
import pandas._testing as tm
class TestPipe:
def test_pipe(self, frame_or_series):
obj = DataFrame({"A": [1, 2, 3]})
expected = DataFrame({"A": [1, 4, 9]})
if frame_or_series is Series:
obj = obj["A"]
Reported by Pylint.
Line: 11
Column: 5
class TestPipe:
def test_pipe(self, frame_or_series):
obj = DataFrame({"A": [1, 2, 3]})
expected = DataFrame({"A": [1, 4, 9]})
if frame_or_series is Series:
obj = obj["A"]
expected = expected["A"]
Reported by Pylint.
Line: 11
Column: 5
class TestPipe:
def test_pipe(self, frame_or_series):
obj = DataFrame({"A": [1, 2, 3]})
expected = DataFrame({"A": [1, 4, 9]})
if frame_or_series is Series:
obj = obj["A"]
expected = expected["A"]
Reported by Pylint.
Line: 18
Column: 9
obj = obj["A"]
expected = expected["A"]
f = lambda x, y: x ** y
result = obj.pipe(f, 2)
tm.assert_equal(result, expected)
def test_pipe_tuple(self, frame_or_series):
obj = DataFrame({"A": [1, 2, 3]})
Reported by Pylint.
Line: 22
Column: 5
result = obj.pipe(f, 2)
tm.assert_equal(result, expected)
def test_pipe_tuple(self, frame_or_series):
obj = DataFrame({"A": [1, 2, 3]})
if frame_or_series is Series:
obj = obj["A"]
f = lambda x, y: y
Reported by Pylint.
Line: 22
Column: 5
result = obj.pipe(f, 2)
tm.assert_equal(result, expected)
def test_pipe_tuple(self, frame_or_series):
obj = DataFrame({"A": [1, 2, 3]})
if frame_or_series is Series:
obj = obj["A"]
f = lambda x, y: y
Reported by Pylint.
Line: 27
Column: 9
if frame_or_series is Series:
obj = obj["A"]
f = lambda x, y: y
result = obj.pipe((f, "y"), 0)
tm.assert_equal(result, obj)
def test_pipe_tuple_error(self, frame_or_series):
obj = DataFrame({"A": [1, 2, 3]})
Reported by Pylint.
Line: 31
Column: 5
result = obj.pipe((f, "y"), 0)
tm.assert_equal(result, obj)
def test_pipe_tuple_error(self, frame_or_series):
obj = DataFrame({"A": [1, 2, 3]})
if frame_or_series is Series:
obj = obj["A"]
f = lambda x, y: y
Reported by Pylint.
pandas/tests/groupby/test_pipe.py
11 issues
Line: 15
Column: 20
# Test the pipe method of DataFrameGroupBy.
# Issue #17871
random_state = np.random.RandomState(1234567890)
df = DataFrame(
{
"A": ["foo", "bar", "foo", "bar", "foo", "bar", "foo", "foo"],
"B": random_state.randn(8),
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pandas as pd
from pandas import (
DataFrame,
Index,
)
import pandas._testing as tm
Reported by Pylint.
Line: 11
Column: 1
import pandas._testing as tm
def test_pipe():
# Test the pipe method of DataFrameGroupBy.
# Issue #17871
random_state = np.random.RandomState(1234567890)
Reported by Pylint.
Line: 17
Column: 5
random_state = np.random.RandomState(1234567890)
df = DataFrame(
{
"A": ["foo", "bar", "foo", "bar", "foo", "bar", "foo", "foo"],
"B": random_state.randn(8),
"C": random_state.randn(8),
}
Reported by Pylint.
Line: 25
Column: 5
}
)
def f(dfgb):
return dfgb.B.max() - dfgb.C.min().min()
def square(srs):
return srs ** 2
Reported by Pylint.
Line: 44
Column: 1
tm.assert_series_equal(expected, result)
def test_pipe_args():
# Test passing args to the pipe method of DataFrameGroupBy.
# Issue #17871
df = DataFrame(
{
Reported by Pylint.
Line: 48
Column: 5
# Test passing args to the pipe method of DataFrameGroupBy.
# Issue #17871
df = DataFrame(
{
"group": ["A", "A", "B", "B", "C"],
"x": [1.0, 2.0, 3.0, 2.0, 5.0],
"y": [10.0, 100.0, 1000.0, -100.0, -1000.0],
}
Reported by Pylint.
Line: 56
Column: 5
}
)
def f(dfgb, arg1):
return dfgb.filter(lambda grp: grp.y.mean() > arg1, dropna=False).groupby(
dfgb.grouper
)
def g(dfgb, arg2):
Reported by Pylint.
Line: 61
Column: 5
dfgb.grouper
)
def g(dfgb, arg2):
return dfgb.sum() / dfgb.sum().sum() + arg2
def h(df, arg3):
return df.x + df.y - arg3
Reported by Pylint.
Line: 64
Column: 5
def g(dfgb, arg2):
return dfgb.sum() / dfgb.sum().sum() + arg2
def h(df, arg3):
return df.x + df.y - arg3
result = df.groupby("group").pipe(f, 0).pipe(g, 10).pipe(h, 100)
# Assert the results here
Reported by Pylint.
pandas/io/formats/css.py
11 issues
Line: 198
Column: 3
for prop in [f"margin-{side}", f"padding-{side}"]:
if prop in props:
# TODO: support %
props[prop] = self.size_to_pt(
props[prop],
em_pt=font_size,
conversions=self.MARGIN_RATIOS,
)
Reported by Pylint.
Line: 206
Column: 5
)
return props
def size_to_pt(self, in_val, em_pt=None, conversions=UNIT_RATIOS):
def _error():
warnings.warn(f"Unhandled size: {repr(in_val)}", CSSWarning)
return self.size_to_pt("1!!default", conversions=conversions)
match = re.match(r"^(\S*?)([a-zA-Z%!].*)", in_val)
Reported by Pylint.
Line: 255
Column: 17
except AttributeError:
yield prop, value
else:
for prop, value in expand(prop, value):
yield prop, value
expand_border_color = _side_expander("border-{:s}-color")
expand_border_style = _side_expander("border-{:s}-style")
expand_border_width = _side_expander("border-{:s}-width")
Reported by Pylint.
Line: 255
Column: 17
except AttributeError:
yield prop, value
else:
for prop, value in expand(prop, value):
yield prop, value
expand_border_color = _side_expander("border-{:s}-color")
expand_border_style = _side_expander("border-{:s}-style")
expand_border_width = _side_expander("border-{:s}-width")
Reported by Pylint.
Line: 279
Column: 3
continue
prop, sep, val = decl.partition(":")
prop = prop.strip().lower()
# TODO: don't lowercase case sensitive parts of values (strings)
val = val.strip().lower()
if sep:
yield prop, val
else:
warnings.warn(
Reported by Pylint.
Line: 138
Column: 5
props = self._update_font_size(props, inherited)
return self._update_other_units(props)
def _update_initial(
self,
props: dict[str, str],
inherited: dict[str, str],
) -> dict[str, str]:
# 1. resolve inherited, initial
Reported by Pylint.
Line: 180
Column: 5
return self._get_float_font_size_from_pt(font_size_string)
return None
def _get_float_font_size_from_pt(self, font_size_string: str) -> float:
assert font_size_string.endswith("pt")
return float(font_size_string.rstrip("pt"))
def _update_other_units(self, props: dict[str, str]) -> dict[str, str]:
font_size = self._get_font_size(props)
Reported by Pylint.
Line: 181
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
return None
def _get_float_font_size_from_pt(self, font_size_string: str) -> float:
assert font_size_string.endswith("pt")
return float(font_size_string.rstrip("pt"))
def _update_other_units(self, props: dict[str, str]) -> dict[str, str]:
font_size = self._get_font_size(props)
# 3. TODO: resolve other font-relative units
Reported by Bandit.
Line: 206
Column: 5
)
return props
def size_to_pt(self, in_val, em_pt=None, conversions=UNIT_RATIOS):
def _error():
warnings.warn(f"Unhandled size: {repr(in_val)}", CSSWarning)
return self.size_to_pt("1!!default", conversions=conversions)
match = re.match(r"^(\S*?)([a-zA-Z%!].*)", in_val)
Reported by Pylint.
Line: 247
Column: 5
size_fmt = f"{val:f}pt"
return size_fmt
def atomize(self, declarations):
for prop, value in declarations:
attr = "expand_" + prop.replace("-", "_")
try:
expand = getattr(self, attr)
except AttributeError:
Reported by Pylint.
pandas/tests/frame/conftest.py
11 issues
Line: 4
Column: 1
from itertools import product
import numpy as np
import pytest
from pandas import (
DataFrame,
NaT,
date_range,
Reported by Pylint.
Line: 1
Column: 1
from itertools import product
import numpy as np
import pytest
from pandas import (
DataFrame,
NaT,
date_range,
Reported by Pylint.
Line: 15
Column: 1
@pytest.fixture(params=product([True, False], [True, False]))
def close_open_fixture(request):
return request.param
@pytest.fixture
def float_frame_with_na():
Reported by Pylint.
Line: 45
Column: 5
[30 rows x 4 columns]
"""
df = DataFrame(tm.getSeriesData())
# set some NAs
df.iloc[5:10] = np.nan
df.iloc[15:20, -2:] = np.nan
return df
Reported by Pylint.
Line: 78
Column: 5
[30 rows x 4 columns]
"""
df = DataFrame(tm.getSeriesData()) > 0
df = df.astype(object)
# set some NAs
df.iloc[5:10] = np.nan
df.iloc[15:20, -2:] = np.nan
Reported by Pylint.
Line: 79
Column: 5
[30 rows x 4 columns]
"""
df = DataFrame(tm.getSeriesData()) > 0
df = df.astype(object)
# set some NAs
df.iloc[5:10] = np.nan
df.iloc[15:20, -2:] = np.nan
# For `any` tests we need to have at least one True before the first NaN
Reported by Pylint.
Line: 117
Column: 5
[30 rows x 5 columns]
"""
df = DataFrame(tm.getSeriesData())
df["foo"] = "bar"
return df
@pytest.fixture
Reported by Pylint.
Line: 148
Column: 5
[30 rows x 4 columns]
"""
df = DataFrame(tm.getSeriesData())
df.A = df.A.astype("float32")
df.B = df.B.astype("float32")
df.C = df.C.astype("float16")
df.D = df.D.astype("float64")
return df
Reported by Pylint.
Line: 182
Column: 5
[30 rows x 4 columns]
"""
df = DataFrame({k: v.astype(int) for k, v in tm.getSeriesData().items()})
df.A = df.A.astype("int32")
df.B = np.ones(len(df.B), dtype="uint64")
df.C = df.C.astype("uint8")
df.D = df.C.astype("int64")
return df
Reported by Pylint.
Line: 202
Column: 5
1 2013-01-02 NaT NaT
2 2013-01-03 2013-01-03 00:00:00-05:00 2013-01-03 00:00:00+01:00
"""
df = DataFrame(
{
"A": date_range("20130101", periods=3),
"B": date_range("20130101", periods=3, tz="US/Eastern"),
"C": date_range("20130101", periods=3, tz="CET"),
}
Reported by Pylint.
pandas/tests/frame/methods/test_infer_objects.py
11 issues
Line: 1
Column: 1
from datetime import datetime
from pandas import DataFrame
import pandas._testing as tm
class TestInferObjects:
def test_infer_objects(self):
# GH#11221
Reported by Pylint.
Line: 7
Column: 1
import pandas._testing as tm
class TestInferObjects:
def test_infer_objects(self):
# GH#11221
df = DataFrame(
{
"a": ["a", 1, 2, 3],
Reported by Pylint.
Line: 7
Column: 1
import pandas._testing as tm
class TestInferObjects:
def test_infer_objects(self):
# GH#11221
df = DataFrame(
{
"a": ["a", 1, 2, 3],
Reported by Pylint.
Line: 8
Column: 5
class TestInferObjects:
def test_infer_objects(self):
# GH#11221
df = DataFrame(
{
"a": ["a", 1, 2, 3],
"b": ["b", 2.0, 3.0, 4.1],
Reported by Pylint.
Line: 8
Column: 5
class TestInferObjects:
def test_infer_objects(self):
# GH#11221
df = DataFrame(
{
"a": ["a", 1, 2, 3],
"b": ["b", 2.0, 3.0, 4.1],
Reported by Pylint.
Line: 10
Column: 9
class TestInferObjects:
def test_infer_objects(self):
# GH#11221
df = DataFrame(
{
"a": ["a", 1, 2, 3],
"b": ["b", 2.0, 3.0, 4.1],
"c": [
"c",
Reported by Pylint.
Line: 24
Column: 9
},
columns=["a", "b", "c", "d"],
)
df = df.iloc[1:].infer_objects()
assert df["a"].dtype == "int64"
assert df["b"].dtype == "float64"
assert df["c"].dtype == "M8[ns]"
assert df["d"].dtype == "object"
Reported by Pylint.
Line: 26
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
)
df = df.iloc[1:].infer_objects()
assert df["a"].dtype == "int64"
assert df["b"].dtype == "float64"
assert df["c"].dtype == "M8[ns]"
assert df["d"].dtype == "object"
expected = DataFrame(
Reported by Bandit.
Line: 27
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
df = df.iloc[1:].infer_objects()
assert df["a"].dtype == "int64"
assert df["b"].dtype == "float64"
assert df["c"].dtype == "M8[ns]"
assert df["d"].dtype == "object"
expected = DataFrame(
{
Reported by Bandit.
Line: 28
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert df["a"].dtype == "int64"
assert df["b"].dtype == "float64"
assert df["c"].dtype == "M8[ns]"
assert df["d"].dtype == "object"
expected = DataFrame(
{
"a": [1, 2, 3],
Reported by Bandit.
pandas/tests/indexes/base_class/test_reshape.py
11 issues
Line: 4
Column: 1
"""
Tests for ndarray-like method on the base Index class
"""
import pytest
from pandas import Index
import pandas._testing as tm
Reported by Pylint.
Line: 10
Column: 1
import pandas._testing as tm
class TestReshape:
def test_repeat(self):
repeats = 2
index = Index([1, 2, 3])
expected = Index([1, 1, 2, 2, 3, 3])
Reported by Pylint.
Line: 11
Column: 5
class TestReshape:
def test_repeat(self):
repeats = 2
index = Index([1, 2, 3])
expected = Index([1, 1, 2, 2, 3, 3])
result = index.repeat(repeats)
Reported by Pylint.
Line: 11
Column: 5
class TestReshape:
def test_repeat(self):
repeats = 2
index = Index([1, 2, 3])
expected = Index([1, 1, 2, 2, 3, 3])
result = index.repeat(repeats)
Reported by Pylint.
Line: 19
Column: 5
result = index.repeat(repeats)
tm.assert_index_equal(result, expected)
def test_insert(self):
# GH 7256
# validate neg/pos inserts
result = Index(["b", "c", "d"])
Reported by Pylint.
Line: 19
Column: 5
result = index.repeat(repeats)
tm.assert_index_equal(result, expected)
def test_insert(self):
# GH 7256
# validate neg/pos inserts
result = Index(["b", "c", "d"])
Reported by Pylint.
Line: 43
Column: 5
[
(0, Index(["b", "c", "d"], name="index")),
(-1, Index(["a", "b", "c"], name="index")),
],
)
def test_delete(self, pos, expected):
index = Index(["a", "b", "c", "d"], name="index")
result = index.delete(pos)
tm.assert_index_equal(result, expected)
Reported by Pylint.
Line: 43
Column: 5
[
(0, Index(["b", "c", "d"], name="index")),
(-1, Index(["a", "b", "c"], name="index")),
],
)
def test_delete(self, pos, expected):
index = Index(["a", "b", "c", "d"], name="index")
result = index.delete(pos)
tm.assert_index_equal(result, expected)
Reported by Pylint.
Line: 49
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
index = Index(["a", "b", "c", "d"], name="index")
result = index.delete(pos)
tm.assert_index_equal(result, expected)
assert result.name == expected.name
def test_append_multiple(self):
index = Index(["a", "b", "c", "d", "e", "f"])
foos = [index[:2], index[2:4], index[4:]]
Reported by Bandit.
Line: 51
Column: 5
tm.assert_index_equal(result, expected)
assert result.name == expected.name
def test_append_multiple(self):
index = Index(["a", "b", "c", "d", "e", "f"])
foos = [index[:2], index[2:4], index[4:]]
result = foos[0].append(foos[1:])
tm.assert_index_equal(result, index)
Reported by Pylint.
pandas/core/window/expanding.py
11 issues
Line: 376
Column: 5
window_method="expanding",
aggregation_description="standard deviation",
agg_method="std",
)
def std(self, ddof: int = 1, *args, **kwargs):
nv.validate_expanding_func("std", args, kwargs)
return super().std(ddof=ddof, **kwargs)
@doc(
Reported by Pylint.
Line: 426
Column: 5
window_method="expanding",
aggregation_description="variance",
agg_method="var",
)
def var(self, ddof: int = 1, *args, **kwargs):
nv.validate_expanding_func("var", args, kwargs)
return super().var(ddof=ddof, **kwargs)
@doc(
Reported by Pylint.
Line: 465
Column: 5
window_method="expanding",
aggregation_description="standard error of mean",
agg_method="sem",
)
def sem(self, ddof: int = 1, *args, **kwargs):
return super().sem(ddof=ddof, **kwargs)
@doc(
template_header,
Reported by Pylint.
Line: 1
Column: 1
from __future__ import annotations
from textwrap import dedent
from typing import (
TYPE_CHECKING,
Any,
Callable,
)
Reported by Pylint.
Line: 18
Column: 1
if TYPE_CHECKING:
from pandas import DataFrame, Series
from pandas.compat.numpy import function as nv
from pandas.util._decorators import doc
from pandas.core.indexers.objects import (
BaseIndexer,
ExpandingIndexer,
Reported by Pylint.
Line: 19
Column: 1
from pandas import DataFrame, Series
from pandas.compat.numpy import function as nv
from pandas.util._decorators import doc
from pandas.core.indexers.objects import (
BaseIndexer,
ExpandingIndexer,
GroupbyIndexer,
Reported by Pylint.
Line: 21
Column: 1
from pandas.compat.numpy import function as nv
from pandas.util._decorators import doc
from pandas.core.indexers.objects import (
BaseIndexer,
ExpandingIndexer,
GroupbyIndexer,
)
from pandas.core.window.doc import (
Reported by Pylint.
Line: 26
Column: 1
ExpandingIndexer,
GroupbyIndexer,
)
from pandas.core.window.doc import (
_shared_docs,
args_compat,
create_section_header,
kwargs_compat,
numba_notes,
Reported by Pylint.
Line: 38
Column: 1
window_agg_numba_parameters,
window_apply_parameters,
)
from pandas.core.window.rolling import (
BaseWindowGroupby,
RollingAndExpandingMixin,
)
Reported by Pylint.
Line: 101
Column: 5
_attributes = ["min_periods", "center", "axis", "method"]
def __init__(
self,
obj: FrameOrSeries,
min_periods: int = 1,
center=None,
axis: Axis = 0,
Reported by Pylint.
pandas/tests/arrays/categorical/test_algos.py
11 issues
Line: 2
Column: 1
import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
@pytest.mark.parametrize("ordered", [True, False])
@pytest.mark.parametrize("categories", [["b", "a", "c"], ["a", "b", "c", "d"]])
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
@pytest.mark.parametrize("ordered", [True, False])
@pytest.mark.parametrize("categories", [["b", "a", "c"], ["a", "b", "c", "d"]])
Reported by Pylint.
Line: 10
Column: 1
@pytest.mark.parametrize("ordered", [True, False])
@pytest.mark.parametrize("categories", [["b", "a", "c"], ["a", "b", "c", "d"]])
def test_factorize(categories, ordered):
cat = pd.Categorical(
["b", "b", "a", "c", None], categories=categories, ordered=ordered
)
codes, uniques = pd.factorize(cat)
expected_codes = np.array([0, 0, 1, 2, -1], dtype=np.intp)
Reported by Pylint.
Line: 24
Column: 1
tm.assert_categorical_equal(uniques, expected_uniques)
def test_factorized_sort():
cat = pd.Categorical(["b", "b", None, "a"])
codes, uniques = pd.factorize(cat, sort=True)
expected_codes = np.array([1, 1, -1, 0], dtype=np.intp)
expected_uniques = pd.Categorical(["a", "b"])
Reported by Pylint.
Line: 34
Column: 1
tm.assert_categorical_equal(uniques, expected_uniques)
def test_factorized_sort_ordered():
cat = pd.Categorical(
["b", "b", None, "a"], categories=["c", "b", "a"], ordered=True
)
codes, uniques = pd.factorize(cat, sort=True)
Reported by Pylint.
Line: 49
Column: 1
tm.assert_categorical_equal(uniques, expected_uniques)
def test_isin_cats():
# GH2003
cat = pd.Categorical(["a", "b", np.nan])
result = cat.isin(["a", np.nan])
expected = np.array([True, False, True], dtype=bool)
Reported by Pylint.
Line: 63
Column: 1
@pytest.mark.parametrize("empty", [[], pd.Series(dtype=object), np.array([])])
def test_isin_empty(empty):
s = pd.Categorical(["a", "b"])
expected = np.array([False, False], dtype=bool)
result = s.isin(empty)
tm.assert_numpy_array_equal(expected, result)
Reported by Pylint.
Line: 64
Column: 5
@pytest.mark.parametrize("empty", [[], pd.Series(dtype=object), np.array([])])
def test_isin_empty(empty):
s = pd.Categorical(["a", "b"])
expected = np.array([False, False], dtype=bool)
result = s.isin(empty)
tm.assert_numpy_array_equal(expected, result)
Reported by Pylint.
Line: 71
Column: 1
tm.assert_numpy_array_equal(expected, result)
def test_diff():
s = pd.Series([1, 2, 3], dtype="category")
with tm.assert_produces_warning(FutureWarning):
result = s.diff()
expected = pd.Series([np.nan, 1, 1])
tm.assert_series_equal(result, expected)
Reported by Pylint.
Line: 72
Column: 5
def test_diff():
s = pd.Series([1, 2, 3], dtype="category")
with tm.assert_produces_warning(FutureWarning):
result = s.diff()
expected = pd.Series([np.nan, 1, 1])
tm.assert_series_equal(result, expected)
Reported by Pylint.
pandas/tests/arrays/floating/conftest.py
11 issues
Line: 2
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas.core.arrays.floating import (
Float32Dtype,
Float64Dtype,
)
Reported by Pylint.
Line: 17
Column: 10
@pytest.fixture
def data(dtype):
return pd.array(
list(np.arange(0.1, 0.9, 0.1))
+ [pd.NA]
+ list(np.arange(1, 9.8, 0.1))
+ [pd.NA]
Reported by Pylint.
Line: 29
Column: 18
@pytest.fixture
def data_missing(dtype):
return pd.array([np.nan, 0.1], dtype=dtype)
@pytest.fixture(params=["data", "data_missing"])
def all_data(request, data, data_missing):
Reported by Pylint.
Line: 34
Column: 23
@pytest.fixture(params=["data", "data_missing"])
def all_data(request, data, data_missing):
"""Parametrized fixture giving 'data' and 'data_missing'"""
if request.param == "data":
return data
elif request.param == "data_missing":
return data_missing
Reported by Pylint.
Line: 34
Column: 29
@pytest.fixture(params=["data", "data_missing"])
def all_data(request, data, data_missing):
"""Parametrized fixture giving 'data' and 'data_missing'"""
if request.param == "data":
return data
elif request.param == "data_missing":
return data_missing
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas.core.arrays.floating import (
Float32Dtype,
Float64Dtype,
)
Reported by Pylint.
Line: 12
Column: 1
@pytest.fixture(params=[Float32Dtype, Float64Dtype])
def dtype(request):
return request.param()
@pytest.fixture
def data(dtype):
Reported by Pylint.
Line: 17
Column: 1
@pytest.fixture
def data(dtype):
return pd.array(
list(np.arange(0.1, 0.9, 0.1))
+ [pd.NA]
+ list(np.arange(1, 9.8, 0.1))
+ [pd.NA]
Reported by Pylint.
Line: 29
Column: 1
@pytest.fixture
def data_missing(dtype):
return pd.array([np.nan, 0.1], dtype=dtype)
@pytest.fixture(params=["data", "data_missing"])
def all_data(request, data, data_missing):
Reported by Pylint.
Line: 34
Column: 1
@pytest.fixture(params=["data", "data_missing"])
def all_data(request, data, data_missing):
"""Parametrized fixture giving 'data' and 'data_missing'"""
if request.param == "data":
return data
elif request.param == "data_missing":
return data_missing
Reported by Pylint.