The following issues were found
pandas/tests/io/formats/style/test_to_latex.py
144 issues
Line: 3
Column: 1
from textwrap import dedent
import pytest
from pandas import (
DataFrame,
MultiIndex,
option_context,
)
Reported by Pylint.
Line: 28
Column: 12
@pytest.fixture
def styler(df):
return Styler(df, uuid_len=0, precision=2)
def test_minimal_latex_tabular(styler):
expected = dedent(
Reported by Pylint.
Line: 32
Column: 32
return Styler(df, uuid_len=0, precision=2)
def test_minimal_latex_tabular(styler):
expected = dedent(
"""\
\\begin{tabular}{lrrl}
{} & {A} & {B} & {C} \\\\
0 & 0 & -0.61 & ab \\\\
Reported by Pylint.
Line: 45
Column: 25
assert styler.to_latex() == expected
def test_tabular_hrules(styler):
expected = dedent(
"""\
\\begin{tabular}{lrrl}
\\toprule
{} & {A} & {B} & {C} \\\\
Reported by Pylint.
Line: 61
Column: 32
assert styler.to_latex(hrules=True) == expected
def test_tabular_custom_hrules(styler):
styler.set_table_styles(
[
{"selector": "toprule", "props": ":hline"},
{"selector": "bottomrule", "props": ":otherline"},
]
Reported by Pylint.
Line: 82
Column: 24
assert styler.to_latex() == expected
def test_column_format(styler):
# default setting is already tested in `test_latex_minimal_tabular`
styler.set_table_styles([{"selector": "column_format", "props": ":cccc"}])
assert "\\begin{tabular}{rrrr}" in styler.to_latex(column_format="rrrr")
styler.set_table_styles([{"selector": "column_format", "props": ":r|r|cc"}])
Reported by Pylint.
Line: 91
Column: 23
assert "\\begin{tabular}{r|r|cc}" in styler.to_latex()
def test_siunitx_cols(styler):
expected = dedent(
"""\
\\begin{tabular}{lSSl}
{} & {A} & {B} & {C} \\\\
0 & 0 & -0.61 & ab \\\\
Reported by Pylint.
Line: 104
Column: 19
assert styler.to_latex(siunitx=True) == expected
def test_position(styler):
assert "\\begin{table}[h!]" in styler.to_latex(position="h!")
assert "\\end{table}" in styler.to_latex(position="h!")
styler.set_table_styles([{"selector": "position", "props": ":b!"}])
assert "\\begin{table}[b!]" in styler.to_latex()
assert "\\end{table}" in styler.to_latex()
Reported by Pylint.
Line: 112
Column: 16
assert "\\end{table}" in styler.to_latex()
def test_label(styler):
assert "\\label{text}" in styler.to_latex(label="text")
styler.set_table_styles([{"selector": "label", "props": ":{more §text}"}])
assert "\\label{more :text}" in styler.to_latex()
Reported by Pylint.
Line: 118
Column: 32
assert "\\label{more :text}" in styler.to_latex()
def test_position_float_raises(styler):
msg = "`position_float` should be one of 'raggedright', 'raggedleft', 'centering',"
with pytest.raises(ValueError, match=msg):
styler.to_latex(position_float="bad_string")
msg = "`position_float` cannot be used in 'longtable' `environment`"
Reported by Pylint.
pandas/tests/io/formats/style/test_format.py
143 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas import (
DataFrame,
IndexSlice,
NaT,
Timestamp,
)
Reported by Pylint.
Line: 26
Column: 12
@pytest.fixture
def styler(df):
return Styler(df, uuid_len=0)
def test_display_format(styler):
ctx = styler.format("{:0.1f}")._translate(True, True)
Reported by Pylint.
Line: 30
Column: 25
return Styler(df, uuid_len=0)
def test_display_format(styler):
ctx = styler.format("{:0.1f}")._translate(True, True)
assert all(["display_value" in c for c in row] for row in ctx["body"])
assert all([len(c["display_value"]) <= 3 for c in row[1:]] for row in ctx["body"])
assert len(ctx["body"][0][1]["display_value"].lstrip("-")) <= 3
Reported by Pylint.
Line: 31
Column: 11
def test_display_format(styler):
ctx = styler.format("{:0.1f}")._translate(True, True)
assert all(["display_value" in c for c in row] for row in ctx["body"])
assert all([len(c["display_value"]) <= 3 for c in row[1:]] for row in ctx["body"])
assert len(ctx["body"][0][1]["display_value"].lstrip("-")) <= 3
Reported by Pylint.
Line: 37
Column: 22
assert len(ctx["body"][0][1]["display_value"].lstrip("-")) <= 3
def test_format_dict(styler):
ctx = styler.format({"A": "{:0.1f}", "B": "{0:.2%}"})._translate(True, True)
assert ctx["body"][0][1]["display_value"] == "0.0"
assert ctx["body"][0][2]["display_value"] == "-60.90%"
Reported by Pylint.
Line: 38
Column: 11
def test_format_dict(styler):
ctx = styler.format({"A": "{:0.1f}", "B": "{0:.2%}"})._translate(True, True)
assert ctx["body"][0][1]["display_value"] == "0.0"
assert ctx["body"][0][2]["display_value"] == "-60.90%"
def test_format_string(styler):
Reported by Pylint.
Line: 43
Column: 24
assert ctx["body"][0][2]["display_value"] == "-60.90%"
def test_format_string(styler):
ctx = styler.format("{:.2f}")._translate(True, True)
assert ctx["body"][0][1]["display_value"] == "0.00"
assert ctx["body"][0][2]["display_value"] == "-0.61"
assert ctx["body"][1][1]["display_value"] == "1.00"
assert ctx["body"][1][2]["display_value"] == "-1.23"
Reported by Pylint.
Line: 44
Column: 11
def test_format_string(styler):
ctx = styler.format("{:.2f}")._translate(True, True)
assert ctx["body"][0][1]["display_value"] == "0.00"
assert ctx["body"][0][2]["display_value"] == "-0.61"
assert ctx["body"][1][1]["display_value"] == "1.00"
assert ctx["body"][1][2]["display_value"] == "-1.23"
Reported by Pylint.
Line: 51
Column: 26
assert ctx["body"][1][2]["display_value"] == "-1.23"
def test_format_callable(styler):
ctx = styler.format(lambda v: "neg" if v < 0 else "pos")._translate(True, True)
assert ctx["body"][0][1]["display_value"] == "pos"
assert ctx["body"][0][2]["display_value"] == "neg"
assert ctx["body"][1][1]["display_value"] == "pos"
assert ctx["body"][1][2]["display_value"] == "neg"
Reported by Pylint.
Line: 52
Column: 11
def test_format_callable(styler):
ctx = styler.format(lambda v: "neg" if v < 0 else "pos")._translate(True, True)
assert ctx["body"][0][1]["display_value"] == "pos"
assert ctx["body"][0][2]["display_value"] == "neg"
assert ctx["body"][1][1]["display_value"] == "pos"
assert ctx["body"][1][2]["display_value"] == "neg"
Reported by Pylint.
pandas/tests/frame/methods/test_sort_values.py
142 issues
Line: 4
Column: 1
import random
import numpy as np
import pytest
from pandas.errors import PerformanceWarning
import pandas as pd
from pandas import (
Reported by Pylint.
Line: 256
Column: 36
)
@pytest.mark.parametrize("na_position", ["first", "last"])
def test_sort_values_stable_multicolumn_sort(
self, expected_idx_non_na, ascending, na_position
):
# GH#38426 Clarify sort_values with mult. columns / labels is stable
df = DataFrame(
{
"A": [1, 2, np.nan, 1, 1, 1, 6, 8, 4, 8, 8, np.nan, np.nan, 8, 8],
Reported by Pylint.
Line: 588
Column: 24
df["D"] = df["A"] * 2
ser = df["A"]
if not using_array_manager:
assert len(df._mgr.blocks) == 2
df.sort_values(by="A")
ser.values[0] = 99
assert df.iloc[0, 0] == df["A"][0]
Reported by Pylint.
Line: 787
Column: 21
@pytest.fixture(params=[["outer"], ["outer", "inner"]])
def df_idx(request, df_none):
levels = request.param
return df_none.set_index(levels)
@pytest.fixture(
Reported by Pylint.
Line: 815
Column: 32
class TestSortValuesLevelAsStr:
def test_sort_index_level_and_column_label(
self, df_none, df_idx, sort_names, ascending
):
# GH#14353
# Get index levels from df_idx
levels = df_idx.index.names
Reported by Pylint.
Line: 815
Column: 15
class TestSortValuesLevelAsStr:
def test_sort_index_level_and_column_label(
self, df_none, df_idx, sort_names, ascending
):
# GH#14353
# Get index levels from df_idx
levels = df_idx.index.names
Reported by Pylint.
Line: 815
Column: 24
class TestSortValuesLevelAsStr:
def test_sort_index_level_and_column_label(
self, df_none, df_idx, sort_names, ascending
):
# GH#14353
# Get index levels from df_idx
levels = df_idx.index.names
Reported by Pylint.
Line: 815
Column: 44
class TestSortValuesLevelAsStr:
def test_sort_index_level_and_column_label(
self, df_none, df_idx, sort_names, ascending
):
# GH#14353
# Get index levels from df_idx
levels = df_idx.index.names
Reported by Pylint.
Line: 833
Column: 15
tm.assert_frame_equal(result, expected)
def test_sort_column_level_and_index_label(
self, df_none, df_idx, sort_names, ascending
):
# GH#14353
# Get levels from df_idx
levels = df_idx.index.names
Reported by Pylint.
Line: 833
Column: 32
tm.assert_frame_equal(result, expected)
def test_sort_column_level_and_index_label(
self, df_none, df_idx, sort_names, ascending
):
# GH#14353
# Get levels from df_idx
levels = df_idx.index.names
Reported by Pylint.
pandas/tests/config/test_config.py
141 issues
Line: 3
Column: 1
import warnings
import pytest
from pandas._config import config as cf
from pandas._config.config import OptionError
import pandas as pd
Reported by Pylint.
Line: 21
Column: 28
cls.do = deepcopy(getattr(cls.cf, "_deprecated_options"))
cls.ro = deepcopy(getattr(cls.cf, "_registered_options"))
def setup_method(self, method):
setattr(self.cf, "_global_config", {})
setattr(self.cf, "options", self.cf.DictWrapper(self.cf._global_config))
setattr(self.cf, "_deprecated_options", {})
setattr(self.cf, "_registered_options", {})
Reported by Pylint.
Line: 23
Column: 57
def setup_method(self, method):
setattr(self.cf, "_global_config", {})
setattr(self.cf, "options", self.cf.DictWrapper(self.cf._global_config))
setattr(self.cf, "_deprecated_options", {})
setattr(self.cf, "_registered_options", {})
# Our test fixture in conftest.py sets "chained_assignment"
# to "raise" only after all test methods have been setup.
Reported by Pylint.
Line: 33
Column: 31
# "chained_assignment" option, so re-register it.
self.cf.register_option("chained_assignment", "raise")
def teardown_method(self, method):
setattr(self.cf, "_global_config", self.gc)
setattr(self.cf, "_deprecated_options", self.do)
setattr(self.cf, "_registered_options", self.ro)
def test_api(self):
Reported by Pylint.
Line: 141
Column: 16
self.cf.get_option("no_such_option")
self.cf.deprecate_option("KanBan")
assert self.cf._is_deprecated("kAnBaN")
def test_get_option(self):
self.cf.register_option("a", 1, "doc")
self.cf.register_option("b.c", "hullo", "doc2")
self.cf.register_option("b.b", None, "doc2")
Reported by Pylint.
Line: 287
Column: 16
# we can deprecate non-existent options
self.cf.deprecate_option("foo")
assert self.cf._is_deprecated("foo")
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
with pytest.raises(KeyError, match="No such keys.s.: 'foo'"):
self.cf.get_option("foo")
assert len(w) == 1 # should have raised one warning
Reported by Pylint.
Line: 423
Column: 16
def test_attribute_access(self):
holder = []
def f3(key):
holder.append(True)
self.cf.register_option("a", 0)
self.cf.register_option("c", 0, cb=f3)
options = self.cf.options
Reported by Pylint.
Line: 476
Column: 13
options = self.cf.options
# GH 19789
with pytest.raises(OptionError, match="No such option"):
options.bananas
assert not hasattr(options, "bananas")
Reported by Pylint.
Line: 1
Column: 1
import warnings
import pytest
from pandas._config import config as cf
from pandas._config.config import OptionError
import pandas as pd
Reported by Pylint.
Line: 11
Column: 1
import pandas as pd
class TestConfig:
@classmethod
def setup_class(cls):
from copy import deepcopy
cls.cf = cf
Reported by Pylint.
pandas/io/formats/format.py
140 issues
Line: 40
Column: 1
set_option,
)
from pandas._libs import lib
from pandas._libs.missing import NA
from pandas._libs.tslibs import (
NaT,
Timedelta,
Timestamp,
Reported by Pylint.
Line: 41
Column: 1
)
from pandas._libs import lib
from pandas._libs.missing import NA
from pandas._libs.tslibs import (
NaT,
Timedelta,
Timestamp,
iNaT,
Reported by Pylint.
Line: 41
Column: 1
)
from pandas._libs import lib
from pandas._libs.missing import NA
from pandas._libs.tslibs import (
NaT,
Timedelta,
Timestamp,
iNaT,
Reported by Pylint.
Line: 48
Column: 1
Timestamp,
iNaT,
)
from pandas._libs.tslibs.nattype import NaTType
from pandas._typing import (
ArrayLike,
ColspaceArgType,
ColspaceType,
CompressionOptions,
Reported by Pylint.
Line: 48
Column: 1
Timestamp,
iNaT,
)
from pandas._libs.tslibs.nattype import NaTType
from pandas._typing import (
ArrayLike,
ColspaceArgType,
ColspaceType,
CompressionOptions,
Reported by Pylint.
Line: 222
Column: 22
footer += ", "
footer += f"Length: {len(self.categorical)}"
level_info = self.categorical._repr_categories_info()
# Levels are added in a newline
if footer:
footer += "\n"
footer += level_info
Reported by Pylint.
Line: 233
Column: 13
def _get_formatted_values(self) -> list[str]:
return format_array(
self.categorical._internal_get_values(),
None,
float_format=None,
na_rep=self.na_rep,
quoting=self.quoting,
)
Reported by Pylint.
Line: 356
Column: 26
# level infos are added to the end and in a new line, like it is done
# for Categoricals
if is_categorical_dtype(self.tr_series.dtype):
level_info = self.tr_series._values._repr_categories_info()
if footer:
footer += "\n"
footer += level_info
return str(footer)
Reported by Pylint.
Line: 356
Column: 26
# level infos are added to the end and in a new line, like it is done
# for Categoricals
if is_categorical_dtype(self.tr_series.dtype):
level_info = self.tr_series._values._repr_categories_info()
if footer:
footer += "\n"
footer += level_info
return str(footer)
Reported by Pylint.
Line: 376
Column: 13
def _get_formatted_values(self) -> list[str]:
return format_array(
self.tr_series._values,
None,
float_format=self.float_format,
na_rep=self.na_rep,
leading_space=self.index,
)
Reported by Pylint.
pandas/tests/frame/methods/test_fillna.py
140 issues
Line: 2
Column: 1
import numpy as np
import pytest
import pandas.util._test_decorators as td
from pandas import (
Categorical,
DataFrame,
DatetimeIndex,
Reported by Pylint.
Line: 48
Column: 3
mf = float_string_frame
mf.loc[mf.index[5:20], "foo"] = np.nan
mf.loc[mf.index[-10:], "A"] = np.nan
# TODO: make stronger assertion here, GH 25640
mf.fillna(value=0)
mf.fillna(method="pad")
def test_fillna_mixed_float(self, mixed_float_frame):
Reported by Pylint.
Line: 235
Column: 3
df = DataFrame({"a": Categorical(idx)})
tm.assert_frame_equal(df.fillna(value=NaT), df)
@td.skip_array_manager_not_yet_implemented # TODO(ArrayManager) implement downcast
def test_fillna_downcast(self):
# GH#15277
# infer int64 from float64
df = DataFrame({"a": [1.0, np.nan]})
result = df.fillna(0, downcast="infer")
Reported by Pylint.
Line: 250
Column: 3
expected = DataFrame({"a": [1, 0]})
tm.assert_frame_equal(result, expected)
@td.skip_array_manager_not_yet_implemented # TODO(ArrayManager) object upcasting
def test_fillna_dtype_conversion(self):
# make sure that fillna on an empty frame works
df = DataFrame(index=["A", "B", "C"], columns=[1, 2, 3, 4, 5])
result = df.dtypes
expected = Series([np.dtype("object")] * 5, index=[1, 2, 3, 4, 5])
Reported by Pylint.
Line: 268
Column: 3
expected = DataFrame("nan", index=range(3), columns=["A", "B"])
tm.assert_frame_equal(result, expected)
@td.skip_array_manager_not_yet_implemented # TODO(ArrayManager) object upcasting
@pytest.mark.parametrize("val", ["", 1, np.nan, 1.0])
def test_fillna_dtype_conversion_equiv_replace(self, val):
df = DataFrame({"A": [1, np.nan], "B": [1.0, 2.0]})
expected = df.replace(np.nan, val)
result = df.fillna(val)
Reported by Pylint.
Line: 404
Column: 42
df.fillna(np.nan)
@pytest.mark.parametrize("type", [int, float])
def test_fillna_positive_limit(self, type):
df = DataFrame(np.random.randn(10, 4)).astype(type)
msg = "Limit must be greater than 0"
with pytest.raises(ValueError, match=msg):
df.fillna(0, limit=-5)
Reported by Pylint.
Line: 412
Column: 41
df.fillna(0, limit=-5)
@pytest.mark.parametrize("type", [int, float])
def test_fillna_integer_limit(self, type):
df = DataFrame(np.random.randn(10, 4)).astype(type)
msg = "Limit must be an integer"
with pytest.raises(ValueError, match=msg):
df.fillna(0, limit=0.5)
Reported by Pylint.
Line: 555
Column: 3
empty_float = float_frame.reindex(columns=[])
# TODO(wesm): unused?
result = empty_float.fillna(value=0) # noqa
def test_fillna_downcast_dict(self):
# GH#40809
df = DataFrame({"col1": [1, np.nan]})
Reported by Pylint.
Line: 556
Column: 9
empty_float = float_frame.reindex(columns=[])
# TODO(wesm): unused?
result = empty_float.fillna(value=0) # noqa
def test_fillna_downcast_dict(self):
# GH#40809
df = DataFrame({"col1": [1, np.nan]})
result = df.fillna({"col1": 2}, downcast={"col1": "int64"})
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
import pandas.util._test_decorators as td
from pandas import (
Categorical,
DataFrame,
DatetimeIndex,
Reported by Pylint.
pandas/tests/plotting/frame/test_frame_subplots.py
138 issues
Line: 7
Column: 1
import warnings
import numpy as np
import pytest
import pandas.util._test_decorators as td
import pandas as pd
from pandas import (
Reported by Pylint.
Line: 268
Column: 21
def test_subplots_multiple_axes(self):
# GH 5353, 6970, GH 7069
fig, axes = self.plt.subplots(2, 3)
df = DataFrame(np.random.rand(10, 3), index=list(string.ascii_letters[:10]))
returned = df.plot(subplots=True, ax=axes[0], sharex=False, sharey=False)
self._check_axes_shape(returned, axes_num=3, layout=(1, 3))
assert returned.shape == (3,)
Reported by Pylint.
Line: 286
Column: 25
msg = "The number of passed axes must be 3, the same as the output plot"
with pytest.raises(ValueError, match=msg):
fig, axes = self.plt.subplots(2, 3)
# pass different number of axes from required
df.plot(subplots=True, ax=axes)
# pass 2-dim axes and invalid layout
# invalid lauout should not affect to input and return value
Reported by Pylint.
Line: 294
Column: 21
# invalid lauout should not affect to input and return value
# (show warning is tested in
# TestDataFrameGroupByPlots.test_grouped_box_multiple_axes
fig, axes = self.plt.subplots(2, 2)
with warnings.catch_warnings():
warnings.simplefilter("ignore", UserWarning)
df = DataFrame(np.random.rand(10, 4), index=list(string.ascii_letters[:10]))
returned = df.plot(
Reported by Pylint.
Line: 318
Column: 21
assert returned.shape == (4,)
# single column
fig, axes = self.plt.subplots(1, 1)
df = DataFrame(np.random.rand(10, 1), index=list(string.ascii_letters[:10]))
axes = df.plot(subplots=True, ax=[axes], sharex=False, sharey=False)
self._check_axes_shape(axes, axes_num=1, layout=(1, 1))
assert axes.shape == (1,)
Reported by Pylint.
Line: 327
Column: 21
def test_subplots_ts_share_axes(self):
# GH 3964
fig, axes = self.plt.subplots(3, 3, sharex=True, sharey=True)
self.plt.subplots_adjust(left=0.05, right=0.95, hspace=0.3, wspace=0.3)
df = DataFrame(
np.random.randn(10, 9),
index=date_range(start="2014-07-01", freq="M", periods=10),
)
Reported by Pylint.
Line: 328
Column: 9
def test_subplots_ts_share_axes(self):
# GH 3964
fig, axes = self.plt.subplots(3, 3, sharex=True, sharey=True)
self.plt.subplots_adjust(left=0.05, right=0.95, hspace=0.3, wspace=0.3)
df = DataFrame(
np.random.randn(10, 9),
index=date_range(start="2014-07-01", freq="M", periods=10),
)
for i, ax in enumerate(axes.ravel()):
Reported by Pylint.
Line: 480
Column: 21
df.iloc[5:, 1] = np.nan
df.iloc[:5, 0] = np.nan
figs, axs = self.plt.subplots(2, 1)
df.plot.line(ax=axs, subplots=True, sharex=False)
expected_ax1 = np.arange(4.5, 10, 0.5)
expected_ax2 = np.arange(-0.5, 5, 0.5)
Reported by Pylint.
Line: 494
Column: 20
idx = date_range(start="now", periods=10)
df = DataFrame(np.random.rand(10, 3), index=idx)
kwargs = {}
if hasattr(self.plt.Figure, "get_constrained_layout"):
kwargs["constrained_layout"] = True
fig, axes = self.plt.subplots(2, **kwargs)
with tm.assert_produces_warning(None):
df.plot(ax=axes[0])
with tm.ensure_clean(return_filelike=True) as path:
Reported by Pylint.
Line: 496
Column: 21
kwargs = {}
if hasattr(self.plt.Figure, "get_constrained_layout"):
kwargs["constrained_layout"] = True
fig, axes = self.plt.subplots(2, **kwargs)
with tm.assert_produces_warning(None):
df.plot(ax=axes[0])
with tm.ensure_clean(return_filelike=True) as path:
self.plt.savefig(path)
Reported by Pylint.
pandas/core/internals/managers.py
138 issues
Line: 18
Column: 1
import numpy as np
from pandas._libs import (
internals as libinternals,
lib,
)
from pandas._libs.internals import BlockPlacement
from pandas._typing import (
Reported by Pylint.
Line: 18
Column: 1
import numpy as np
from pandas._libs import (
internals as libinternals,
lib,
)
from pandas._libs.internals import BlockPlacement
from pandas._typing import (
Reported by Pylint.
Line: 22
Column: 1
internals as libinternals,
lib,
)
from pandas._libs.internals import BlockPlacement
from pandas._typing import (
ArrayLike,
DtypeObj,
Shape,
npt,
Reported by Pylint.
Line: 22
Column: 1
internals as libinternals,
lib,
)
from pandas._libs.internals import BlockPlacement
from pandas._typing import (
ArrayLike,
DtypeObj,
Shape,
npt,
Reported by Pylint.
Line: 142
Column: 14
__slots__ = ()
_blknos: npt.NDArray[np.intp]
_blklocs: npt.NDArray[np.intp]
blocks: tuple[Block, ...]
axes: list[Index]
ndim: int
Reported by Pylint.
Line: 143
Column: 15
__slots__ = ()
_blknos: npt.NDArray[np.intp]
_blklocs: npt.NDArray[np.intp]
blocks: tuple[Block, ...]
axes: list[Index]
ndim: int
_known_consolidated: bool
Reported by Pylint.
Line: 159
Column: 25
raise NotImplementedError
@property
def blknos(self) -> npt.NDArray[np.intp]:
"""
Suppose we want to find the array corresponding to our i'th column.
blknos[i] identifies the block from self.blocks that contains this column.
Reported by Pylint.
Line: 175
Column: 26
return self._blknos
@property
def blklocs(self) -> npt.NDArray[np.intp]:
"""
See blknos.__doc__
"""
if self._blklocs is None:
# Note: these can be altered by other BlockManager methods.
Reported by Pylint.
Line: 1707
Column: 20
def get_slice(self, slobj: slice, axis: int = 0) -> SingleBlockManager:
# Assertion disabled for performance
# assert isinstance(slobj, slice), type(slobj)
if axis >= self.ndim:
raise IndexError("Requested axis not found in manager")
blk = self._block
array = blk._slice(slobj)
bp = BlockPlacement(slice(0, len(array)))
Reported by Pylint.
Line: 2048
Column: 32
return blocks
def _fast_count_smallints(arr: npt.NDArray[np.intp]):
"""Faster version of set(arr) for sequences of small numbers."""
counts = np.bincount(arr.astype(np.int_, copy=False))
nz = counts.nonzero()[0]
# Note: list(zip(...) outperforms list(np.c_[nz, counts[nz]]) here,
# in one benchmark by a factor of 11
Reported by Pylint.
pandas/tests/reshape/test_melt.py
137 issues
Line: 2
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas import (
DataFrame,
lreshape,
melt,
wide_to_long,
Reported by Pylint.
Line: 15
Column: 28
class TestMelt:
def setup_method(self, method):
self.df = tm.makeTimeDataFrame()[:10]
self.df["id1"] = (self.df["A"] > 0).astype(np.int64)
self.df["id2"] = (self.df["B"] > 0).astype(np.int64)
self.var_name = "var"
Reported by Pylint.
Line: 16
Column: 9
class TestMelt:
def setup_method(self, method):
self.df = tm.makeTimeDataFrame()[:10]
self.df["id1"] = (self.df["A"] > 0).astype(np.int64)
self.df["id2"] = (self.df["B"] > 0).astype(np.int64)
self.var_name = "var"
self.value_name = "val"
Reported by Pylint.
Line: 20
Column: 9
self.df["id1"] = (self.df["A"] > 0).astype(np.int64)
self.df["id2"] = (self.df["B"] > 0).astype(np.int64)
self.var_name = "var"
self.value_name = "val"
self.df1 = DataFrame(
[
[1.067683, -1.110463, 0.20867],
Reported by Pylint.
Line: 21
Column: 9
self.df["id2"] = (self.df["B"] > 0).astype(np.int64)
self.var_name = "var"
self.value_name = "val"
self.df1 = DataFrame(
[
[1.067683, -1.110463, 0.20867],
[-1.321405, 0.368915, -1.055342],
Reported by Pylint.
Line: 23
Column: 9
self.var_name = "var"
self.value_name = "val"
self.df1 = DataFrame(
[
[1.067683, -1.110463, 0.20867],
[-1.321405, 0.368915, -1.055342],
[-0.807333, 0.08298, -0.873361],
]
Reported by Pylint.
Line: 679
Column: 3
df.columns = ["id", "inc1", "inc2", "edu1", "edu2"]
stubs = ["inc", "edu"]
# TODO: unused?
df_long = wide_to_long(df, stubs, i="id", j="age") # noqa
assert stubs == ["inc", "edu"]
def test_separating_character(self):
Reported by Pylint.
Line: 680
Column: 9
stubs = ["inc", "edu"]
# TODO: unused?
df_long = wide_to_long(df, stubs, i="id", j="age") # noqa
assert stubs == ["inc", "edu"]
def test_separating_character(self):
# GH14779
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas import (
DataFrame,
lreshape,
melt,
wide_to_long,
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas import (
DataFrame,
lreshape,
melt,
wide_to_long,
Reported by Pylint.
asv_bench/benchmarks/join_merge.py
137 issues
Line: 5
Column: 1
import numpy as np
from pandas import (
DataFrame,
MultiIndex,
Series,
concat,
date_range,
Reported by Pylint.
Line: 15
Column: 1
merge_asof,
)
from .pandas_vb_common import tm
try:
from pandas import merge_ordered
except ImportError:
from pandas import ordered_merge as merge_ordered
Reported by Pylint.
Line: 387
Column: 18
def setup(self):
size = 5 * 10 ** 5
rng = np.arange(0, 10 ** 13, 10 ** 7)
stamps = np.datetime64("now").view("i8") + rng
idx1 = np.sort(np.random.choice(stamps, size, replace=False))
idx2 = np.sort(np.random.choice(stamps, size, replace=False))
self.ts1 = Series(np.random.randn(size), idx1)
self.ts2 = Series(np.random.randn(size), idx2)
Reported by Pylint.
Line: 400
Column: 1
self.ts1.align(self.ts2, join="left")
from .pandas_vb_common import setup # noqa: F401 isort:skip
Reported by Pylint.
Line: 25
Column: 9
class Append:
def setup(self):
self.df1 = DataFrame(np.random.randn(10000, 4), columns=["A", "B", "C", "D"])
self.df2 = self.df1.copy()
self.df2.index = np.arange(10000, 20000)
self.mdf1 = self.df1.copy()
self.mdf1["obj1"] = "bar"
self.mdf1["obj2"] = "bar"
Reported by Pylint.
Line: 26
Column: 9
class Append:
def setup(self):
self.df1 = DataFrame(np.random.randn(10000, 4), columns=["A", "B", "C", "D"])
self.df2 = self.df1.copy()
self.df2.index = np.arange(10000, 20000)
self.mdf1 = self.df1.copy()
self.mdf1["obj1"] = "bar"
self.mdf1["obj2"] = "bar"
self.mdf1["int1"] = 5
Reported by Pylint.
Line: 28
Column: 9
self.df1 = DataFrame(np.random.randn(10000, 4), columns=["A", "B", "C", "D"])
self.df2 = self.df1.copy()
self.df2.index = np.arange(10000, 20000)
self.mdf1 = self.df1.copy()
self.mdf1["obj1"] = "bar"
self.mdf1["obj2"] = "bar"
self.mdf1["int1"] = 5
self.mdf1 = self.mdf1._consolidate()
self.mdf2 = self.mdf1.copy()
Reported by Pylint.
Line: 32
Column: 21
self.mdf1["obj1"] = "bar"
self.mdf1["obj2"] = "bar"
self.mdf1["int1"] = 5
self.mdf1 = self.mdf1._consolidate()
self.mdf2 = self.mdf1.copy()
self.mdf2.index = self.df2.index
def time_append_homogenous(self):
self.df1.append(self.df2)
Reported by Pylint.
Line: 32
Column: 9
self.mdf1["obj1"] = "bar"
self.mdf1["obj2"] = "bar"
self.mdf1["int1"] = 5
self.mdf1 = self.mdf1._consolidate()
self.mdf2 = self.mdf1.copy()
self.mdf2.index = self.df2.index
def time_append_homogenous(self):
self.df1.append(self.df2)
Reported by Pylint.
Line: 33
Column: 9
self.mdf1["obj2"] = "bar"
self.mdf1["int1"] = 5
self.mdf1 = self.mdf1._consolidate()
self.mdf2 = self.mdf1.copy()
self.mdf2.index = self.df2.index
def time_append_homogenous(self):
self.df1.append(self.df2)
Reported by Pylint.