The following issues were found

pandas/tests/plotting/test_hist_method.py
193 issues
Unable to import 'pytest'
Error

Line: 5 Column: 1

              import re

import numpy as np
import pytest

import pandas.util._test_decorators as td

from pandas import (
    DataFrame,

            

Reported by Pylint.

Method 'plt' has no 'subplots' member
Error

Line: 45 Column: 19

                      with tm.assert_produces_warning(UserWarning):
            _check_plot_works(self.ts.hist, by=self.ts.index.month, bins=5)

        fig, ax = self.plt.subplots(1, 1)
        _check_plot_works(self.ts.hist, ax=ax, default_axes=True)
        _check_plot_works(self.ts.hist, ax=ax, figure=fig, default_axes=True)
        _check_plot_works(self.ts.hist, figure=fig, default_axes=True)
        tm.close()


            

Reported by Pylint.

Method 'plt' has no 'subplots' member
Error

Line: 51 Column: 27

                      _check_plot_works(self.ts.hist, figure=fig, default_axes=True)
        tm.close()

        fig, (ax1, ax2) = self.plt.subplots(1, 2)
        _check_plot_works(self.ts.hist, figure=fig, ax=ax1, default_axes=True)
        _check_plot_works(self.ts.hist, figure=fig, ax=ax2, default_axes=True)

        msg = (
            "Cannot pass 'figure' when using the 'by' argument, since a new 'Figure' "

            

Reported by Pylint.

Method 'plt' has no 'get_fignums' member
Error

Line: 132 Column: 20

                  def test_hist_by_no_extra_plots(self):
        df = self.hist_df
        axes = df.height.hist(by=df.gender)  # noqa
        assert len(self.plt.get_fignums()) == 1

    def test_plot_fails_when_ax_differs_from_figure(self):
        from pylab import figure

        fig1 = figure()

            

Reported by Pylint.

Method 'plt' has no 'subplots' member
Error

Line: 184 Column: 17

                          s.hist(legend=True, by=by, label="c")

    def test_hist_kwargs(self):
        _, ax = self.plt.subplots()
        ax = self.ts.plot.hist(bins=5, ax=ax)
        assert len(ax.patches) == 5
        self._check_text_labels(ax.yaxis.get_label(), "Frequency")
        tm.close()


            

Reported by Pylint.

Method 'plt' has no 'subplots' member
Error

Line: 190 Column: 17

                      self._check_text_labels(ax.yaxis.get_label(), "Frequency")
        tm.close()

        _, ax = self.plt.subplots()
        ax = self.ts.plot.hist(orientation="horizontal", ax=ax)
        self._check_text_labels(ax.xaxis.get_label(), "Frequency")
        tm.close()

        _, ax = self.plt.subplots()

            

Reported by Pylint.

Method 'plt' has no 'subplots' member
Error

Line: 195 Column: 17

                      self._check_text_labels(ax.xaxis.get_label(), "Frequency")
        tm.close()

        _, ax = self.plt.subplots()
        ax = self.ts.plot.hist(align="left", stacked=True, ax=ax)
        tm.close()

    @td.skip_if_no_scipy
    def test_hist_kde(self):

            

Reported by Pylint.

Method 'plt' has no 'subplots' member
Error

Line: 202 Column: 17

                  @td.skip_if_no_scipy
    def test_hist_kde(self):

        _, ax = self.plt.subplots()
        ax = self.ts.plot.hist(logy=True, ax=ax)
        self._check_ax_scales(ax, yaxis="log")
        xlabels = ax.get_xticklabels()
        # ticks are values, thus ticklabels are blank
        self._check_text_labels(xlabels, [""] * len(xlabels))

            

Reported by Pylint.

Method 'plt' has no 'subplots' member
Error

Line: 213 Column: 17

              
        _check_plot_works(self.ts.plot.kde)
        _check_plot_works(self.ts.plot.density)
        _, ax = self.plt.subplots()
        ax = self.ts.plot.kde(logy=True, ax=ax)
        self._check_ax_scales(ax, yaxis="log")
        xlabels = ax.get_xticklabels()
        self._check_text_labels(xlabels, [""] * len(xlabels))
        ylabels = ax.get_yticklabels()

            

Reported by Pylint.

Method 'plt' has no 'subplots' member
Error

Line: 223 Column: 17

              
    @td.skip_if_no_scipy
    def test_hist_kde_color(self):
        _, ax = self.plt.subplots()
        ax = self.ts.plot.hist(logy=True, bins=10, color="b", ax=ax)
        self._check_ax_scales(ax, yaxis="log")
        assert len(ax.patches) == 10
        self._check_colors(ax.patches, facecolors=["b"] * 10)


            

Reported by Pylint.

pandas/tests/indexing/multiindex/test_loc.py
189 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

from pandas.errors import PerformanceWarning

import pandas as pd
from pandas import (
    DataFrame,
    Index,

            

Reported by Pylint.

Instance of 'tuple' has no 'get_loc' member
Error

Line: 748 Column: 11

                  assert mi.get_loc("2001-01") == slice(0, 31, None)
    assert index.get_loc("2001-01") == slice(0, 31, None)

    loc = mi[::2].get_loc("2001-01")
    expected = index[::2].get_loc("2001-01")
    assert loc == expected

    loc = mi.repeat(2).get_loc("2001-01")
    expected = index.repeat(2).get_loc("2001-01")

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 79 Column: 13

                      )

        with pytest.raises(KeyError, match=r"^2$"):
            df.loc[2]

    def test_loc_getitem_list_of_tuples_with_multiindex(
        self, multiindex_year_month_day_dataframe_random_data
    ):
        ser = multiindex_year_month_day_dataframe_random_data["A"]

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 195 Column: 13

                      )

        with pytest.raises(KeyError, match=r"^2$"):
            df.loc[2]

    @pytest.mark.parametrize("key, pos", [([2, 4], [0, 1]), ([2], []), ([2, 3], [])])
    def test_loc_multiindex_list_missing_label(self, key, pos):
        # GH 27148 - lists with missing labels _do_ raise
        df = DataFrame(

            

Reported by Pylint.

Unused argument 'pos'
Error

Line: 198 Column: 59

                          df.loc[2]

    @pytest.mark.parametrize("key, pos", [([2, 4], [0, 1]), ([2], []), ([2, 3], [])])
    def test_loc_multiindex_list_missing_label(self, key, pos):
        # GH 27148 - lists with missing labels _do_ raise
        df = DataFrame(
            np.random.randn(3, 3),
            columns=[[2, 2, 4], [6, 8, 10]],
            index=[[4, 4, 8], [8, 10, 12]],

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 207 Column: 13

                      )

        with pytest.raises(KeyError, match="not in index"):
            df.loc[key]

    def test_loc_multiindex_too_many_dims_raises(self):
        # GH 14885
        s = Series(
            range(8),

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 217 Column: 13

                      )

        with pytest.raises(KeyError, match=r"^\('a', 'b'\)$"):
            s.loc["a", "b"]
        with pytest.raises(KeyError, match=r"^\('a', 'd', 'g'\)$"):
            s.loc["a", "d", "g"]
        with pytest.raises(IndexingError, match="Too many indexers"):
            s.loc["a", "d", "g", "j"]


            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 219 Column: 13

                      with pytest.raises(KeyError, match=r"^\('a', 'b'\)$"):
            s.loc["a", "b"]
        with pytest.raises(KeyError, match=r"^\('a', 'd', 'g'\)$"):
            s.loc["a", "d", "g"]
        with pytest.raises(IndexingError, match="Too many indexers"):
            s.loc["a", "d", "g", "j"]

    def test_loc_multiindex_indexer_none(self):


            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 221 Column: 13

                      with pytest.raises(KeyError, match=r"^\('a', 'd', 'g'\)$"):
            s.loc["a", "d", "g"]
        with pytest.raises(IndexingError, match="Too many indexers"):
            s.loc["a", "d", "g", "j"]

    def test_loc_multiindex_indexer_none(self):

        # GH6788
        # multi-index indexer is None (meaning take all)

            

Reported by Pylint.

Redefining name 'single_level_multiindex' from outer scope (line 18)
Error

Line: 276 Column: 41

                      result = s.loc[2:4:2, "a":"c"]
        tm.assert_series_equal(result, expected)

    def test_get_loc_single_level(self, single_level_multiindex):
        single_level = single_level_multiindex
        s = Series(np.random.randn(len(single_level)), index=single_level)
        for k in single_level.values:
            s[k]


            

Reported by Pylint.

pandas/tests/arrays/categorical/test_repr.py
189 issues
Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np

from pandas import (
    Categorical,
    CategoricalIndex,
    Series,
    date_range,
    option_context,
    period_range,

            

Reported by Pylint.

Missing class docstring
Error

Line: 15 Column: 1

              from pandas.tests.arrays.categorical.common import TestCategorical


class TestCategoricalReprWithFactor(TestCategorical):
    def test_print(self):
        expected = [
            "['a', 'b', 'b', 'a', 'a', 'c', 'c', 'c']",
            "Categories (3, object): ['a' < 'b' < 'c']",
        ]

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 16 Column: 5

              

class TestCategoricalReprWithFactor(TestCategorical):
    def test_print(self):
        expected = [
            "['a', 'b', 'b', 'a', 'a', 'c', 'c', 'c']",
            "Categories (3, object): ['a' < 'b' < 'c']",
        ]
        expected = "\n".join(expected)

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 23
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                      ]
        expected = "\n".join(expected)
        actual = repr(self.factor)
        assert actual == expected


class TestCategoricalRepr:
    def test_big_print(self):
        factor = Categorical([0, 1, 2, 0, 1, 2] * 100, ["a", "b", "c"], fastpath=True)

            

Reported by Bandit.

Too many public methods (22/20)
Error

Line: 26 Column: 1

                      assert actual == expected


class TestCategoricalRepr:
    def test_big_print(self):
        factor = Categorical([0, 1, 2, 0, 1, 2] * 100, ["a", "b", "c"], fastpath=True)
        expected = [
            "['a', 'b', 'c', 'a', 'b', ..., 'b', 'c', 'a', 'b', 'c']",
            "Length: 600",

            

Reported by Pylint.

Missing class docstring
Error

Line: 26 Column: 1

                      assert actual == expected


class TestCategoricalRepr:
    def test_big_print(self):
        factor = Categorical([0, 1, 2, 0, 1, 2] * 100, ["a", "b", "c"], fastpath=True)
        expected = [
            "['a', 'b', 'c', 'a', 'b', ..., 'b', 'c', 'a', 'b', 'c']",
            "Length: 600",

            

Reported by Pylint.

Method could be a function
Error

Line: 27 Column: 5

              

class TestCategoricalRepr:
    def test_big_print(self):
        factor = Categorical([0, 1, 2, 0, 1, 2] * 100, ["a", "b", "c"], fastpath=True)
        expected = [
            "['a', 'b', 'c', 'a', 'b', ..., 'b', 'c', 'a', 'b', 'c']",
            "Length: 600",
            "Categories (3, object): ['a', 'b', 'c']",

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 27 Column: 5

              

class TestCategoricalRepr:
    def test_big_print(self):
        factor = Categorical([0, 1, 2, 0, 1, 2] * 100, ["a", "b", "c"], fastpath=True)
        expected = [
            "['a', 'b', 'c', 'a', 'b', ..., 'b', 'c', 'a', 'b', 'c']",
            "Length: 600",
            "Categories (3, object): ['a', 'b', 'c']",

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 38
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

              
        actual = repr(factor)

        assert actual == expected

    def test_empty_print(self):
        factor = Categorical([], ["a", "b", "c"])
        expected = "[], Categories (3, object): ['a', 'b', 'c']"
        actual = repr(factor)

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 40 Column: 5

              
        assert actual == expected

    def test_empty_print(self):
        factor = Categorical([], ["a", "b", "c"])
        expected = "[], Categories (3, object): ['a', 'b', 'c']"
        actual = repr(factor)
        assert actual == expected


            

Reported by Pylint.

pandas/plotting/_matplotlib/core.py
188 issues
Method 'plt' has no 'draw_if_interactive' member
Error

Line: 323 Column: 9

                          return self.data.shape[1]

    def draw(self):
        self.plt.draw_if_interactive()

    def generate(self):
        self._args_adjust()
        self._compute_plot_data()
        self._setup_subplots()

            

Reported by Pylint.

Method 'plt' has no 'figure' member
Error

Line: 386 Column: 23

                          )
        else:
            if self.ax is None:
                fig = self.plt.figure(figsize=self.figsize)
                axes = fig.add_subplot(111)
            else:
                fig = self.ax.get_figure()
                if self.figsize is not None:
                    fig.set_size_inches(self.figsize)

            

Reported by Pylint.

Method 'plt' has no 'cm' member
Error

Line: 1085 Column: 16

              
        # pandas uses colormap, matplotlib uses cmap.
        cmap = self.colormap or "Greys"
        cmap = self.plt.cm.get_cmap(cmap)
        color = self.kwds.pop("color", None)
        if c is not None and color is not None:
            raise TypeError("Specify exactly one of `c` and `color`")
        elif c is None and color is None:
            c_values = self.plt.rcParams["patch.facecolor"]

            

Reported by Pylint.

Method 'plt' has no 'rcParams' member
Error

Line: 1090 Column: 24

                      if c is not None and color is not None:
            raise TypeError("Specify exactly one of `c` and `color`")
        elif c is None and color is None:
            c_values = self.plt.rcParams["patch.facecolor"]
        elif color is not None:
            c_values = color
        elif color_by_categorical:
            c_values = self.data[c].cat.codes
        elif c_is_column:

            

Reported by Pylint.

Method 'plt' has no 'cm' member
Error

Line: 1162 Column: 16

                      ax = self.axes[0]
        # pandas uses colormap, matplotlib uses cmap.
        cmap = self.colormap or "BuGn"
        cmap = self.plt.cm.get_cmap(cmap)
        cb = self.kwds.pop("colorbar", True)

        if C is None:
            c_values = None
        else:

            

Reported by Pylint.

Redefining name 'table' from outer scope (line 56)
Error

Line: 127 Column: 9

                      fontsize=None,
        secondary_y=False,
        colormap=None,
        table=False,
        layout=None,
        include_bool=False,
        column: IndexLabel | None = None,
        **kwds,
    ):

            

Reported by Pylint.

TODO: Might deprecate `column` argument in future PR (#28373)
Error

Line: 146 Column: 3

              
        # Assign the rest of columns into self.columns if by is explicitly defined
        # while column is not, only need `columns` in hist/box plot when it's DF
        # TODO: Might deprecate `column` argument in future PR (#28373)
        if isinstance(data, DataFrame):
            if column:
                self.columns = com.maybe_make_list(column)
            else:
                if self.by is None:

            

Reported by Pylint.

TODO: use Matplotlib public API when available
Error

Line: 359 Column: 3

                      else:
            # otherwise, create twin axes
            orig_ax, new_ax = ax, ax.twinx()
            # TODO: use Matplotlib public API when available
            new_ax._get_lines = orig_ax._get_lines
            new_ax._get_patches_for_fill = orig_ax._get_patches_for_fill
            orig_ax.right_ax, new_ax.left_ax = new_ax, orig_ax

            if not self._has_plotted_object(orig_ax):  # no data on left y

            

Reported by Pylint.

Access to a protected member _get_lines of a client class
Error

Line: 360 Column: 33

                          # otherwise, create twin axes
            orig_ax, new_ax = ax, ax.twinx()
            # TODO: use Matplotlib public API when available
            new_ax._get_lines = orig_ax._get_lines
            new_ax._get_patches_for_fill = orig_ax._get_patches_for_fill
            orig_ax.right_ax, new_ax.left_ax = new_ax, orig_ax

            if not self._has_plotted_object(orig_ax):  # no data on left y
                orig_ax.get_yaxis().set_visible(False)

            

Reported by Pylint.

Access to a protected member _get_lines of a client class
Error

Line: 360 Column: 13

                          # otherwise, create twin axes
            orig_ax, new_ax = ax, ax.twinx()
            # TODO: use Matplotlib public API when available
            new_ax._get_lines = orig_ax._get_lines
            new_ax._get_patches_for_fill = orig_ax._get_patches_for_fill
            orig_ax.right_ax, new_ax.left_ax = new_ax, orig_ax

            if not self._has_plotted_object(orig_ax):  # no data on left y
                orig_ax.get_yaxis().set_visible(False)

            

Reported by Pylint.

pandas/tests/io/pytables/test_store.py
186 issues
Unable to import 'pytest'
Error

Line: 11 Column: 1

              )

import numpy as np
import pytest

import pandas as pd
from pandas import (
    DataFrame,
    DatetimeIndex,

            

Reported by Pylint.

Instance of 'ExtensionIndex' has no 'weekday' member
Error

Line: 471 Column: 16

                  dt = datetime.datetime(2013, 4, 30)
    dts = date_range(dt, periods=5, freq=bday_egypt)

    s = Series(dts.weekday, dts).map(Series("Mon Tue Wed Thu Fri Sat Sun".split()))

    with ensure_clean_store(setup_path) as store:

        store.put("fixed", s)
        result = store.select("fixed")

            

Reported by Pylint.

Instance of 'Index' has no 'weekday' member
Error

Line: 471 Column: 16

                  dt = datetime.datetime(2013, 4, 30)
    dts = date_range(dt, periods=5, freq=bday_egypt)

    s = Series(dts.weekday, dts).map(Series("Mon Tue Wed Thu Fri Sat Sun".split()))

    with ensure_clean_store(setup_path) as store:

        store.put("fixed", s)
        result = store.select("fixed")

            

Reported by Pylint.

Instance of 'DatetimeIndex' has no 'month' member
Error

Line: 661 Column: 19

                      )
        store.append("df", df)
        c = store.select_column("df", "index")
        where = c[DatetimeIndex(c).month == 5].index
        expected = df.iloc[where]

        # locations
        result = store.select("df", where=where)
        tm.assert_frame_equal(result, expected)

            

Reported by Pylint.

Access to a protected member _consolidate of a client class
Error

Line: 133 Column: 14

                      df["datetime1"] = datetime.datetime(2001, 1, 2, 0, 0)
        df["datetime2"] = datetime.datetime(2001, 1, 3, 0, 0)
        df.loc[df.index[3:6], ["obj1"]] = np.nan
        df = df._consolidate()._convert(datetime=True)

        with catch_warnings(record=True):
            simplefilter("ignore", pd.errors.PerformanceWarning)
            store["df"] = df


            

Reported by Pylint.

Access to a protected member _convert of a client class
Error

Line: 133 Column: 14

                      df["datetime1"] = datetime.datetime(2001, 1, 2, 0, 0)
        df["datetime2"] = datetime.datetime(2001, 1, 3, 0, 0)
        df.loc[df.index[3:6], ["obj1"]] = np.nan
        df = df._consolidate()._convert(datetime=True)

        with catch_warnings(record=True):
            simplefilter("ignore", pd.errors.PerformanceWarning)
            store["df"] = df


            

Reported by Pylint.

Access to a protected member _handle of a client class
Error

Line: 140 Column: 36

                          store["df"] = df

        # make a random group in hdf space
        store._handle.create_group(store._handle.root, "bah")

        assert store.filename in repr(store)
        assert store.filename in str(store)
        store.info()


            

Reported by Pylint.

Access to a protected member _handle of a client class
Error

Line: 140 Column: 9

                          store["df"] = df

        # make a random group in hdf space
        store._handle.create_group(store._handle.root, "bah")

        assert store.filename in repr(store)
        assert store.filename in str(store)
        store.info()


            

Reported by Pylint.

Access to a protected member _v_attrs of a client class
Error

Line: 187 Column: 16

                      _maybe_remove(store, "df1")
        store.append("df1", df[:10])
        store.append("df1", df[10:])
        assert store.root.a._v_attrs.pandas_version == "0.15.2"
        assert store.root.b._v_attrs.pandas_version == "0.15.2"
        assert store.root.df1._v_attrs.pandas_version == "0.15.2"

        # write a file and wipe its versioning
        _maybe_remove(store, "df2")

            

Reported by Pylint.

Access to a protected member _v_attrs of a client class
Error

Line: 188 Column: 16

                      store.append("df1", df[:10])
        store.append("df1", df[10:])
        assert store.root.a._v_attrs.pandas_version == "0.15.2"
        assert store.root.b._v_attrs.pandas_version == "0.15.2"
        assert store.root.df1._v_attrs.pandas_version == "0.15.2"

        # write a file and wipe its versioning
        _maybe_remove(store, "df2")
        store.append("df2", df)

            

Reported by Pylint.

pandas/tests/series/indexing/test_getitem.py
184 issues
Unable to import 'pytest'
Error

Line: 11 Column: 1

              )

import numpy as np
import pytest

from pandas._libs.tslibs import (
    conversion,
    timezones,
)

            

Reported by Pylint.

No name 'timezones' in module 'pandas._libs.tslibs'
Error

Line: 13 Column: 1

              import numpy as np
import pytest

from pandas._libs.tslibs import (
    conversion,
    timezones,
)

from pandas.core.dtypes.common import is_scalar

            

Reported by Pylint.

No name 'conversion' in module 'pandas._libs.tslibs'
Error

Line: 13 Column: 1

              import numpy as np
import pytest

from pandas._libs.tslibs import (
    conversion,
    timezones,
)

from pandas.core.dtypes.common import is_scalar

            

Reported by Pylint.

Instance of 'ExtensionIndex' has no 'hour' member
Error

Line: 123 Column: 39

                      index = date_range(
            start="2012-12-24 16:00", end="2012-12-24 18:00", freq="H", tz=tzstr
        )
        ts = Series(index=index, data=index.hour)
        time_pandas = Timestamp("2012-12-24 17:00", tz=tzstr)

        dt = datetime(2012, 12, 24, 17, 0)
        time_datetime = conversion.localize_pydatetime(dt, tz)
        assert ts[time_pandas] == ts[time_datetime]

            

Reported by Pylint.

Instance of 'Index' has no 'hour' member
Error

Line: 123 Column: 39

                      index = date_range(
            start="2012-12-24 16:00", end="2012-12-24 18:00", freq="H", tz=tzstr
        )
        ts = Series(index=index, data=index.hour)
        time_pandas = Timestamp("2012-12-24 17:00", tz=tzstr)

        dt = datetime(2012, 12, 24, 17, 0)
        time_datetime = conversion.localize_pydatetime(dt, tz)
        assert ts[time_pandas] == ts[time_datetime]

            

Reported by Pylint.

Instance of 'Index' has no 'hour' member
Error

Line: 142 Column: 17

                      rng = date_range("1/1/2000", "1/5/2000", freq="5min")
        ts = Series(np.random.randn(len(rng)), index=rng)

        mask = (rng.hour == 9) & (rng.minute == 30)
        result = ts[time(9, 30)]
        expected = ts[mask]
        result.index = result.index._with_freq(None)
        tm.assert_series_equal(result, expected)


            

Reported by Pylint.

Instance of 'ExtensionIndex' has no 'minute' member
Error

Line: 142 Column: 35

                      rng = date_range("1/1/2000", "1/5/2000", freq="5min")
        ts = Series(np.random.randn(len(rng)), index=rng)

        mask = (rng.hour == 9) & (rng.minute == 30)
        result = ts[time(9, 30)]
        expected = ts[mask]
        result.index = result.index._with_freq(None)
        tm.assert_series_equal(result, expected)


            

Reported by Pylint.

Instance of 'Index' has no 'minute' member
Error

Line: 142 Column: 35

                      rng = date_range("1/1/2000", "1/5/2000", freq="5min")
        ts = Series(np.random.randn(len(rng)), index=rng)

        mask = (rng.hour == 9) & (rng.minute == 30)
        result = ts[time(9, 30)]
        expected = ts[mask]
        result.index = result.index._with_freq(None)
        tm.assert_series_equal(result, expected)


            

Reported by Pylint.

Instance of 'ExtensionIndex' has no 'hour' member
Error

Line: 142 Column: 17

                      rng = date_range("1/1/2000", "1/5/2000", freq="5min")
        ts = Series(np.random.randn(len(rng)), index=rng)

        mask = (rng.hour == 9) & (rng.minute == 30)
        result = ts[time(9, 30)]
        expected = ts[mask]
        result.index = result.index._with_freq(None)
        tm.assert_series_equal(result, expected)


            

Reported by Pylint.

Instance of 'Index' has no '_with_freq' member
Error

Line: 341 Column: 15

                  @pytest.mark.parametrize("box", [list, np.array, Index])
    def test_getitem_intlist_intervalindex_non_int(self, box):
        # GH#33404 fall back to positional since ints are unambiguous
        dti = date_range("2000-01-03", periods=3)._with_freq(None)
        ii = pd.IntervalIndex.from_breaks(dti)
        ser = Series(range(len(ii)), index=ii)

        expected = ser.iloc[:1]
        key = box([0])

            

Reported by Pylint.

pandas/tests/indexes/datetimes/test_setops.py
182 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              from datetime import datetime

import numpy as np
import pytest

import pandas.util._test_decorators as td

import pandas as pd
from pandas import (

            

Reported by Pylint.

Instance of 'DatetimeIndex' has no 'freq' member
Error

Line: 99 Column: 31

              
        result = ordered[:0].union(ordered, sort=sort)
        tm.assert_index_equal(result, ordered)
        assert result.freq == ordered.freq

    def test_union_bug_1730(self, sort):
        rng_a = date_range("1/1/2012", periods=4, freq="3H")
        rng_b = date_range("1/1/2012", periods=4, freq="4H")


            

Reported by Pylint.

Instance of 'DatetimeIndex' has no 'freq' member
Error

Line: 258 Column: 16

                      # GH 7880
        rng4 = date_range("7/1/2000", "7/31/2000", freq="D", tz=tz, name="idx")
        expected4 = DatetimeIndex([], tz=tz, name="idx")
        assert expected4.freq is None

        for (rng, expected) in [
            (rng2, expected2),
            (rng3, expected3),
            (rng4, expected4),

            

Reported by Pylint.

Instance of 'Index' has no 'freq' member
Error

Line: 280 Column: 31

                      rng = date_range("6/1/2000", "6/15/2000", freq=freq, tz=tz)
        result = rng[0:0].intersection(rng)
        assert len(result) == 0
        assert result.freq == rng.freq

        result = rng.intersection(rng[0:0])
        assert len(result) == 0
        assert result.freq == rng.freq


            

Reported by Pylint.

Instance of 'ExtensionIndex' has no 'freq' member
Error

Line: 280 Column: 31

                      rng = date_range("6/1/2000", "6/15/2000", freq=freq, tz=tz)
        result = rng[0:0].intersection(rng)
        assert len(result) == 0
        assert result.freq == rng.freq

        result = rng.intersection(rng[0:0])
        assert len(result) == 0
        assert result.freq == rng.freq


            

Reported by Pylint.

Instance of 'Index' has no 'freq' member
Error

Line: 284 Column: 31

              
        result = rng.intersection(rng[0:0])
        assert len(result) == 0
        assert result.freq == rng.freq

        # no overlap GH#33604
        check_freq = freq != "T"  # We don't preserve freq on non-anchored offsets
        result = rng[:3].intersection(rng[-3:])
        tm.assert_index_equal(result, rng[:0])

            

Reported by Pylint.

Instance of 'ExtensionIndex' has no 'freq' member
Error

Line: 284 Column: 31

              
        result = rng.intersection(rng[0:0])
        assert len(result) == 0
        assert result.freq == rng.freq

        # no overlap GH#33604
        check_freq = freq != "T"  # We don't preserve freq on non-anchored offsets
        result = rng[:3].intersection(rng[-3:])
        tm.assert_index_equal(result, rng[:0])

            

Reported by Pylint.

Instance of 'ExtensionIndex' has no 'freq' member
Error

Line: 292 Column: 35

                      tm.assert_index_equal(result, rng[:0])
        if check_freq:
            # We don't preserve freq on non-anchored offsets
            assert result.freq == rng.freq

        # swapped left and right
        result = rng[-3:].intersection(rng[:3])
        tm.assert_index_equal(result, rng[:0])
        if check_freq:

            

Reported by Pylint.

Instance of 'Index' has no 'freq' member
Error

Line: 292 Column: 35

                      tm.assert_index_equal(result, rng[:0])
        if check_freq:
            # We don't preserve freq on non-anchored offsets
            assert result.freq == rng.freq

        # swapped left and right
        result = rng[-3:].intersection(rng[:3])
        tm.assert_index_equal(result, rng[:0])
        if check_freq:

            

Reported by Pylint.

Instance of 'Index' has no 'freq' member
Error

Line: 299 Column: 35

                      tm.assert_index_equal(result, rng[:0])
        if check_freq:
            # We don't preserve freq on non-anchored offsets
            assert result.freq == rng.freq

    def test_intersection_bug_1708(self):
        from pandas import DateOffset

        index_1 = date_range("1/1/2012", periods=4, freq="12H")

            

Reported by Pylint.

pandas/tests/arrays/sparse/test_arithmetics.py
181 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              import operator

import numpy as np
import pytest

from pandas.compat import np_version_under1p20

import pandas as pd
import pandas._testing as tm

            

Reported by Pylint.

Argument 'dtype' passed by position and keyword in function call
Error

Line: 284 Column: 18

                      # have to specify dtype explicitly until fixing GH 667
        dtype = np.int64

        values = self._base([0, 1, 2, 0, 0, 0, 1, 2, 1, 0], dtype=dtype)
        rvalues = self._base([2, 0, 2, 3, 0, 0, 1, 5, 2, 0], dtype=dtype)

        a = self._klass(values, dtype=dtype, kind=kind)
        assert a.dtype == SparseDtype(dtype)
        b = self._klass(rvalues, dtype=dtype, kind=kind)

            

Reported by Pylint.

Argument 'dtype' passed by position and keyword in function call
Error

Line: 285 Column: 19

                      dtype = np.int64

        values = self._base([0, 1, 2, 0, 0, 0, 1, 2, 1, 0], dtype=dtype)
        rvalues = self._base([2, 0, 2, 3, 0, 0, 1, 5, 2, 0], dtype=dtype)

        a = self._klass(values, dtype=dtype, kind=kind)
        assert a.dtype == SparseDtype(dtype)
        b = self._klass(rvalues, dtype=dtype, kind=kind)
        assert b.dtype == SparseDtype(dtype)

            

Reported by Pylint.

Argument 'dtype' passed by position and keyword in function call
Error

Line: 318 Column: 18

                      dtype = "int64"
        # int32 NI ATM

        values = self._base([0, 1, 2, 0, 0, 0, 1, 2, 1, 0], dtype=dtype)
        rvalues = self._base([2, 0, 2, 3, 0, 0, 1, 5, 2, 0], dtype=dtype)

        a = self._klass(values, dtype=dtype, kind=kind)
        b = self._klass(rvalues, dtype=dtype, kind=kind)
        self._check_comparison_ops(a, b, values, rvalues)

            

Reported by Pylint.

Argument 'dtype' passed by position and keyword in function call
Error

Line: 319 Column: 19

                      # int32 NI ATM

        values = self._base([0, 1, 2, 0, 0, 0, 1, 2, 1, 0], dtype=dtype)
        rvalues = self._base([2, 0, 2, 3, 0, 0, 1, 5, 2, 0], dtype=dtype)

        a = self._klass(values, dtype=dtype, kind=kind)
        b = self._klass(rvalues, dtype=dtype, kind=kind)
        self._check_comparison_ops(a, b, values, rvalues)
        self._check_comparison_ops(a, b * 0, values, rvalues * 0)

            

Reported by Pylint.

Argument 'dtype' passed by position and keyword in function call
Error

Line: 342 Column: 18

                  def test_bool_same_index(self, kind, fill_value):
        # GH 14000
        # when sp_index are the same
        values = self._base([True, False, True, True], dtype=np.bool_)
        rvalues = self._base([True, False, True, True], dtype=np.bool_)

        a = self._klass(values, kind=kind, dtype=np.bool_, fill_value=fill_value)
        b = self._klass(rvalues, kind=kind, dtype=np.bool_, fill_value=fill_value)
        self._check_logical_ops(a, b, values, rvalues)

            

Reported by Pylint.

Argument 'dtype' passed by position and keyword in function call
Error

Line: 343 Column: 19

                      # GH 14000
        # when sp_index are the same
        values = self._base([True, False, True, True], dtype=np.bool_)
        rvalues = self._base([True, False, True, True], dtype=np.bool_)

        a = self._klass(values, kind=kind, dtype=np.bool_, fill_value=fill_value)
        b = self._klass(rvalues, kind=kind, dtype=np.bool_, fill_value=fill_value)
        self._check_logical_ops(a, b, values, rvalues)


            

Reported by Pylint.

Argument 'dtype' passed by position and keyword in function call
Error

Line: 353 Column: 18

                  def test_bool_array_logical(self, kind, fill_value):
        # GH 14000
        # when sp_index are the same
        values = self._base([True, False, True, False, True, True], dtype=np.bool_)
        rvalues = self._base([True, False, False, True, False, True], dtype=np.bool_)

        a = self._klass(values, kind=kind, dtype=np.bool_, fill_value=fill_value)
        b = self._klass(rvalues, kind=kind, dtype=np.bool_, fill_value=fill_value)
        self._check_logical_ops(a, b, values, rvalues)

            

Reported by Pylint.

Argument 'dtype' passed by position and keyword in function call
Error

Line: 354 Column: 19

                      # GH 14000
        # when sp_index are the same
        values = self._base([True, False, True, False, True, True], dtype=np.bool_)
        rvalues = self._base([True, False, False, True, False, True], dtype=np.bool_)

        a = self._klass(values, kind=kind, dtype=np.bool_, fill_value=fill_value)
        b = self._klass(rvalues, kind=kind, dtype=np.bool_, fill_value=fill_value)
        self._check_logical_ops(a, b, values, rvalues)


            

Reported by Pylint.

Argument 'dtype' passed by position and keyword in function call
Error

Line: 374 Column: 19

                      rdtype = "int64"

        values = self._base([np.nan, 1, 2, 0, np.nan, 0, 1, 2, 1, np.nan])
        rvalues = self._base([2, 0, 2, 3, 0, 0, 1, 5, 2, 0], dtype=rdtype)

        a = self._klass(values, kind=kind)
        b = self._klass(rvalues, kind=kind)
        assert b.dtype == SparseDtype(rdtype)


            

Reported by Pylint.

pandas/tests/io/test_html.py
179 issues
Unable to import 'pytest'
Error

Line: 14 Column: 1

              from urllib.error import URLError

import numpy as np
import pytest

from pandas.compat import is_platform_windows
from pandas.errors import ParserError
import pandas.util._test_decorators as td


            

Reported by Pylint.

Unable to import 'bs4'
Error

Line: 74 Column: 5

              @td.skip_if_no("bs4")
@td.skip_if_no("html5lib")
def test_bs4_version_fails(monkeypatch, datapath):
    import bs4

    monkeypatch.setattr(bs4, "__version__", "4.2")
    with pytest.raises(ImportError, match="Pandas requires version"):
        read_html(datapath("io", "data", "html", "spam.html"), flavor="bs4")


            

Reported by Pylint.

Argument 'flavor' passed by position and keyword in function call
Error

Line: 1111 Column: 9

                  @pytest.mark.slow
    def test_fallback_success(self, datapath):
        banklist_data = datapath("io", "data", "html", "banklist.html")
        self.read_html(banklist_data, match=".*Water.*", flavor=["lxml", "html5lib"])

    def test_to_html_timestamp(self):
        rng = date_range("2000-01-01", periods=10)
        df = DataFrame(np.random.randn(10, 4), index=rng)


            

Reported by Pylint.

Attribute 'spam_data' defined outside __init__
Error

Line: 111 Column: 9

              class TestReadHtml:
    @pytest.fixture(autouse=True)
    def set_files(self, datapath):
        self.spam_data = datapath("io", "data", "html", "spam.html")
        self.spam_data_kwargs = {}
        self.spam_data_kwargs["encoding"] = "UTF-8"
        self.banklist_data = datapath("io", "data", "html", "banklist.html")

    @pytest.fixture(autouse=True, scope="function")

            

Reported by Pylint.

Attribute 'spam_data_kwargs' defined outside __init__
Error

Line: 112 Column: 9

                  @pytest.fixture(autouse=True)
    def set_files(self, datapath):
        self.spam_data = datapath("io", "data", "html", "spam.html")
        self.spam_data_kwargs = {}
        self.spam_data_kwargs["encoding"] = "UTF-8"
        self.banklist_data = datapath("io", "data", "html", "banklist.html")

    @pytest.fixture(autouse=True, scope="function")
    def set_defaults(self, flavor, request):

            

Reported by Pylint.

Attribute 'banklist_data' defined outside __init__
Error

Line: 114 Column: 9

                      self.spam_data = datapath("io", "data", "html", "spam.html")
        self.spam_data_kwargs = {}
        self.spam_data_kwargs["encoding"] = "UTF-8"
        self.banklist_data = datapath("io", "data", "html", "banklist.html")

    @pytest.fixture(autouse=True, scope="function")
    def set_defaults(self, flavor, request):
        self.read_html = partial(read_html, flavor=flavor)
        yield

            

Reported by Pylint.

Unused argument 'request'
Error

Line: 117 Column: 36

                      self.banklist_data = datapath("io", "data", "html", "banklist.html")

    @pytest.fixture(autouse=True, scope="function")
    def set_defaults(self, flavor, request):
        self.read_html = partial(read_html, flavor=flavor)
        yield

    def test_to_html_compat(self):
        df = (

            

Reported by Pylint.

Attribute 'read_html' defined outside __init__
Error

Line: 118 Column: 9

              
    @pytest.fixture(autouse=True, scope="function")
    def set_defaults(self, flavor, request):
        self.read_html = partial(read_html, flavor=flavor)
        yield

    def test_to_html_compat(self):
        df = (
            tm.makeCustomDataframe(

            

Reported by Pylint.

Access to a protected member _convert of a client class
Error

Line: 627 Column: 21

                      ]
        dfnew = df.applymap(try_remove_ws).replace(old, new)
        gtnew = ground_truth.applymap(try_remove_ws)
        converted = dfnew._convert(datetime=True, numeric=True)
        date_cols = ["Closing Date", "Updated Date"]
        converted[date_cols] = converted[date_cols].apply(to_datetime)
        tm.assert_frame_equal(converted, gtnew)

    @pytest.mark.slow

            

Reported by Pylint.

Redefining name 'html_encoding_file' from outer scope (line 44)
Error

Line: 1159 Column: 27

                      else:
            assert len(dfs) == 1  # Should not parse hidden table

    def test_encode(self, html_encoding_file):
        base_path = os.path.basename(html_encoding_file)
        root = os.path.splitext(base_path)[0]
        _, encoding = root.split("_")

        try:

            

Reported by Pylint.

pandas/tests/io/formats/test_to_csv.py
179 issues
Unable to import 'pytest'
Error

Line: 6 Column: 1

              import sys

import numpy as np
import pytest

import pandas as pd
from pandas import (
    DataFrame,
    compat,

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import io
import os
import sys

import numpy as np
import pytest

import pandas as pd
from pandas import (

            

Reported by Pylint.

Missing class docstring
Error

Line: 16 Column: 1

              import pandas._testing as tm


class TestToCSV:
    def test_to_csv_with_single_column(self):
        # see gh-18676, https://bugs.python.org/issue32255
        #
        # Python's CSV library adds an extraneous '""'
        # before the newline when the NaN-value is in

            

Reported by Pylint.

Too many public methods (30/20)
Error

Line: 16 Column: 1

              import pandas._testing as tm


class TestToCSV:
    def test_to_csv_with_single_column(self):
        # see gh-18676, https://bugs.python.org/issue32255
        #
        # Python's CSV library adds an extraneous '""'
        # before the newline when the NaN-value is in

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 17 Column: 5

              

class TestToCSV:
    def test_to_csv_with_single_column(self):
        # see gh-18676, https://bugs.python.org/issue32255
        #
        # Python's CSV library adds an extraneous '""'
        # before the newline when the NaN-value is in
        # the first row. Otherwise, only the newline

            

Reported by Pylint.

Method could be a function
Error

Line: 17 Column: 5

              

class TestToCSV:
    def test_to_csv_with_single_column(self):
        # see gh-18676, https://bugs.python.org/issue32255
        #
        # Python's CSV library adds an extraneous '""'
        # before the newline when the NaN-value is in
        # the first row. Otherwise, only the newline

            

Reported by Pylint.

Variable name "f" doesn't conform to snake_case naming style
Error

Line: 32 Column: 32

              """
        with tm.ensure_clean("test.csv") as path:
            df1.to_csv(path, header=None, index=None)
            with open(path) as f:
                assert f.read() == expected1

        df2 = DataFrame([1, None])
        expected2 = """\
1.0

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 33
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                      with tm.ensure_clean("test.csv") as path:
            df1.to_csv(path, header=None, index=None)
            with open(path) as f:
                assert f.read() == expected1

        df2 = DataFrame([1, None])
        expected2 = """\
1.0
""

            

Reported by Bandit.

Variable name "f" doesn't conform to snake_case naming style
Error

Line: 42 Column: 32

              """
        with tm.ensure_clean("test.csv") as path:
            df2.to_csv(path, header=None, index=None)
            with open(path) as f:
                assert f.read() == expected2

    def test_to_csv_defualt_encoding(self):
        # GH17097
        df = DataFrame({"col": ["AAAAA", "ÄÄÄÄÄ", "ßßßßß", "聞聞聞聞聞"]})

            

Reported by Pylint.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Security

Line: 43
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html

                      with tm.ensure_clean("test.csv") as path:
            df2.to_csv(path, header=None, index=None)
            with open(path) as f:
                assert f.read() == expected2

    def test_to_csv_defualt_encoding(self):
        # GH17097
        df = DataFrame({"col": ["AAAAA", "ÄÄÄÄÄ", "ßßßßß", "聞聞聞聞聞"]})


            

Reported by Bandit.