The following issues were found

pandas/tests/indexes/numeric/test_join.py
52 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

from pandas import (
    Index,
    Int64Index,
    UInt64Index,
)
import pandas._testing as tm

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import numpy as np
import pytest

from pandas import (
    Index,
    Int64Index,
    UInt64Index,
)
import pandas._testing as tm

            

Reported by Pylint.

Missing class docstring
Error

Line: 12 Column: 1

              import pandas._testing as tm


class TestJoinInt64Index:
    def test_join_non_unique(self):
        left = Index([4, 4, 3, 3])

        joined, lidx, ridx = left.join(left, return_indexers=True)


            

Reported by Pylint.

Method could be a function
Error

Line: 13 Column: 5

              

class TestJoinInt64Index:
    def test_join_non_unique(self):
        left = Index([4, 4, 3, 3])

        joined, lidx, ridx = left.join(left, return_indexers=True)

        exp_joined = Index([3, 3, 3, 3, 4, 4, 4, 4])

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 13 Column: 5

              

class TestJoinInt64Index:
    def test_join_non_unique(self):
        left = Index([4, 4, 3, 3])

        joined, lidx, ridx = left.join(left, return_indexers=True)

        exp_joined = Index([3, 3, 3, 3, 4, 4, 4, 4])

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 27 Column: 5

                      exp_ridx = np.array([2, 3, 2, 3, 0, 1, 0, 1], dtype=np.intp)
        tm.assert_numpy_array_equal(ridx, exp_ridx)

    def test_join_inner(self):
        index = Int64Index(range(0, 20, 2))
        other = Int64Index([7, 12, 25, 1, 2, 5])
        other_mono = Int64Index([1, 2, 5, 7, 12, 25])

        # not monotonic

            

Reported by Pylint.

Method could be a function
Error

Line: 27 Column: 5

                      exp_ridx = np.array([2, 3, 2, 3, 0, 1, 0, 1], dtype=np.intp)
        tm.assert_numpy_array_equal(ridx, exp_ridx)

    def test_join_inner(self):
        index = Int64Index(range(0, 20, 2))
        other = Int64Index([7, 12, 25, 1, 2, 5])
        other_mono = Int64Index([1, 2, 5, 7, 12, 25])

        # not monotonic

            

Reported by Pylint.

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

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

                      elidx = np.array([1, 6], dtype=np.intp)
        eridx = np.array([4, 1], dtype=np.intp)

        assert isinstance(res, Int64Index)
        tm.assert_index_equal(res, eres)
        tm.assert_numpy_array_equal(lidx, elidx)
        tm.assert_numpy_array_equal(ridx, eridx)

        # monotonic

            

Reported by Bandit.

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

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

              
        elidx = np.array([1, 6], dtype=np.intp)
        eridx = np.array([1, 4], dtype=np.intp)
        assert isinstance(res, Int64Index)
        tm.assert_index_equal(res, eres)
        tm.assert_numpy_array_equal(lidx, elidx)
        tm.assert_numpy_array_equal(ridx, eridx)

    def test_join_left(self):

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 63 Column: 5

                      tm.assert_numpy_array_equal(lidx, elidx)
        tm.assert_numpy_array_equal(ridx, eridx)

    def test_join_left(self):
        index = Int64Index(range(0, 20, 2))
        other = Int64Index([7, 12, 25, 1, 2, 5])
        other_mono = Int64Index([1, 2, 5, 7, 12, 25])

        # not monotonic

            

Reported by Pylint.

pandas/tests/indexes/datetimes/methods/test_shift.py
52 issues
Unable to import 'pytest'
Error

Line: 3 Column: 1

              from datetime import datetime

import pytest
import pytz

from pandas.errors import NullFrequencyError

