The following issues were found
pandas/tests/arrays/timedeltas/test_reductions.py
90 issues
Line: 2
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas import Timedelta
import pandas._testing as tm
from pandas.core import nanops
from pandas.core.arrays import TimedeltaArray
Reported by Pylint.
Line: 29
Column: 18
tdi = pd.TimedeltaIndex([])
arr = tdi.array
result = tdi.sum(skipna=skipna)
assert isinstance(result, Timedelta)
assert result == Timedelta(0)
result = arr.sum(skipna=skipna)
assert isinstance(result, Timedelta)
Reported by Pylint.
Line: 63
Column: 18
assert isinstance(result, Timedelta)
assert result == expected
result = tdi.sum(skipna=True)
assert isinstance(result, Timedelta)
assert result == expected
result = arr.sum(skipna=False)
assert result is pd.NaT
Reported by Pylint.
Line: 70
Column: 18
result = arr.sum(skipna=False)
assert result is pd.NaT
result = tdi.sum(skipna=False)
assert result is pd.NaT
result = arr.sum(min_count=9)
assert result is pd.NaT
Reported by Pylint.
Line: 76
Column: 18
result = arr.sum(min_count=9)
assert result is pd.NaT
result = tdi.sum(min_count=9)
assert result is pd.NaT
result = arr.sum(min_count=1)
assert isinstance(result, Timedelta)
assert result == expected
Reported by Pylint.
Line: 83
Column: 18
assert isinstance(result, Timedelta)
assert result == expected
result = tdi.sum(min_count=1)
assert isinstance(result, Timedelta)
assert result == expected
# TODO: de-duplicate with test_npsum below
def test_np_sum(self):
Reported by Pylint.
Line: 183
Column: 18
assert isinstance(result, Timedelta)
assert result == expected
result = tdi.median(skipna=True)
assert isinstance(result, Timedelta)
assert result == expected
result = arr.median(skipna=False)
assert result is pd.NaT
Reported by Pylint.
Line: 190
Column: 18
result = arr.median(skipna=False)
assert result is pd.NaT
result = tdi.median(skipna=False)
assert result is pd.NaT
def test_mean(self):
tdi = pd.TimedeltaIndex(["0H", "3H", "NaT", "5H06m", "0H", "2H"])
arr = tdi._data
Reported by Pylint.
Line: 224
Column: 20
tm.assert_timedelta_array_equal(result, expected)
result = tda.mean(axis=None)
expected = tdi.mean()
assert result == expected
Reported by Pylint.
Line: 224
Column: 20
tm.assert_timedelta_array_equal(result, expected)
result = tda.mean(axis=None)
expected = tdi.mean()
assert result == expected
Reported by Pylint.
pandas/tests/indexing/test_floats.py
90 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas import (
DataFrame,
Float64Index,
Index,
Int64Index,
RangeIndex,
Reported by Pylint.
Line: 64
Column: 13
# getting
with pytest.raises(KeyError, match="^3.0$"):
indexer_sl(s)[3.0]
# contains
assert 3.0 not in s
# setting with an indexer
Reported by Pylint.
Line: 75
Column: 3
pass
elif s.index.inferred_type in ["datetime64", "timedelta64", "period"]:
# FIXME: dont leave commented-out
# these should prob work
# and are inconsistent between series/dataframe ATM
# for idxr in [lambda x: x]:
# s2 = s.copy()
#
Reported by Pylint.
Line: 106
Column: 9
# fallsback to position selection, series only
i = index_func(5)
s = Series(np.arange(len(i)), index=i)
s[3]
with pytest.raises(KeyError, match="^3.0$"):
s[3.0]
def test_scalar_with_mixed(self, indexer_sl):
Reported by Pylint.
Line: 108
Column: 13
s = Series(np.arange(len(i)), index=i)
s[3]
with pytest.raises(KeyError, match="^3.0$"):
s[3.0]
def test_scalar_with_mixed(self, indexer_sl):
s2 = Series([1, 2, 3], index=["a", "b", "c"])
s3 = Series([1, 2, 3], index=["a", "b", 1.5])
Reported by Pylint.
Line: 118
Column: 13
# lookup in a pure string index with an invalid indexer
with pytest.raises(KeyError, match="^1.0$"):
indexer_sl(s2)[1.0]
with pytest.raises(KeyError, match=r"^1\.0$"):
indexer_sl(s2)[1.0]
result = indexer_sl(s2)["b"]
Reported by Pylint.
Line: 121
Column: 13
indexer_sl(s2)[1.0]
with pytest.raises(KeyError, match=r"^1\.0$"):
indexer_sl(s2)[1.0]
result = indexer_sl(s2)["b"]
expected = 2
assert result == expected
Reported by Pylint.
Line: 130
Column: 13
# mixed index so we have label
# indexing
with pytest.raises(KeyError, match="^1.0$"):
indexer_sl(s3)[1.0]
if indexer_sl is not tm.loc:
# __getitem__ falls back to positional
result = s3[1]
expected = 2
Reported by Pylint.
Line: 139
Column: 13
assert result == expected
with pytest.raises(KeyError, match=r"^1\.0$"):
indexer_sl(s3)[1.0]
result = indexer_sl(s3)[1.5]
expected = 3
assert result == expected
Reported by Pylint.
Line: 215
Column: 17
# random float is a KeyError
with pytest.raises(KeyError, match=r"^3\.5$"):
idxr(s)[3.5]
# contains
assert 3.0 in s
# iloc succeeds with an integer
Reported by Pylint.
pandas/tests/arrays/test_array.py
89 issues
Line: 5
Column: 1
import decimal
import numpy as np
import pytest
import pytz
from pandas.core.dtypes.base import _registry as registry
import pandas as pd
Reported by Pylint.
Line: 6
Column: 1
import numpy as np
import pytest
import pytz
from pandas.core.dtypes.base import _registry as registry
import pandas as pd
import pandas._testing as tm
Reported by Pylint.
Line: 38
Column: 24
"data, dtype, expected",
[
# Basic NumPy defaults.
([1, 2], None, IntegerArray._from_sequence([1, 2])),
([1, 2], object, PandasArray(np.array([1, 2], dtype=object))),
(
[1, 2],
np.dtype("float32"),
PandasArray(np.array([1.0, 2.0], dtype=np.dtype("float32"))),
Reported by Pylint.
Line: 45
Column: 49
np.dtype("float32"),
PandasArray(np.array([1.0, 2.0], dtype=np.dtype("float32"))),
),
(np.array([1, 2], dtype="int64"), None, IntegerArray._from_sequence([1, 2])),
(
np.array([1.0, 2.0], dtype="float64"),
None,
FloatingArray._from_sequence([1.0, 2.0]),
),
Reported by Pylint.
Line: 49
Column: 13
(
np.array([1.0, 2.0], dtype="float64"),
None,
FloatingArray._from_sequence([1.0, 2.0]),
),
# String alias passes through to NumPy
([1, 2], "float32", PandasArray(np.array([1, 2], dtype="float32"))),
# Period alias
(
Reported by Pylint.
Line: 69
Column: 13
(
[1, 2],
np.dtype("datetime64[ns]"),
DatetimeArray._from_sequence(np.array([1, 2], dtype="datetime64[ns]")),
),
(
np.array([1, 2], dtype="datetime64[ns]"),
None,
DatetimeArray._from_sequence(np.array([1, 2], dtype="datetime64[ns]")),
Reported by Pylint.
Line: 74
Column: 13
(
np.array([1, 2], dtype="datetime64[ns]"),
None,
DatetimeArray._from_sequence(np.array([1, 2], dtype="datetime64[ns]")),
),
(
pd.DatetimeIndex(["2000", "2001"]),
np.dtype("datetime64[ns]"),
DatetimeArray._from_sequence(["2000", "2001"]),
Reported by Pylint.
Line: 79
Column: 13
(
pd.DatetimeIndex(["2000", "2001"]),
np.dtype("datetime64[ns]"),
DatetimeArray._from_sequence(["2000", "2001"]),
),
(
pd.DatetimeIndex(["2000", "2001"]),
None,
DatetimeArray._from_sequence(["2000", "2001"]),
Reported by Pylint.
Line: 84
Column: 13
(
pd.DatetimeIndex(["2000", "2001"]),
None,
DatetimeArray._from_sequence(["2000", "2001"]),
),
(
["2000", "2001"],
np.dtype("datetime64[ns]"),
DatetimeArray._from_sequence(["2000", "2001"]),
Reported by Pylint.
Line: 89
Column: 13
(
["2000", "2001"],
np.dtype("datetime64[ns]"),
DatetimeArray._from_sequence(["2000", "2001"]),
),
# Datetime (tz-aware)
(
["2000", "2001"],
pd.DatetimeTZDtype(tz="CET"),
Reported by Pylint.
pandas/tests/base/test_conversion.py
89 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas.core.dtypes.common import (
is_datetime64_dtype,
is_timedelta64_dtype,
)
from pandas.core.dtypes.dtypes import DatetimeTZDtype
Reported by Pylint.
Line: 55
Column: 13
[
lambda x: x.tolist(),
lambda x: x.to_list(),
lambda x: list(x),
lambda x: list(x.__iter__()),
],
ids=["tolist", "to_list", "list", "iter"],
)
def test_iterable(self, index_or_series, method, dtype, rdtype):
Reported by Pylint.
Line: 83
Column: 13
[
lambda x: x.tolist(),
lambda x: x.to_list(),
lambda x: list(x),
lambda x: list(x.__iter__()),
],
ids=["tolist", "to_list", "list", "iter"],
)
def test_iterable_object_and_category(
Reported by Pylint.
Line: 129
Column: 13
[
lambda x: x.tolist(),
lambda x: x.to_list(),
lambda x: list(x),
lambda x: list(x.__iter__()),
],
ids=["tolist", "to_list", "list", "iter"],
)
def test_categorial_datetimelike(self, method):
Reported by Pylint.
Line: 219
Column: 48
),
],
)
def test_values_consistent(arr, expected_type, dtype):
l_values = Series(arr)._values
r_values = pd.Index(arr)._values
assert type(l_values) is expected_type
assert type(l_values) is type(r_values)
Reported by Pylint.
Line: 220
Column: 16
],
)
def test_values_consistent(arr, expected_type, dtype):
l_values = Series(arr)._values
r_values = pd.Index(arr)._values
assert type(l_values) is expected_type
assert type(l_values) is type(r_values)
tm.assert_equal(l_values, r_values)
Reported by Pylint.
Line: 221
Column: 16
)
def test_values_consistent(arr, expected_type, dtype):
l_values = Series(arr)._values
r_values = pd.Index(arr)._values
assert type(l_values) is expected_type
assert type(l_values) is type(r_values)
tm.assert_equal(l_values, r_values)
Reported by Pylint.
Line: 285
Column: 9
idx = pd.MultiIndex.from_product([["A"], ["a", "b"]])
msg = "MultiIndex has no single backing array"
with pytest.raises(ValueError, match=msg):
idx.array
@pytest.mark.parametrize(
"arr, expected",
[
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas.core.dtypes.common import (
is_datetime64_dtype,
is_timedelta64_dtype,
)
from pandas.core.dtypes.dtypes import DatetimeTZDtype
Reported by Pylint.
Line: 29
Column: 1
)
class TestToIterable:
# test that we convert an iterable to python types
dtypes = [
("int8", int),
("int16", int),
Reported by Pylint.
asv_bench/benchmarks/io/json.py
89 issues
Line: 5
Column: 1
import numpy as np
from pandas import (
DataFrame,
concat,
date_range,
json_normalize,
read_json,
Reported by Pylint.
Line: 14
Column: 1
timedelta_range,
)
from ..pandas_vb_common import (
BaseIO,
tm,
)
Reported by Pylint.
Line: 312
Column: 1
df.to_json()
from ..pandas_vb_common import setup # noqa: F401 isort:skip
Reported by Pylint.
Line: 39
Column: 38
)
df.to_json(self.fname, orient=orient)
def time_read_json(self, orient, index):
read_json(self.fname, orient=orient)
class ReadJSONLines(BaseIO):
Reported by Pylint.
Line: 62
Column: 36
)
df.to_json(self.fname, orient="records", lines=True)
def time_read_json_lines(self, index):
read_json(self.fname, orient="records", lines=True)
def time_read_json_lines_concat(self, index):
concat(read_json(self.fname, orient="records", lines=True, chunksize=25000))
Reported by Pylint.
Line: 65
Column: 43
def time_read_json_lines(self, index):
read_json(self.fname, orient="records", lines=True)
def time_read_json_lines_concat(self, index):
concat(read_json(self.fname, orient="records", lines=True, chunksize=25000))
def time_read_json_lines_nrows(self, index):
read_json(self.fname, orient="records", lines=True, nrows=25000)
Reported by Pylint.
Line: 68
Column: 42
def time_read_json_lines_concat(self, index):
concat(read_json(self.fname, orient="records", lines=True, chunksize=25000))
def time_read_json_lines_nrows(self, index):
read_json(self.fname, orient="records", lines=True, nrows=25000)
def peakmem_read_json_lines(self, index):
read_json(self.fname, orient="records", lines=True)
Reported by Pylint.
Line: 71
Column: 39
def time_read_json_lines_nrows(self, index):
read_json(self.fname, orient="records", lines=True, nrows=25000)
def peakmem_read_json_lines(self, index):
read_json(self.fname, orient="records", lines=True)
def peakmem_read_json_lines_concat(self, index):
concat(read_json(self.fname, orient="records", lines=True, chunksize=25000))
Reported by Pylint.
Line: 74
Column: 46
def peakmem_read_json_lines(self, index):
read_json(self.fname, orient="records", lines=True)
def peakmem_read_json_lines_concat(self, index):
concat(read_json(self.fname, orient="records", lines=True, chunksize=25000))
def peakmem_read_json_lines_nrows(self, index):
read_json(self.fname, orient="records", lines=True, nrows=15000)
Reported by Pylint.
Line: 77
Column: 45
def peakmem_read_json_lines_concat(self, index):
concat(read_json(self.fname, orient="records", lines=True, chunksize=25000))
def peakmem_read_json_lines_nrows(self, index):
read_json(self.fname, orient="records", lines=True, nrows=15000)
class NormalizeJSON(BaseIO):
fname = "__test__.json"
Reported by Pylint.
pandas/tests/scalar/test_nat.py
89 issues
Line: 8
Column: 1
import operator
import numpy as np
import pytest
import pytz
from pandas._libs.tslibs import iNaT
from pandas.core.dtypes.common import is_datetime64_any_dtype
Reported by Pylint.
Line: 9
Column: 1
import numpy as np
import pytest
import pytz
from pandas._libs.tslibs import iNaT
from pandas.core.dtypes.common import is_datetime64_any_dtype
Reported by Pylint.
Line: 47
Column: 18
)
def test_nat_fields(nat, idx):
for field in idx._field_ops:
# weekday is a property of DTI, but a method
# on NaT/Timestamp for compat with datetime
if field == "weekday":
continue
Reported by Pylint.
Line: 59
Column: 18
result = getattr(nat, field)
assert np.isnan(result)
for field in idx._bool_ops:
result = getattr(NaT, field)
assert result is False
result = getattr(nat, field)
Reported by Pylint.
Line: 71
Column: 18
def test_nat_vector_field_access():
idx = DatetimeIndex(["1/1/2000", None, None, "1/4/2000"])
for field in DatetimeIndex._field_ops:
# weekday is a property of DTI, but a method
# on NaT/Timestamp for compat with datetime
if field == "weekday":
continue
if field in ["week", "weekofyear"]:
Reported by Pylint.
Line: 86
Column: 18
ser = Series(idx)
for field in DatetimeArray._field_ops:
# weekday is a property of DTI, but a method
# on NaT/Timestamp for compat with datetime
if field == "weekday":
continue
if field in ["week", "weekofyear"]:
Reported by Pylint.
Line: 99
Column: 18
expected = [getattr(x, field) for x in idx]
tm.assert_series_equal(result, Series(expected))
for field in DatetimeArray._bool_ops:
result = getattr(ser.dt, field)
expected = [getattr(x, field) for x in idx]
tm.assert_series_equal(result, Series(expected))
Reported by Pylint.
Line: 180
Column: 32
@pytest.mark.parametrize(
"get_nat", [lambda x: NaT, lambda x: Timedelta(x), lambda x: Timestamp(x)]
)
def test_nat_iso_format(get_nat):
# see gh-12300
assert get_nat("NaT").isoformat() == "NaT"
Reported by Pylint.
Line: 180
Column: 56
@pytest.mark.parametrize(
"get_nat", [lambda x: NaT, lambda x: Timedelta(x), lambda x: Timestamp(x)]
)
def test_nat_iso_format(get_nat):
# see gh-12300
assert get_nat("NaT").isoformat() == "NaT"
Reported by Pylint.
Line: 438
Column: 9
[
DatetimeIndex(["2011-01-01", "2011-01-02"], name="x"),
DatetimeIndex(["2011-01-01", "2011-01-02"], tz="US/Eastern", name="x"),
DatetimeArray._from_sequence(["2011-01-01", "2011-01-02"]),
DatetimeArray._from_sequence(
["2011-01-01", "2011-01-02"], dtype=DatetimeTZDtype(tz="US/Pacific")
),
TimedeltaIndex(["1 day", "2 day"], name="x"),
],
Reported by Pylint.
pandas/core/window/rolling.py
88 issues
Line: 26
Column: 1
BaseOffset,
to_offset,
)
import pandas._libs.window.aggregations as window_aggregations
from pandas._typing import (
ArrayLike,
Axis,
FrameOrSeries,
)
Reported by Pylint.
Line: 26
Column: 1
BaseOffset,
to_offset,
)
import pandas._libs.window.aggregations as window_aggregations
from pandas._typing import (
ArrayLike,
Axis,
FrameOrSeries,
)
Reported by Pylint.
Line: 347
Column: 26
result[name] = extra_col
elif name in result.index.names:
pass
elif name in self._selected_obj.columns:
# insert in the same location as we had in _selected_obj
old_cols = self._selected_obj.columns
new_cols = result.columns
old_loc = old_cols.get_loc(name)
overlap = new_cols.intersection(old_cols[:old_loc])
Reported by Pylint.
Line: 349
Column: 28
pass
elif name in self._selected_obj.columns:
# insert in the same location as we had in _selected_obj
old_cols = self._selected_obj.columns
new_cols = result.columns
old_loc = old_cols.get_loc(name)
overlap = new_cols.intersection(old_cols[:old_loc])
new_loc = len(overlap)
result.insert(new_loc, name, extra_col)
Reported by Pylint.
Line: 416
Column: 12
Apply the given function to the DataFrame broken down into homogeneous
sub-frames.
"""
if self._selected_obj.ndim == 1:
return self._apply_series(homogeneous_func, name)
obj = self._create_data(self._selected_obj)
if name == "count":
# GH 12541: Special case for count where we support date-like types
Reported by Pylint.
Line: 462
Column: 12
"""
Apply the given function to the DataFrame across the entire object
"""
if self._selected_obj.ndim == 1:
raise ValueError("method='table' not applicable for Series objects.")
obj = self._create_data(self._selected_obj)
values = self._prep_values(obj.to_numpy())
values = values.T if self.axis == 1 else values
result = homogeneous_func(values)
Reported by Pylint.
Line: 1012
Column: 18
-------
y : type of input
"""
window = self._scipy_weight_generator(self.window, **kwargs)
offset = (len(window) - 1) // 2 if self.center else 0
def homogeneous_func(values: np.ndarray):
# calculation function
Reported by Pylint.
Line: 136
Column: 3
self.window = window
self.min_periods = min_periods
self.center = center
# TODO: Change this back to self.win_type once deprecation is enforced
self._win_type = win_type
self.axis = obj._get_axis_number(axis) if axis is not None else None
self.method = method
self._win_freq_i8 = None
if self.on is None:
Reported by Pylint.
Line: 232
Column: 24
# dtypes.
obj = obj.select_dtypes(include=["number"], exclude=["timedelta"])
obj = obj.astype("float64", copy=False)
obj._mgr = obj._mgr.consolidate()
return obj
def _gotitem(self, key, ndim, subset=None):
"""
Sub-classes to define. Return a sliced object.
Reported by Pylint.
Line: 232
Column: 13
# dtypes.
obj = obj.select_dtypes(include=["number"], exclude=["timedelta"])
obj = obj.astype("float64", copy=False)
obj._mgr = obj._mgr.consolidate()
return obj
def _gotitem(self, key, ndim, subset=None):
"""
Sub-classes to define. Return a sliced object.
Reported by Pylint.
pandas/tests/test_expressions.py
88 issues
Line: 6
Column: 1
import warnings
import numpy as np
import pytest
import pandas._testing as tm
from pandas.core.api import (
DataFrame,
Index,
Reported by Pylint.
Line: 49
Column: 28
@pytest.mark.skipif(not expr.USE_NUMEXPR, reason="not using numexpr")
class TestExpressions:
def setup_method(self, method):
self.frame = _frame.copy()
self.frame2 = _frame2.copy()
self.mixed = _mixed.copy()
self.mixed2 = _mixed2.copy()
Reported by Pylint.
Line: 51
Column: 9
class TestExpressions:
def setup_method(self, method):
self.frame = _frame.copy()
self.frame2 = _frame2.copy()
self.mixed = _mixed.copy()
self.mixed2 = _mixed2.copy()
self._MIN_ELEMENTS = expr._MIN_ELEMENTS
Reported by Pylint.
Line: 52
Column: 9
def setup_method(self, method):
self.frame = _frame.copy()
self.frame2 = _frame2.copy()
self.mixed = _mixed.copy()
self.mixed2 = _mixed2.copy()
self._MIN_ELEMENTS = expr._MIN_ELEMENTS
def teardown_method(self, method):
Reported by Pylint.
Line: 53
Column: 9
self.frame = _frame.copy()
self.frame2 = _frame2.copy()
self.mixed = _mixed.copy()
self.mixed2 = _mixed2.copy()
self._MIN_ELEMENTS = expr._MIN_ELEMENTS
def teardown_method(self, method):
expr._MIN_ELEMENTS = self._MIN_ELEMENTS
Reported by Pylint.
Line: 54
Column: 9
self.frame = _frame.copy()
self.frame2 = _frame2.copy()
self.mixed = _mixed.copy()
self.mixed2 = _mixed2.copy()
self._MIN_ELEMENTS = expr._MIN_ELEMENTS
def teardown_method(self, method):
expr._MIN_ELEMENTS = self._MIN_ELEMENTS
Reported by Pylint.
Line: 55
Column: 9
self.frame2 = _frame2.copy()
self.mixed = _mixed.copy()
self.mixed2 = _mixed2.copy()
self._MIN_ELEMENTS = expr._MIN_ELEMENTS
def teardown_method(self, method):
expr._MIN_ELEMENTS = self._MIN_ELEMENTS
@staticmethod
Reported by Pylint.
Line: 55
Column: 30
self.frame2 = _frame2.copy()
self.mixed = _mixed.copy()
self.mixed2 = _mixed2.copy()
self._MIN_ELEMENTS = expr._MIN_ELEMENTS
def teardown_method(self, method):
expr._MIN_ELEMENTS = self._MIN_ELEMENTS
@staticmethod
Reported by Pylint.
Line: 57
Column: 31
self.mixed2 = _mixed2.copy()
self._MIN_ELEMENTS = expr._MIN_ELEMENTS
def teardown_method(self, method):
expr._MIN_ELEMENTS = self._MIN_ELEMENTS
@staticmethod
def call_op(df, other, flex: bool, opname: str):
if flex:
Reported by Pylint.
Line: 58
Column: 9
self._MIN_ELEMENTS = expr._MIN_ELEMENTS
def teardown_method(self, method):
expr._MIN_ELEMENTS = self._MIN_ELEMENTS
@staticmethod
def call_op(df, other, flex: bool, opname: str):
if flex:
op = lambda x, y: getattr(x, opname)(y)
Reported by Pylint.
pandas/tests/indexes/datetimes/methods/test_astype.py
88 issues
Line: 5
Column: 1
import dateutil
import numpy as np
import pytest
import pytz
import pandas as pd
from pandas import (
DatetimeIndex,
Reported by Pylint.
Line: 6
Column: 1
import dateutil
import numpy as np
import pytest
import pytz
import pandas as pd
from pandas import (
DatetimeIndex,
Index,
Reported by Pylint.
Line: 69
Column: 13
rng._data.astype("datetime64[ns]")
expected = (
date_range("1/1/2000", periods=10, tz="US/Eastern")
.tz_convert("UTC")
.tz_localize(None)
)
tm.assert_index_equal(result, expected)
Reported by Pylint.
Line: 69
Column: 13
rng._data.astype("datetime64[ns]")
expected = (
date_range("1/1/2000", periods=10, tz="US/Eastern")
.tz_convert("UTC")
.tz_localize(None)
)
tm.assert_index_equal(result, expected)
Reported by Pylint.
Line: 81
Column: 31
result = idx.astype("datetime64[ns, US/Eastern]")
expected = date_range("20170101 03:00:00", periods=4, tz="US/Eastern")
tm.assert_index_equal(result, expected)
assert result.freq == expected.freq
def test_astype_tznaive_to_tzaware(self):
# GH 18951: tz-naive to tz-aware
idx = date_range("20170101", periods=4)
idx = idx._with_freq(None) # tz_localize does not preserve freq
Reported by Pylint.
Line: 81
Column: 31
result = idx.astype("datetime64[ns, US/Eastern]")
expected = date_range("20170101 03:00:00", periods=4, tz="US/Eastern")
tm.assert_index_equal(result, expected)
assert result.freq == expected.freq
def test_astype_tznaive_to_tzaware(self):
# GH 18951: tz-naive to tz-aware
idx = date_range("20170101", periods=4)
idx = idx._with_freq(None) # tz_localize does not preserve freq
Reported by Pylint.
Line: 86
Column: 15
def test_astype_tznaive_to_tzaware(self):
# GH 18951: tz-naive to tz-aware
idx = date_range("20170101", periods=4)
idx = idx._with_freq(None) # tz_localize does not preserve freq
with tm.assert_produces_warning(FutureWarning):
# dt64->dt64tz deprecated
result = idx.astype("datetime64[ns, US/Eastern]")
with tm.assert_produces_warning(FutureWarning):
# dt64->dt64tz deprecated
Reported by Pylint.
Line: 86
Column: 15
def test_astype_tznaive_to_tzaware(self):
# GH 18951: tz-naive to tz-aware
idx = date_range("20170101", periods=4)
idx = idx._with_freq(None) # tz_localize does not preserve freq
with tm.assert_produces_warning(FutureWarning):
# dt64->dt64tz deprecated
result = idx.astype("datetime64[ns, US/Eastern]")
with tm.assert_produces_warning(FutureWarning):
# dt64->dt64tz deprecated
Reported by Pylint.
Line: 95
Column: 20
idx._data.astype("datetime64[ns, US/Eastern]")
expected = date_range("20170101", periods=4, tz="US/Eastern")
expected = expected._with_freq(None)
tm.assert_index_equal(result, expected)
def test_astype_str_nat(self):
# GH 13149, GH 13209
# verify that we are returning NaT as a string (and not unicode)
Reported by Pylint.
Line: 95
Column: 20
idx._data.astype("datetime64[ns, US/Eastern]")
expected = date_range("20170101", periods=4, tz="US/Eastern")
expected = expected._with_freq(None)
tm.assert_index_equal(result, expected)
def test_astype_str_nat(self):
# GH 13149, GH 13209
# verify that we are returning NaT as a string (and not unicode)
Reported by Pylint.
pandas/tests/extension/base/setitem.py
88 issues
Line: 2
Column: 1
import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
from pandas.tests.extension.base.base import BaseExtensionTests
class BaseSetitemTests(BaseExtensionTests):
Reported by Pylint.
Line: 59
Column: 21
original = ser.copy()
value = [data[0]]
if as_array:
value = data._from_sequence(value)
xpr = "cannot set using a {} indexer with a different length"
with pytest.raises(ValueError, match=xpr.format("list-like")):
ser[[0, 1]] = value
# Ensure no modifications made before the exception
Reported by Pylint.
Line: 197
Column: 3
def test_setitem_integer_with_missing_raises(self, data, idx, box_in_series):
arr = data.copy()
# TODO(xfail) this raises KeyError about labels not found (it tries label-based)
# for list of labels with Series
if box_in_series:
arr = pd.Series(data, index=[tm.rands(4) for _ in range(len(data))])
msg = "Cannot index with an integer indexer containing NA values"
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
from pandas.tests.extension.base.base import BaseExtensionTests
class BaseSetitemTests(BaseExtensionTests):
Reported by Pylint.
Line: 9
Column: 1
from pandas.tests.extension.base.base import BaseExtensionTests
class BaseSetitemTests(BaseExtensionTests):
@pytest.fixture(
params=[
lambda x: x.index,
lambda x: list(x.index),
lambda x: slice(None),
Reported by Pylint.
Line: 9
Column: 1
from pandas.tests.extension.base.base import BaseExtensionTests
class BaseSetitemTests(BaseExtensionTests):
@pytest.fixture(
params=[
lambda x: x.index,
lambda x: list(x.index),
lambda x: slice(None),
Reported by Pylint.
Line: 28
Column: 5
"range",
"list(range)",
"mask",
],
)
def full_indexer(self, request):
"""
Fixture for an indexer to pass to obj.loc to get/set the full length of the
object.
Reported by Pylint.
Line: 39
Column: 5
"""
return request.param
def test_setitem_scalar_series(self, data, box_in_series):
if box_in_series:
data = pd.Series(data)
data[0] = data[1]
assert data[0] == data[1]
Reported by Pylint.
Line: 39
Column: 5
"""
return request.param
def test_setitem_scalar_series(self, data, box_in_series):
if box_in_series:
data = pd.Series(data)
data[0] = data[1]
assert data[0] == data[1]
Reported by Pylint.
Line: 43
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
if box_in_series:
data = pd.Series(data)
data[0] = data[1]
assert data[0] == data[1]
def test_setitem_sequence(self, data, box_in_series):
if box_in_series:
data = pd.Series(data)
original = data.copy()
Reported by Bandit.