import pandas as pd
from pandas import (

            

Reported by Pylint.

Unable to import 'pytz'
Error

Line: 4 Column: 1

              from datetime import datetime

import pytest
import pytz

from pandas.errors import NullFrequencyError

import pandas as pd
from pandas import (

            

Reported by Pylint.

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

Line: 81 Column: 28

                  def test_dti_shift_int(self):
        rng = date_range("1/1/2000", periods=20)

        result = rng + 5 * rng.freq
        expected = rng.shift(5)
        tm.assert_index_equal(result, expected)

        result = rng - 5 * rng.freq
        expected = rng.shift(-5)

            

Reported by Pylint.

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

Line: 81 Column: 28

                  def test_dti_shift_int(self):
        rng = date_range("1/1/2000", periods=20)

        result = rng + 5 * rng.freq
        expected = rng.shift(5)
        tm.assert_index_equal(result, expected)

        result = rng - 5 * rng.freq
        expected = rng.shift(-5)

            

Reported by Pylint.

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

Line: 85 Column: 28

                      expected = rng.shift(5)
        tm.assert_index_equal(result, expected)

        result = rng - 5 * rng.freq
        expected = rng.shift(-5)
        tm.assert_index_equal(result, expected)

    def test_dti_shift_no_freq(self):
        # GH#19147

            

Reported by Pylint.

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

Line: 85 Column: 28

                      expected = rng.shift(5)
        tm.assert_index_equal(result, expected)

        result = rng - 5 * rng.freq
        expected = rng.shift(-5)
        tm.assert_index_equal(result, expected)

    def test_dti_shift_no_freq(self):
        # GH#19147

            

Reported by Pylint.

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

Line: 98 Column: 17

                  @pytest.mark.parametrize("tzstr", ["US/Eastern", "dateutil/US/Eastern"])
    def test_dti_shift_localized(self, tzstr):
        dr = date_range("2011/1/1", "2012/1/1", freq="W-FRI")
        dr_tz = dr.tz_localize(tzstr)

        result = dr_tz.shift(1, "10T")
        assert result.tz == dr_tz.tz

    def test_dti_shift_across_dst(self):

            

Reported by Pylint.

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

Line: 98 Column: 17

                  @pytest.mark.parametrize("tzstr", ["US/Eastern", "dateutil/US/Eastern"])
    def test_dti_shift_localized(self, tzstr):
        dr = date_range("2011/1/1", "2012/1/1", freq="W-FRI")
        dr_tz = dr.tz_localize(tzstr)

        result = dr_tz.shift(1, "10T")
        assert result.tz == dr_tz.tz

    def test_dti_shift_across_dst(self):

            

Reported by Pylint.

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

Line: 139 Column: 32

                      rng = date_range(START, END, freq=freq)
        shifted = rng.shift(5)
        assert shifted[0] == rng[5]
        assert shifted.freq == rng.freq

        shifted = rng.shift(-5)
        assert shifted[5] == rng[0]
        assert shifted.freq == rng.freq


            

Reported by Pylint.

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

Line: 139 Column: 32

                      rng = date_range(START, END, freq=freq)
        shifted = rng.shift(5)
        assert shifted[0] == rng[5]
        assert shifted.freq == rng.freq

        shifted = rng.shift(-5)
        assert shifted[5] == rng[0]
        assert shifted.freq == rng.freq


            

Reported by Pylint.

pandas/tests/indexes/datetimes/test_join.py
52 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              from datetime import datetime

import numpy as np
import pytest

from pandas import (
    DatetimeIndex,
    Index,
    Timestamp,

            

Reported by Pylint.

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

Line: 65 Column: 16

                  def test_join_utc_convert(self, join_type):
        rng = date_range("1/1/2011", periods=100, freq="H", tz="utc")

        left = rng.tz_convert("US/Eastern")
        right = rng.tz_convert("Europe/Berlin")

        result = left.join(left[:-5], how=join_type)
        assert isinstance(result, DatetimeIndex)
        assert result.tz == left.tz

            

Reported by Pylint.

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

Line: 65 Column: 16

                  def test_join_utc_convert(self, join_type):
        rng = date_range("1/1/2011", periods=100, freq="H", tz="utc")

        left = rng.tz_convert("US/Eastern")
        right = rng.tz_convert("Europe/Berlin")

        result = left.join(left[:-5], how=join_type)
        assert isinstance(result, DatetimeIndex)
        assert result.tz == left.tz

            

Reported by Pylint.

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

Line: 66 Column: 17

                      rng = date_range("1/1/2011", periods=100, freq="H", tz="utc")

        left = rng.tz_convert("US/Eastern")
        right = rng.tz_convert("Europe/Berlin")

        result = left.join(left[:-5], how=join_type)
        assert isinstance(result, DatetimeIndex)
        assert result.tz == left.tz


            

Reported by Pylint.

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

Line: 66 Column: 17

                      rng = date_range("1/1/2011", periods=100, freq="H", tz="utc")

        left = rng.tz_convert("US/Eastern")
        right = rng.tz_convert("Europe/Berlin")

        result = left.join(left[:-5], how=join_type)
        assert isinstance(result, DatetimeIndex)
        assert result.tz == left.tz


            

Reported by Pylint.

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

Line: 146 Column: 31

                      # GH#32157
        dti = date_range("2016-01-01", periods=10, tz=tz)
        result = dti[:5].join(dti[5:], how="outer")
        assert result.freq == dti.freq
        tm.assert_index_equal(result, dti)

        result = dti[:5].join(dti[6:], how="outer")
        assert result.freq is None
        expected = dti.delete(5)

            

Reported by Pylint.

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

Line: 146 Column: 31

                      # GH#32157
        dti = date_range("2016-01-01", periods=10, tz=tz)
        result = dti[:5].join(dti[5:], how="outer")
        assert result.freq == dti.freq
        tm.assert_index_equal(result, dti)

        result = dti[:5].join(dti[6:], how="outer")
        assert result.freq is None
        expected = dti.delete(5)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from datetime import datetime

import numpy as np
import pytest

from pandas import (
    DatetimeIndex,
    Index,
    Timestamp,

            

Reported by Pylint.

Missing class docstring
Error

Line: 21 Column: 1

              )


class TestJoin:
    def test_does_not_convert_mixed_integer(self):
        df = tm.makeCustomDataframe(
            10,
            10,
            data_gen_f=lambda *args, **kwargs: np.random.randn(),

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 22 Column: 5

              

class TestJoin:
    def test_does_not_convert_mixed_integer(self):
        df = tm.makeCustomDataframe(
            10,
            10,
            data_gen_f=lambda *args, **kwargs: np.random.randn(),
            r_idx_type="i",

            

Reported by Pylint.

pandas/tests/indexes/datetimes/test_formats.py
52 issues
Unable to import 'pytest'
Error

Line: 5 Column: 1

              
import dateutil.tz
import numpy as np
import pytest
import pytz

import pandas as pd
from pandas import (
    DatetimeIndex,

            

Reported by Pylint.

Unable to import 'pytz'
Error

Line: 6 Column: 1

              import dateutil.tz
import numpy as np
import pytest
import pytz

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

            

Reported by Pylint.

Access to a protected member _format_native_types of a client class
Error

Line: 40 Column: 14

                  # First, with no arguments.
    expected = np.array(["2017-01-01", "2017-01-02", "2017-01-03"], dtype=object)

    result = index._format_native_types()
    tm.assert_numpy_array_equal(result, expected)

    # No NaN values, so na_rep has no effect
    result = index._format_native_types(na_rep="pandas")
    tm.assert_numpy_array_equal(result, expected)

            

Reported by Pylint.

Access to a protected member _format_native_types of a client class
Error

Line: 44 Column: 14

                  tm.assert_numpy_array_equal(result, expected)

    # No NaN values, so na_rep has no effect
    result = index._format_native_types(na_rep="pandas")
    tm.assert_numpy_array_equal(result, expected)

    # Make sure date formatting works
    expected = np.array(["01-2017-01", "01-2017-02", "01-2017-03"], dtype=object)


            

Reported by Pylint.

Access to a protected member _format_native_types of a client class
Error

Line: 50 Column: 14

                  # Make sure date formatting works
    expected = np.array(["01-2017-01", "01-2017-02", "01-2017-03"], dtype=object)

    result = index._format_native_types(date_format="%m-%Y-%d")
    tm.assert_numpy_array_equal(result, expected)

    # NULL object handling should work
    index = DatetimeIndex(["2017-01-01", pd.NaT, "2017-01-03"])
    expected = np.array(["2017-01-01", "NaT", "2017-01-03"], dtype=object)

            

Reported by Pylint.

Access to a protected member _format_native_types of a client class
Error

Line: 57 Column: 14

                  index = DatetimeIndex(["2017-01-01", pd.NaT, "2017-01-03"])
    expected = np.array(["2017-01-01", "NaT", "2017-01-03"], dtype=object)

    result = index._format_native_types()
    tm.assert_numpy_array_equal(result, expected)

    expected = np.array(["2017-01-01", "pandas", "2017-01-03"], dtype=object)

    result = index._format_native_types(na_rep="pandas")

            

Reported by Pylint.

Access to a protected member _format_native_types of a client class
Error

Line: 62 Column: 14

              
    expected = np.array(["2017-01-01", "pandas", "2017-01-03"], dtype=object)

    result = index._format_native_types(na_rep="pandas")
    tm.assert_numpy_array_equal(result, expected)


class TestDatetimeIndexRendering:
    def test_dti_repr_short(self):

            

Reported by Pylint.

Access to a protected member _summary of a client class
Error

Line: 223 Column: 22

                      for idx, expected in zip(
            [idx1, idx2, idx3, idx4, idx5, idx6], [exp1, exp2, exp3, exp4, exp5, exp6]
        ):
            result = idx._summary()
            assert result == expected

    def test_dti_business_repr(self):
        # only really care that it works
        repr(pd.bdate_range(datetime(2009, 1, 1), datetime(2010, 1, 1)))

            

Reported by Pylint.

Access to a protected member _summary of a client class
Error

Line: 232 Column: 9

              
    def test_dti_business_summary(self):
        rng = pd.bdate_range(datetime(2009, 1, 1), datetime(2010, 1, 1))
        rng._summary()
        rng[2:2]._summary()

    def test_dti_business_summary_pytz(self):
        pd.bdate_range("1/1/2005", "1/1/2009", tz=pytz.utc)._summary()


            

Reported by Pylint.

Access to a protected member _summary of a client class
Error

Line: 233 Column: 9

                  def test_dti_business_summary(self):
        rng = pd.bdate_range(datetime(2009, 1, 1), datetime(2010, 1, 1))
        rng._summary()
        rng[2:2]._summary()

    def test_dti_business_summary_pytz(self):
        pd.bdate_range("1/1/2005", "1/1/2009", tz=pytz.utc)._summary()

    def test_dti_business_summary_dateutil(self):

            

Reported by Pylint.

pandas/tests/frame/methods/test_tz_convert.py
52 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

from pandas import (
    DataFrame,
    Index,
    MultiIndex,
    Series,
    date_range,

            

Reported by Pylint.

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

Line: 23 Column: 40

                          obj = obj["a"]

        result = obj.tz_convert("Europe/Berlin")
        expected = DataFrame({"a": 1}, rng.tz_convert("Europe/Berlin"))
        if frame_or_series is not DataFrame:
            expected = expected["a"]

        assert result.index.tz.zone == "Europe/Berlin"
        tm.assert_equal(result, expected)

            

Reported by Pylint.

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

Line: 23 Column: 40

                          obj = obj["a"]

        result = obj.tz_convert("Europe/Berlin")
        expected = DataFrame({"a": 1}, rng.tz_convert("Europe/Berlin"))
        if frame_or_series is not DataFrame:
            expected = expected["a"]

        assert result.index.tz.zone == "Europe/Berlin"
        tm.assert_equal(result, expected)

            

Reported by Pylint.

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

Line: 39 Column: 40

                      result = obj.tz_convert("Europe/Berlin", axis=1)
        assert result.columns.tz.zone == "Europe/Berlin"

        expected = DataFrame({"a": 1}, rng.tz_convert("Europe/Berlin"))

        tm.assert_equal(result, expected.T)

    def test_tz_convert_naive(self, frame_or_series):
        # can't convert tz-naive

            

Reported by Pylint.

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

Line: 39 Column: 40

                      result = obj.tz_convert("Europe/Berlin", axis=1)
        assert result.columns.tz.zone == "Europe/Berlin"

        expected = DataFrame({"a": 1}, rng.tz_convert("Europe/Berlin"))

        tm.assert_equal(result, expected.T)

    def test_tz_convert_naive(self, frame_or_series):
        # can't convert tz-naive

            

Reported by Pylint.

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

Line: 60 Column: 18

                      int_idx = Index(range(5))

        if fn == "tz_convert":
            l0 = l0.tz_localize("UTC")
            l1 = l1.tz_localize("UTC")

        for idx in [l0, l1]:

            l0_expected = getattr(idx, fn)("US/Pacific")

            

Reported by Pylint.

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

Line: 60 Column: 18

                      int_idx = Index(range(5))

        if fn == "tz_convert":
            l0 = l0.tz_localize("UTC")
            l1 = l1.tz_localize("UTC")

        for idx in [l0, l1]:

            l0_expected = getattr(idx, fn)("US/Pacific")

            

Reported by Pylint.

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

Line: 61 Column: 18

              
        if fn == "tz_convert":
            l0 = l0.tz_localize("UTC")
            l1 = l1.tz_localize("UTC")

        for idx in [l0, l1]:

            l0_expected = getattr(idx, fn)("US/Pacific")
            l1_expected = getattr(idx, fn)("US/Pacific")

            

Reported by Pylint.

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

Line: 61 Column: 18

              
        if fn == "tz_convert":
            l0 = l0.tz_localize("UTC")
            l1 = l1.tz_localize("UTC")

        for idx in [l0, l1]:

            l0_expected = getattr(idx, fn)("US/Pacific")
            l1_expected = getattr(idx, fn)("US/Pacific")

            

Reported by Pylint.

Access to a protected member _with_freq of a client class
Error

Line: 77 Column: 27

                          df2 = DataFrame(np.ones(5), MultiIndex.from_arrays([l0, l1]))

            # freq is not preserved in MultiIndex construction
            l1_expected = l1_expected._with_freq(None)
            l0_expected = l0_expected._with_freq(None)
            l1 = l1._with_freq(None)
            l0 = l0._with_freq(None)

            df3 = getattr(df2, fn)("US/Pacific", level=0)

            

Reported by Pylint.

asv_bench/benchmarks/plotting.py
52 issues
Unable to import 'pandas'
Error

Line: 8 Column: 1

              import numpy as np
import pkg_resources

from pandas import (
    DataFrame,
    DatetimeIndex,
    Series,
    date_range,
)

            

Reported by Pylint.

Unable to import 'pandas.plotting._core'
Error

Line: 20 Column: 1

              except ImportError:
    from pandas.tools.plotting import andrews_curves

from pandas.plotting._core import _get_plot_backend

matplotlib.use("Agg")


class SeriesPlotting:

            

Reported by Pylint.

Attempted relative import beyond top-level package
Error

Line: 132 Column: 1

                      _get_plot_backend("my_backend")


from .pandas_vb_common import setup  # noqa: F401 isort:skip

            

Reported by Pylint.

Attribute 's' defined outside __init__
Error

Line: 37 Column: 9

                      else:
            n = 1000000

        self.s = Series(np.random.randn(n))
        if kind in ["area", "pie"]:
            self.s = self.s.abs()

    def time_series_plot(self, kind):
        self.s.plot(kind=kind)

            

Reported by Pylint.

Attribute 's' defined outside __init__
Error

Line: 39 Column: 13

              
        self.s = Series(np.random.randn(n))
        if kind in ["area", "pie"]:
            self.s = self.s.abs()

    def time_series_plot(self, kind):
        self.s.plot(kind=kind)



            

Reported by Pylint.

Attribute 'x' defined outside __init__
Error

Line: 59 Column: 9

                      else:
            n = 1000000

        self.x = Series(np.random.randn(n))
        self.y = Series(np.random.randn(n))
        if kind in ["area", "pie"]:
            self.x = self.x.abs()
            self.y = self.y.abs()
        self.df = DataFrame({"x": self.x, "y": self.y})

            

Reported by Pylint.

Attribute 'y' defined outside __init__
Error

Line: 60 Column: 9

                          n = 1000000

        self.x = Series(np.random.randn(n))
        self.y = Series(np.random.randn(n))
        if kind in ["area", "pie"]:
            self.x = self.x.abs()
            self.y = self.y.abs()
        self.df = DataFrame({"x": self.x, "y": self.y})


            

Reported by Pylint.

Attribute 'x' defined outside __init__
Error

Line: 62 Column: 13

                      self.x = Series(np.random.randn(n))
        self.y = Series(np.random.randn(n))
        if kind in ["area", "pie"]:
            self.x = self.x.abs()
            self.y = self.y.abs()
        self.df = DataFrame({"x": self.x, "y": self.y})

    def time_frame_plot(self, kind):
        self.df.plot(x="x", y="y", kind=kind)

            

Reported by Pylint.

Attribute 'y' defined outside __init__
Error

Line: 63 Column: 13

                      self.y = Series(np.random.randn(n))
        if kind in ["area", "pie"]:
            self.x = self.x.abs()
            self.y = self.y.abs()
        self.df = DataFrame({"x": self.x, "y": self.y})

    def time_frame_plot(self, kind):
        self.df.plot(x="x", y="y", kind=kind)


            

Reported by Pylint.

Attribute 'df' defined outside __init__
Error

Line: 64 Column: 9

                      if kind in ["area", "pie"]:
            self.x = self.x.abs()
            self.y = self.y.abs()
        self.df = DataFrame({"x": self.x, "y": self.y})

    def time_frame_plot(self, kind):
        self.df.plot(x="x", y="y", kind=kind)



            

Reported by Pylint.

pandas/tests/tslibs/test_timezones.py
52 issues
Unable to import 'pytest'
Error

Line: 8 Column: 1

              )

import dateutil.tz
import pytest
import pytz

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

            

Reported by Pylint.

Unable to import 'pytz'
Error

Line: 9 Column: 1

              
import dateutil.tz
import pytest
import pytz

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

            

Reported by Pylint.

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

Line: 11 Column: 1

              import pytest
import pytz

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

from pandas import Timestamp

            

Reported by Pylint.

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

Line: 11 Column: 1

              import pytest
import pytz

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

from pandas import Timestamp

            

Reported by Pylint.

Access to a protected member _p_tz_cache_key of a client class
Error

Line: 35 Column: 47

                  if tz_d is None:
        pytest.skip(tz_name + ": dateutil does not know about this one")

    assert timezones._p_tz_cache_key(tz_p) != timezones._p_tz_cache_key(tz_d)


def test_tzlocal_repr():
    # see gh-13583
    ts = Timestamp("2011-01-01", tz=dateutil.tz.tzlocal())

            

Reported by Pylint.

Access to a protected member _p_tz_cache_key of a client class
Error

Line: 35 Column: 12

                  if tz_d is None:
        pytest.skip(tz_name + ": dateutil does not know about this one")

    assert timezones._p_tz_cache_key(tz_p) != timezones._p_tz_cache_key(tz_d)


def test_tzlocal_repr():
    # see gh-13583
    ts = Timestamp("2011-01-01", tz=dateutil.tz.tzlocal())

            

Reported by Pylint.

Redefining name 'infer_setup' from outer scope (line 81)
Error

Line: 95 Column: 26

                  return eastern, localize, start, end, start_naive, end_naive


def test_infer_tz_compat(infer_setup):
    eastern, _, start, end, start_naive, end_naive = infer_setup

    assert (
        timezones.infer_tzinfo(start, end)
        is conversion.localize_pydatetime(start_naive, eastern).tzinfo

            

Reported by Pylint.

Redefining name 'infer_setup' from outer scope (line 81)
Error

Line: 112 Column: 32

                  )


def test_infer_tz_utc_localize(infer_setup):
    _, _, start, end, start_naive, end_naive = infer_setup
    utc = pytz.utc

    start = utc.localize(start_naive)
    end = utc.localize(end_naive)

            

Reported by Pylint.

Redefining name 'infer_setup' from outer scope (line 81)
Error

Line: 123 Column: 28

              

@pytest.mark.parametrize("ordered", [True, False])
def test_infer_tz_mismatch(infer_setup, ordered):
    eastern, _, _, _, start_naive, end_naive = infer_setup
    msg = "Inputs must both have the same timezone"

    utc = pytz.utc
    start = utc.localize(start_naive)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              from datetime import (
    datetime,
    timedelta,
    timezone,
)

import dateutil.tz
import pytest
import pytz

            

Reported by Pylint.

pandas/io/json/_json.py
52 issues
Unable to import 'pandas._libs.json'
Error

Line: 19 Column: 1

              
import numpy as np

import pandas._libs.json as json
from pandas._libs.tslibs import iNaT
from pandas._typing import (
    CompressionOptions,
    DtypeArg,
    IndexLabel,

            

Reported by Pylint.

No name 'json' in module 'pandas._libs'
Error

Line: 19 Column: 1

              
import numpy as np

import pandas._libs.json as json
from pandas._libs.tslibs import iNaT
from pandas._typing import (
    CompressionOptions,
    DtypeArg,
    IndexLabel,

            

Reported by Pylint.

Unnecessary pass statement
Error

Line: 189 Column: 9

                  @abstractmethod
    def obj_to_write(self) -> NDFrame | Mapping[IndexLabel, Any]:
        """Object to write in JSON format."""
        pass


class SeriesWriter(Writer):
    _default_orient = "index"


            

Reported by Pylint.

TODO: Do this timedelta properly in objToJSON.c See GH #15137
Error

Line: 286 Column: 3

                              "orient='table' is not supported for MultiIndex columns"
            )

        # TODO: Do this timedelta properly in objToJSON.c See GH #15137
        if (
            (obj.ndim == 1)
            and (obj.name in set(obj.index.names))
            or len(obj.columns.intersection(obj.index.names))
        ):

            

Reported by Pylint.

Access to a protected member _shared_docs of a client class
Error

Line: 317 Column: 22

                      return {"schema": self.schema, "data": self.obj}


@doc(storage_options=generic._shared_docs["storage_options"])
@deprecate_kwarg(old_arg_name="numpy", new_arg_name=None)
@deprecate_nonkeyword_arguments(
    version="2.0", allowed_args=["path_or_buf"], stacklevel=3
)
def read_json(

            

Reported by Pylint.

Redefining name 'json' from outer scope (line 19)
Error

Line: 751 Column: 34

                      self.close()
        return obj

    def _get_object_parser(self, json):
        """
        Parses a json document into a pandas object.
        """
        typ = self.typ
        dtype = self.dtype

            

Reported by Pylint.

Redefining name 'json' from outer scope (line 19)
Error

Line: 829 Column: 9

              
    def __init__(
        self,
        json,
        orient,
        dtype: DtypeArg | None = None,
        convert_axes=True,
        convert_dates=True,
        keep_default_dates=False,

            

Reported by Pylint.

Access to a protected member _AXIS_ORDERS of a client class
Error

Line: 905 Column: 26

                      """
        obj = self.obj
        assert obj is not None  # for mypy
        for axis_name in obj._AXIS_ORDERS:
            new_axis, result = self._try_convert_data(
                name=axis_name,
                data=obj._get_axis(axis_name),
                use_dtypes=False,
                convert_dates=True,

            

Reported by Pylint.

Access to a protected member _get_axis of a client class
Error

Line: 908 Column: 22

                      for axis_name in obj._AXIS_ORDERS:
            new_axis, result = self._try_convert_data(
                name=axis_name,
                data=obj._get_axis(axis_name),
                use_dtypes=False,
                convert_dates=True,
            )
            if result:
                setattr(self.obj, axis_name, new_axis)

            

Reported by Pylint.

Access to a protected member _values of a client class
Error

Line: 1022 Column: 22

                      # ignore numbers that are out of range
        if issubclass(new_data.dtype.type, np.number):
            in_range = (
                isna(new_data._values)
                | (new_data > self.min_stamp)
                | (new_data._values == iNaT)
            )
            if not in_range.all():
                return data, False

            

Reported by Pylint.

pandas/tests/indexes/multi/test_integrity.py
52 issues
Unable to import 'pytest'
Error

Line: 4 Column: 1

              import re

import numpy as np
import pytest

from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike

import pandas as pd
from pandas import (

            

Reported by Pylint.

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

Line: 49 Column: 52

                  expected = construct_1d_object_array_from_listlike(tuples)
    tm.assert_numpy_array_equal(result.values, expected)
    # Check that code branches for boxed values produce identical results
    tm.assert_numpy_array_equal(result.values[:4], result[:4].values)


def test_values_multiindex_datetimeindex():
    # Test to ensure we hit the boxing / nobox part of MI.values
    ints = np.arange(10 ** 18, 10 ** 18 + 5)

            

Reported by Pylint.

Non-iterable value result is used in an iterating context
Error

Line: 62 Column: 45

                  idx = MultiIndex.from_arrays([naive, aware])
    result = idx.values

    outer = pd.DatetimeIndex([x[0] for x in result])
    tm.assert_index_equal(outer, naive)

    inner = pd.DatetimeIndex([x[1] for x in result])
    tm.assert_index_equal(inner, aware)


            

Reported by Pylint.

Non-iterable value result is used in an iterating context
Error

Line: 65 Column: 45

                  outer = pd.DatetimeIndex([x[0] for x in result])
    tm.assert_index_equal(outer, naive)

    inner = pd.DatetimeIndex([x[1] for x in result])
    tm.assert_index_equal(inner, aware)

    # n_lev > n_lab
    result = idx[:2].values


            

Reported by Pylint.

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

Line: 69 Column: 14

                  tm.assert_index_equal(inner, aware)

    # n_lev > n_lab
    result = idx[:2].values

    outer = pd.DatetimeIndex([x[0] for x in result])
    tm.assert_index_equal(outer, naive[:2])

    inner = pd.DatetimeIndex([x[1] for x in result])

            

Reported by Pylint.

Non-iterable value result is used in an iterating context
Error

Line: 86 Column: 42

                  idx = MultiIndex.from_arrays([ints, pidx])
    result = idx.values

    outer = pd.Int64Index([x[0] for x in result])
    tm.assert_index_equal(outer, pd.Int64Index(ints))

    inner = pd.PeriodIndex([x[1] for x in result])
    tm.assert_index_equal(inner, pidx)


            

Reported by Pylint.

Non-iterable value result is used in an iterating context
Error

Line: 89 Column: 43

                  outer = pd.Int64Index([x[0] for x in result])
    tm.assert_index_equal(outer, pd.Int64Index(ints))

    inner = pd.PeriodIndex([x[1] for x in result])
    tm.assert_index_equal(inner, pidx)

    # n_lev > n_lab
    result = idx[:2].values


            

Reported by Pylint.

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

Line: 93 Column: 14

                  tm.assert_index_equal(inner, pidx)

    # n_lev > n_lab
    result = idx[:2].values

    outer = pd.Int64Index([x[0] for x in result])
    tm.assert_index_equal(outer, pd.Int64Index(ints[:2]))

    inner = pd.PeriodIndex([x[1] for x in result])

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 177 Column: 9

                      1, index=MultiIndex.from_product([[1, 2], range(499999)]), columns=["dest"]
    )
    with pytest.raises(KeyError, match=r"^\(-1, 0\)$"):
        df_below_1000000.loc[(-1, 0), "dest"]
    with pytest.raises(KeyError, match=r"^\(3, 0\)$"):
        df_below_1000000.loc[(3, 0), "dest"]
    df_above_1000000 = pd.DataFrame(
        1, index=MultiIndex.from_product([[1, 2], range(500001)]), columns=["dest"]
    )

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 179 Column: 9

                  with pytest.raises(KeyError, match=r"^\(-1, 0\)$"):
        df_below_1000000.loc[(-1, 0), "dest"]
    with pytest.raises(KeyError, match=r"^\(3, 0\)$"):
        df_below_1000000.loc[(3, 0), "dest"]
    df_above_1000000 = pd.DataFrame(
        1, index=MultiIndex.from_product([[1, 2], range(500001)]), columns=["dest"]
    )
    with pytest.raises(KeyError, match=r"^\(-1, 0\)$"):
        df_above_1000000.loc[(-1, 0), "dest"]

            

Reported by Pylint.

pandas/tests/indexing/multiindex/test_partial.py
51 issues
Unable to import 'pytest'
Error

Line: 2 Column: 1

              import numpy as np
import pytest

import pandas.util._test_decorators as td

from pandas import (
    DataFrame,
    Float64Index,
    Int64Index,

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 37 Column: 13

              
        # missing item:
        with pytest.raises(KeyError, match="1"):
            df[1]
        with pytest.raises(KeyError, match=r"'\[1\] not in index'"):
            df[[1]]

    def test_series_slice_partial(self):
        pass

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 39 Column: 13

                      with pytest.raises(KeyError, match="1"):
            df[1]
        with pytest.raises(KeyError, match=r"'\[1\] not in index'"):
            df[[1]]

    def test_series_slice_partial(self):
        pass

    def test_xs_partial(

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 118 Column: 13

                      tm.assert_frame_equal(result, expected)

        with pytest.raises(KeyError, match=r"\('a', 'foo'\)"):
            df.loc[("a", "foo"), :]

    # TODO(ArrayManager) rewrite test to not use .values
    # exp.loc[2000, 4].values[:] select multiple columns -> .values is not a view
    @td.skip_array_manager_invalid_test
    def test_partial_set(self, multiindex_year_month_day_dataframe_random_data):

            

Reported by Pylint.

TODO(ArrayManager) rewrite test to not use .values
Error

Line: 120 Column: 3

                      with pytest.raises(KeyError, match=r"\('a', 'foo'\)"):
            df.loc[("a", "foo"), :]

    # TODO(ArrayManager) rewrite test to not use .values
    # exp.loc[2000, 4].values[:] select multiple columns -> .values is not a view
    @td.skip_array_manager_invalid_test
    def test_partial_set(self, multiindex_year_month_day_dataframe_random_data):
        # GH #397
        ymd = multiindex_year_month_day_dataframe_random_data

            

Reported by Pylint.

Access to a protected member _should_fallback_to_positional of a client class
Error

Line: 161 Column: 20

                          assert isinstance(mi.levels[0], Float64Index)

        assert 14 not in mi.levels[0]
        assert not mi.levels[0]._should_fallback_to_positional
        assert not mi._should_fallback_to_positional

        with pytest.raises(KeyError, match="14"):
            ser[14]
        with pytest.raises(KeyError, match="14"):

            

Reported by Pylint.

Access to a protected member _should_fallback_to_positional of a client class
Error

Line: 162 Column: 20

              
        assert 14 not in mi.levels[0]
        assert not mi.levels[0]._should_fallback_to_positional
        assert not mi._should_fallback_to_positional

        with pytest.raises(KeyError, match="14"):
            ser[14]
        with pytest.raises(KeyError, match="14"):
            with tm.assert_produces_warning(FutureWarning):

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 165 Column: 13

                      assert not mi._should_fallback_to_positional

        with pytest.raises(KeyError, match="14"):
            ser[14]
        with pytest.raises(KeyError, match="14"):
            with tm.assert_produces_warning(FutureWarning):
                mi.get_value(ser, 14)

    # ---------------------------------------------------------------------

            

Reported by Pylint.

FIXME: dont leave commented-out
Error

Line: 182 Column: 3

                      tm.assert_series_equal(result, expected)

        # need to put in some work here
        # FIXME: dont leave commented-out
        # self.ymd.loc[2000, 0] = 0
        # assert (self.ymd.loc[2000]['A'] == 0).all()

        # Pretty sure the second (and maybe even the first) is already wrong.
        with pytest.raises(KeyError, match="6"):

            

Reported by Pylint.

Statement seems to have no effect
Error

Line: 188 Column: 13

              
        # Pretty sure the second (and maybe even the first) is already wrong.
        with pytest.raises(KeyError, match="6"):
            ymd.loc[(2000, 6)]
        with pytest.raises(KeyError, match="(2000, 6)"):
            ymd.loc[(2000, 6), 0]

    # ---------------------------------------------------------------------


            

Reported by Pylint.