The following issues were found
pandas/tests/extension/base/getitem.py
125 issues
Line: 2
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas.tests.extension.base.base import BaseExtensionTests
class BaseGetitemTests(BaseExtensionTests):
"""Tests for ExtensionArray.__getitem__."""
Reported by Pylint.
Line: 164
Column: 13
mask = np.array([True, False])
msg = f"Boolean index has wrong length: 2 instead of {len(data)}"
with pytest.raises(IndexError, match=msg):
data[mask]
mask = pd.array(mask, dtype="boolean")
with pytest.raises(IndexError, match=msg):
data[mask]
Reported by Pylint.
Line: 168
Column: 13
mask = pd.array(mask, dtype="boolean")
with pytest.raises(IndexError, match=msg):
data[mask]
def test_getitem_boolean_array_mask(self, data):
mask = pd.array(np.zeros(data.shape, dtype="bool"), dtype="boolean")
result = data[mask]
assert len(result) == 0
Reported by Pylint.
Line: 231
Column: 13
def test_getitem_integer_with_missing_raises(self, data, idx):
msg = "Cannot index with an integer indexer containing NA values"
with pytest.raises(ValueError, match=msg):
data[idx]
# FIXME: dont leave commented-out
# TODO: this raises KeyError about labels not found (it tries label-based)
# import pandas._testing as tm
# s = pd.Series(data, index=[tm.rands(4) for _ in range(len(data))])
Reported by Pylint.
Line: 233
Column: 3
with pytest.raises(ValueError, match=msg):
data[idx]
# FIXME: dont leave commented-out
# TODO: this raises KeyError about labels not found (it tries label-based)
# import pandas._testing as tm
# s = pd.Series(data, index=[tm.rands(4) for _ in range(len(data))])
# with pytest.raises(ValueError, match=msg):
# s[idx]
Reported by Pylint.
Line: 234
Column: 3
data[idx]
# FIXME: dont leave commented-out
# TODO: this raises KeyError about labels not found (it tries label-based)
# import pandas._testing as tm
# s = pd.Series(data, index=[tm.rands(4) for _ in range(len(data))])
# with pytest.raises(ValueError, match=msg):
# s[idx]
Reported by Pylint.
Line: 347
Column: 15
fill_value = data_missing[1] # valid
na = data_missing[0]
arr = data_missing._from_sequence(
[na, fill_value, na], dtype=data_missing.dtype
)
result = arr.take([-1, 1], fill_value=fill_value, allow_fill=True)
expected = arr.take([1, 1])
self.assert_extension_array_equal(result, expected)
Reported by Pylint.
Line: 369
Column: 13
s = pd.Series(data)
result = s.take([0, -1])
expected = pd.Series(
data._from_sequence([data[0], data[len(data) - 1]], dtype=s.dtype),
index=[0, len(data) - 1],
)
self.assert_series_equal(result, expected)
def test_reindex(self, data, na_value):
Reported by Pylint.
Line: 383
Column: 13
n = len(data)
result = s.reindex([-1, 0, n])
expected = pd.Series(
data._from_sequence([na_value, data[0], na_value], dtype=s.dtype),
index=[-1, 0, n],
)
self.assert_series_equal(result, expected)
result = s.reindex([n, n + 1])
Reported by Pylint.
Line: 390
Column: 13
result = s.reindex([n, n + 1])
expected = pd.Series(
data._from_sequence([na_value, na_value], dtype=s.dtype), index=[n, n + 1]
)
self.assert_series_equal(result, expected)
def test_reindex_non_na_fill_value(self, data_missing):
valid = data_missing[1]
Reported by Pylint.
pandas/tests/frame/methods/test_quantile.py
124 issues
Line: 2
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas import (
DataFrame,
Index,
Series,
Timestamp,
Reported by Pylint.
Line: 283
Column: 3
tm.assert_frame_equal(result, expected)
# empty when numeric_only=True
# FIXME (gives empty frame in 0.18.1, broken in 0.19.0)
# result = df[['a', 'c']].quantile(.5)
# result = df[['a', 'c']].quantile([.5])
def test_quantile_invalid(self, datetime_frame):
msg = "percentiles should all be in the interval \\[0, 1\\]"
Reported by Pylint.
Line: 497
Column: 3
exp = DataFrame([[np.nan, np.nan]], columns=["a", "b"], index=[0.5])
tm.assert_frame_equal(res, exp)
# FIXME (gives empty frame in 0.18.1, broken in 0.19.0)
# res = df.quantile(0.5, axis=1)
# res = df.quantile([0.5], axis=1)
# ints
df = DataFrame(columns=["a", "b"], dtype="int64")
Reported by Pylint.
Line: 504
Column: 3
# ints
df = DataFrame(columns=["a", "b"], dtype="int64")
# FIXME (gives empty frame in 0.18.1, broken in 0.19.0)
# res = df.quantile(0.5)
# datetimes
df = DataFrame(columns=["a", "b"], dtype="datetime64[ns]")
Reported by Pylint.
Line: 510
Column: 3
# datetimes
df = DataFrame(columns=["a", "b"], dtype="datetime64[ns]")
# FIXME (gives NaNs instead of NaT in 0.18.1 or 0.19.0)
# res = df.quantile(0.5, numeric_only=False)
def test_quantile_empty_no_columns(self):
# GH#23925 _get_numeric_data may drop all columns
df = DataFrame(pd.date_range("1/1/18", periods=5))
Reported by Pylint.
Line: 533
Column: 24
df["D"] = df["A"] * 2
ser = df["A"]
if not using_array_manager:
assert len(df._mgr.blocks) == 2
df.quantile(numeric_only=False)
ser.values[0] = 99
assert df.iloc[0, 0] == df["A"][0]
Reported by Pylint.
Line: 542
Column: 3
class TestQuantileExtensionDtype:
# TODO: tests for axis=1?
# TODO: empty case? might as well do dt64 and td64 here too
@pytest.fixture(
params=[
pytest.param(
Reported by Pylint.
Line: 543
Column: 3
class TestQuantileExtensionDtype:
# TODO: tests for axis=1?
# TODO: empty case? might as well do dt64 and td64 here too
@pytest.fixture(
params=[
pytest.param(
pd.IntervalIndex.from_breaks(range(10)),
Reported by Pylint.
Line: 602
Column: 23
def test_quantile_ea_with_na(self, obj, index):
obj.iloc[0] = index._na_value
obj.iloc[-1] = index._na_value
# result should be invariant to shuffling
indexer = np.arange(len(index), dtype=np.intp)
np.random.shuffle(indexer)
Reported by Pylint.
Line: 603
Column: 24
def test_quantile_ea_with_na(self, obj, index):
obj.iloc[0] = index._na_value
obj.iloc[-1] = index._na_value
# result should be invariant to shuffling
indexer = np.arange(len(index), dtype=np.intp)
np.random.shuffle(indexer)
obj = obj.iloc[indexer]
Reported by Pylint.
asv_bench/benchmarks/index_object.py
124 issues
Line: 5
Column: 1
import numpy as np
from pandas import (
DatetimeIndex,
Float64Index,
Index,
IntervalIndex,
MultiIndex,
Reported by Pylint.
Line: 16
Column: 1
date_range,
)
from .pandas_vb_common import tm
class SetOperations:
params = (
Reported by Pylint.
Line: 236
Column: 1
gc.enable()
from .pandas_vb_common import setup # noqa: F401 isort:skip
Reported by Pylint.
Line: 27
Column: 28
)
param_names = ["dtype", "method"]
def setup(self, dtype, method):
N = 10 ** 5
dates_left = date_range("1/1/2000", periods=N, freq="T")
fmt = "%Y-%m-%d %H:%M:%S"
date_str_left = Index(dates_left.strftime(fmt))
int_left = Index(np.arange(N))
Reported by Pylint.
Line: 40
Column: 9
"int": {"left": int_left, "right": int_left[:-1]},
"strings": {"left": str_left, "right": str_left[:-1]},
}
self.left = data[dtype]["left"]
self.right = data[dtype]["right"]
def time_operation(self, dtype, method):
getattr(self.left, method)(self.right)
Reported by Pylint.
Line: 41
Column: 9
"strings": {"left": str_left, "right": str_left[:-1]},
}
self.left = data[dtype]["left"]
self.right = data[dtype]["right"]
def time_operation(self, dtype, method):
getattr(self.left, method)(self.right)
Reported by Pylint.
Line: 43
Column: 30
self.left = data[dtype]["left"]
self.right = data[dtype]["right"]
def time_operation(self, dtype, method):
getattr(self.left, method)(self.right)
class SetDisjoint:
def setup(self):
Reported by Pylint.
Line: 51
Column: 9
def setup(self):
N = 10 ** 5
B = N + 20000
self.datetime_left = DatetimeIndex(range(N))
self.datetime_right = DatetimeIndex(range(N, B))
def time_datetime_difference_disjoint(self):
self.datetime_left.difference(self.datetime_right)
Reported by Pylint.
Line: 52
Column: 9
N = 10 ** 5
B = N + 20000
self.datetime_left = DatetimeIndex(range(N))
self.datetime_right = DatetimeIndex(range(N, B))
def time_datetime_difference_disjoint(self):
self.datetime_left.difference(self.datetime_right)
Reported by Pylint.
Line: 60
Column: 9
class Range:
def setup(self):
self.idx_inc = RangeIndex(start=0, stop=10 ** 6, step=3)
self.idx_dec = RangeIndex(start=10 ** 6, stop=-1, step=-3)
def time_max(self):
self.idx_inc.max()
Reported by Pylint.
pandas/tests/window/moments/test_moments_consistency_rolling.py
124 issues
Line: 4
Column: 1
from datetime import datetime
import numpy as np
import pytest
import pandas.util._test_decorators as td
from pandas import (
DataFrame,
Reported by Pylint.
Line: 68
Column: 23
res = getattr(series.rolling(window=10), method)(frame)
res2 = getattr(frame.rolling(window=10), method)(series)
exp = frame.apply(lambda x: getattr(series.rolling(window=10), method)(x))
tm.assert_frame_equal(res, exp)
tm.assert_frame_equal(res2, exp)
frame2 = frame.copy()
Reported by Pylint.
Line: 90
Column: 8
def test_rolling_apply_consistency_sum_nans(
consistency_data, window, min_periods, center, f
):
x, is_constant, no_nans = consistency_data
if f is np.nansum and min_periods == 0:
pass
else:
rolling_f_result = x.rolling(
Reported by Pylint.
Line: 90
Column: 21
def test_rolling_apply_consistency_sum_nans(
consistency_data, window, min_periods, center, f
):
x, is_constant, no_nans = consistency_data
if f is np.nansum and min_periods == 0:
pass
else:
rolling_f_result = x.rolling(
Reported by Pylint.
Line: 111
Column: 8
def test_rolling_apply_consistency_sum_no_nans(
consistency_data, window, min_periods, center, f
):
x, is_constant, no_nans = consistency_data
if no_nans:
if f is np.nansum and min_periods == 0:
pass
else:
Reported by Pylint.
Line: 306
Column: 25
indices.append(datetime(1975, 1, 3, 6, 0))
series = Series(range(1, 7), index=indices)
# Use floats instead of ints as values
series = series.map(lambda x: float(x))
# Sort chronologically
series = series.sort_index()
expected = Series(
[1.0, 2.0, 6.0, 4.0, 5.0],
Reported by Pylint.
Line: 326
Column: 25
indices.append(datetime(1975, 1, 5, 2))
series = Series(list(range(0, 5)) + [10, 20], index=indices)
# Use floats instead of ints as values
series = series.map(lambda x: float(x))
# Sort chronologically
series = series.sort_index()
# Default how should be max
expected = Series(
Reported by Pylint.
Line: 364
Column: 25
indices.append(datetime(1975, 1, 5, 2))
series = Series(list(range(0, 5)) + [10, 20], index=indices)
# Use floats instead of ints as values
series = series.map(lambda x: float(x))
# Sort chronologically
series = series.sort_index()
# Default how should be min
expected = Series(
Reported by Pylint.
Line: 385
Column: 25
indices.append(datetime(1975, 1, 5, 2))
series = Series(list(range(0, 5)) + [10, 20], index=indices)
# Use floats instead of ints as values
series = series.map(lambda x: float(x))
# Sort chronologically
series = series.sort_index()
# Default how should be median
expected = Series(
Reported by Pylint.
Line: 500
Column: 8
)
@pytest.mark.parametrize("ddof", [0, 1])
def test_moments_consistency_var(consistency_data, window, min_periods, center, ddof):
x, is_constant, no_nans = consistency_data
mean_x = x.rolling(window=window, min_periods=min_periods, center=center).mean()
var_x = x.rolling(window=window, min_periods=min_periods, center=center).var(
ddof=ddof
)
Reported by Pylint.
pandas/io/parsers/readers.py
123 issues
Line: 15
Column: 1
import numpy as np
import pandas._libs.lib as lib
from pandas._libs.parsers import STR_NA_VALUES
from pandas._typing import (
ArrayLike,
DtypeArg,
FilePathOrBuffer,
Reported by Pylint.
Line: 15
Column: 1
import numpy as np
import pandas._libs.lib as lib
from pandas._libs.parsers import STR_NA_VALUES
from pandas._typing import (
ArrayLike,
DtypeArg,
FilePathOrBuffer,
Reported by Pylint.
Line: 16
Column: 1
import numpy as np
import pandas._libs.lib as lib
from pandas._libs.parsers import STR_NA_VALUES
from pandas._typing import (
ArrayLike,
DtypeArg,
FilePathOrBuffer,
StorageOptions,
Reported by Pylint.
Line: 16
Column: 1
import numpy as np
import pandas._libs.lib as lib
from pandas._libs.parsers import STR_NA_VALUES
from pandas._typing import (
ArrayLike,
DtypeArg,
FilePathOrBuffer,
StorageOptions,
Reported by Pylint.
Line: 499
Column: 25
func_name="read_csv",
summary="Read a comma-separated values (csv) file into DataFrame.",
_default_sep="','",
storage_options=generic._shared_docs["storage_options"],
)
)
def read_csv(
filepath_or_buffer: FilePathOrBuffer,
sep=lib.no_default,
Reported by Pylint.
Line: 507
Column: 5
sep=lib.no_default,
delimiter=None,
# Column and Index Locations and Names
header="infer",
names=lib.no_default,
index_col=None,
usecols=None,
squeeze=False,
prefix=lib.no_default,
Reported by Pylint.
Line: 509
Column: 5
# Column and Index Locations and Names
header="infer",
names=lib.no_default,
index_col=None,
usecols=None,
squeeze=False,
prefix=lib.no_default,
mangle_dupe_cols=True,
# General Parsing Configuration
Reported by Pylint.
Line: 510
Column: 5
header="infer",
names=lib.no_default,
index_col=None,
usecols=None,
squeeze=False,
prefix=lib.no_default,
mangle_dupe_cols=True,
# General Parsing Configuration
dtype: DtypeArg | None = None,
Reported by Pylint.
Line: 511
Column: 5
names=lib.no_default,
index_col=None,
usecols=None,
squeeze=False,
prefix=lib.no_default,
mangle_dupe_cols=True,
# General Parsing Configuration
dtype: DtypeArg | None = None,
engine=None,
Reported by Pylint.
Line: 513
Column: 5
usecols=None,
squeeze=False,
prefix=lib.no_default,
mangle_dupe_cols=True,
# General Parsing Configuration
dtype: DtypeArg | None = None,
engine=None,
converters=None,
true_values=None,
Reported by Pylint.
pandas/tests/generic/test_label_or_level_utils.py
123 issues
Line: 1
Column: 1
import pytest
from pandas.core.dtypes.missing import array_equivalent
import pandas as pd
# Fixtures
# ========
Reported by Pylint.
Line: 17
Column: 24
@pytest.fixture(params=[[], ["L1"], ["L1", "L2"], ["L1", "L2", "L3"]])
def df_levels(request, df):
"""DataFrame with columns or index levels 'L1', 'L2', and 'L3'"""
levels = request.param
if levels:
df = df.set_index(levels)
Reported by Pylint.
Line: 28
Column: 14
@pytest.fixture
def df_ambig(df):
"""DataFrame with levels 'L1' and 'L2' and labels 'L1' and 'L3'"""
df = df.set_index(["L1", "L2"])
df["L1"] = df["L3"]
Reported by Pylint.
Line: 38
Column: 18
@pytest.fixture
def df_duplabels(df):
"""DataFrame with level 'L1' and labels 'L2', 'L3', and 'L2'"""
df = df.set_index(["L1"])
df = pd.concat([df, df["L2"]], axis=1)
return df
Reported by Pylint.
Line: 48
Column: 23
# Test is label/level reference
# =============================
def get_labels_levels(df_levels):
expected_labels = list(df_levels.columns)
expected_levels = [name for name in df_levels.index.names if name is not None]
return expected_labels, expected_levels
Reported by Pylint.
Line: 56
Column: 16
def assert_label_reference(frame, labels, axis):
for label in labels:
assert frame._is_label_reference(label, axis=axis)
assert not frame._is_level_reference(label, axis=axis)
assert frame._is_label_or_level_reference(label, axis=axis)
def assert_level_reference(frame, levels, axis):
Reported by Pylint.
Line: 57
Column: 20
def assert_label_reference(frame, labels, axis):
for label in labels:
assert frame._is_label_reference(label, axis=axis)
assert not frame._is_level_reference(label, axis=axis)
assert frame._is_label_or_level_reference(label, axis=axis)
def assert_level_reference(frame, levels, axis):
for level in levels:
Reported by Pylint.
Line: 58
Column: 16
for label in labels:
assert frame._is_label_reference(label, axis=axis)
assert not frame._is_level_reference(label, axis=axis)
assert frame._is_label_or_level_reference(label, axis=axis)
def assert_level_reference(frame, levels, axis):
for level in levels:
assert frame._is_level_reference(level, axis=axis)
Reported by Pylint.
Line: 63
Column: 16
def assert_level_reference(frame, levels, axis):
for level in levels:
assert frame._is_level_reference(level, axis=axis)
assert not frame._is_label_reference(level, axis=axis)
assert frame._is_label_or_level_reference(level, axis=axis)
# DataFrame
Reported by Pylint.
Line: 64
Column: 20
def assert_level_reference(frame, levels, axis):
for level in levels:
assert frame._is_level_reference(level, axis=axis)
assert not frame._is_label_reference(level, axis=axis)
assert frame._is_label_or_level_reference(level, axis=axis)
# DataFrame
# ---------
Reported by Pylint.
pandas/tests/scalar/timestamp/test_timezones.py
122 issues
Line: 15
Column: 1
gettz,
tzoffset,
)
import pytest
import pytz
from pytz.exceptions import (
AmbiguousTimeError,
NonExistentTimeError,
)
Reported by Pylint.
Line: 16
Column: 1
tzoffset,
)
import pytest
import pytz
from pytz.exceptions import (
AmbiguousTimeError,
NonExistentTimeError,
)
Reported by Pylint.
Line: 17
Column: 1
)
import pytest
import pytz
from pytz.exceptions import (
AmbiguousTimeError,
NonExistentTimeError,
)
from pandas._libs.tslibs import timezones
Reported by Pylint.
Line: 22
Column: 1
NonExistentTimeError,
)
from pandas._libs.tslibs import timezones
from pandas.errors import OutOfBoundsDatetime
import pandas.util._test_decorators as td
from pandas import (
NaT,
Reported by Pylint.
Line: 32
Column: 1
)
class TestTimestampTZOperations:
# --------------------------------------------------------------
# Timestamp.tz_localize
def test_tz_localize_pushes_out_of_bounds(self):
# GH#12677
Reported by Pylint.
Line: 32
Column: 1
)
class TestTimestampTZOperations:
# --------------------------------------------------------------
# Timestamp.tz_localize
def test_tz_localize_pushes_out_of_bounds(self):
# GH#12677
Reported by Pylint.
Line: 36
Column: 5
# --------------------------------------------------------------
# Timestamp.tz_localize
def test_tz_localize_pushes_out_of_bounds(self):
# GH#12677
# tz_localize that pushes away from the boundary is OK
msg = (
f"Converting {Timestamp.min.strftime('%Y-%m-%d %H:%M:%S')} "
f"underflows past {Timestamp.min}"
Reported by Pylint.
Line: 36
Column: 5
# --------------------------------------------------------------
# Timestamp.tz_localize
def test_tz_localize_pushes_out_of_bounds(self):
# GH#12677
# tz_localize that pushes away from the boundary is OK
msg = (
f"Converting {Timestamp.min.strftime('%Y-%m-%d %H:%M:%S')} "
f"underflows past {Timestamp.min}"
Reported by Pylint.
Line: 44
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
f"underflows past {Timestamp.min}"
)
pac = Timestamp.min.tz_localize("US/Pacific")
assert pac.value > Timestamp.min.value
pac.tz_convert("Asia/Tokyo") # tz_convert doesn't change value
with pytest.raises(OutOfBoundsDatetime, match=msg):
Timestamp.min.tz_localize("Asia/Tokyo")
# tz_localize that pushes away from the boundary is OK
Reported by Bandit.
Line: 55
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
f"overflows past {Timestamp.max}"
)
tokyo = Timestamp.max.tz_localize("Asia/Tokyo")
assert tokyo.value < Timestamp.max.value
tokyo.tz_convert("US/Pacific") # tz_convert doesn't change value
with pytest.raises(OutOfBoundsDatetime, match=msg):
Timestamp.max.tz_localize("US/Pacific")
def test_tz_localize_ambiguous_bool(self):
Reported by Bandit.
pandas/tests/groupby/test_counting.py
122 issues
Line: 5
Column: 1
from string import ascii_lowercase
import numpy as np
import pytest
from pandas import (
DataFrame,
Index,
MultiIndex,
Reported by Pylint.
Line: 1
Column: 1
from itertools import product
from string import ascii_lowercase
import numpy as np
import pytest
from pandas import (
DataFrame,
Index,
Reported by Pylint.
Line: 20
Column: 1
import pandas._testing as tm
class TestCounting:
def test_cumcount(self):
df = DataFrame([["a"], ["a"], ["a"], ["b"], ["a"]], columns=["A"])
g = df.groupby("A")
sg = g.A
Reported by Pylint.
Line: 20
Column: 1
import pandas._testing as tm
class TestCounting:
def test_cumcount(self):
df = DataFrame([["a"], ["a"], ["a"], ["b"], ["a"]], columns=["A"])
g = df.groupby("A")
sg = g.A
Reported by Pylint.
Line: 21
Column: 5
class TestCounting:
def test_cumcount(self):
df = DataFrame([["a"], ["a"], ["a"], ["b"], ["a"]], columns=["A"])
g = df.groupby("A")
sg = g.A
expected = Series([0, 1, 2, 0, 3])
Reported by Pylint.
Line: 21
Column: 5
class TestCounting:
def test_cumcount(self):
df = DataFrame([["a"], ["a"], ["a"], ["b"], ["a"]], columns=["A"])
g = df.groupby("A")
sg = g.A
expected = Series([0, 1, 2, 0, 3])
Reported by Pylint.
Line: 22
Column: 9
class TestCounting:
def test_cumcount(self):
df = DataFrame([["a"], ["a"], ["a"], ["b"], ["a"]], columns=["A"])
g = df.groupby("A")
sg = g.A
expected = Series([0, 1, 2, 0, 3])
Reported by Pylint.
Line: 23
Column: 9
class TestCounting:
def test_cumcount(self):
df = DataFrame([["a"], ["a"], ["a"], ["b"], ["a"]], columns=["A"])
g = df.groupby("A")
sg = g.A
expected = Series([0, 1, 2, 0, 3])
tm.assert_series_equal(expected, g.cumcount())
Reported by Pylint.
Line: 24
Column: 9
def test_cumcount(self):
df = DataFrame([["a"], ["a"], ["a"], ["b"], ["a"]], columns=["A"])
g = df.groupby("A")
sg = g.A
expected = Series([0, 1, 2, 0, 3])
tm.assert_series_equal(expected, g.cumcount())
tm.assert_series_equal(expected, sg.cumcount())
Reported by Pylint.
Line: 31
Column: 5
tm.assert_series_equal(expected, g.cumcount())
tm.assert_series_equal(expected, sg.cumcount())
def test_cumcount_empty(self):
ge = DataFrame().groupby(level=0)
se = Series(dtype=object).groupby(level=0)
# edge case, as this is usually considered float
e = Series(dtype="int64")
Reported by Pylint.
pandas/tests/reshape/merge/test_merge_asof.py
121 issues
Line: 4
Column: 1
import datetime
import numpy as np
import pytest
import pytz
import pandas as pd
from pandas import (
Index,
Reported by Pylint.
Line: 5
Column: 1
import numpy as np
import pytest
import pytz
import pandas as pd
from pandas import (
Index,
Timedelta,
Reported by Pylint.
Line: 33
Column: 9
@pytest.fixture(autouse=True)
def setup_method(self, datapath):
self.trades = self.read_data(datapath, "trades.csv")
self.quotes = self.read_data(datapath, "quotes.csv", dedupe=True)
self.asof = self.read_data(datapath, "asof.csv")
self.tolerance = self.read_data(datapath, "tolerance.csv")
self.allow_exact_matches = self.read_data(datapath, "allow_exact_matches.csv")
self.allow_exact_matches_and_tolerance = self.read_data(
Reported by Pylint.
Line: 34
Column: 9
def setup_method(self, datapath):
self.trades = self.read_data(datapath, "trades.csv")
self.quotes = self.read_data(datapath, "quotes.csv", dedupe=True)
self.asof = self.read_data(datapath, "asof.csv")
self.tolerance = self.read_data(datapath, "tolerance.csv")
self.allow_exact_matches = self.read_data(datapath, "allow_exact_matches.csv")
self.allow_exact_matches_and_tolerance = self.read_data(
datapath, "allow_exact_matches_and_tolerance.csv"
Reported by Pylint.
Line: 35
Column: 9
self.trades = self.read_data(datapath, "trades.csv")
self.quotes = self.read_data(datapath, "quotes.csv", dedupe=True)
self.asof = self.read_data(datapath, "asof.csv")
self.tolerance = self.read_data(datapath, "tolerance.csv")
self.allow_exact_matches = self.read_data(datapath, "allow_exact_matches.csv")
self.allow_exact_matches_and_tolerance = self.read_data(
datapath, "allow_exact_matches_and_tolerance.csv"
)
Reported by Pylint.
Line: 36
Column: 9
self.trades = self.read_data(datapath, "trades.csv")
self.quotes = self.read_data(datapath, "quotes.csv", dedupe=True)
self.asof = self.read_data(datapath, "asof.csv")
self.tolerance = self.read_data(datapath, "tolerance.csv")
self.allow_exact_matches = self.read_data(datapath, "allow_exact_matches.csv")
self.allow_exact_matches_and_tolerance = self.read_data(
datapath, "allow_exact_matches_and_tolerance.csv"
)
Reported by Pylint.
Line: 37
Column: 9
self.quotes = self.read_data(datapath, "quotes.csv", dedupe=True)
self.asof = self.read_data(datapath, "asof.csv")
self.tolerance = self.read_data(datapath, "tolerance.csv")
self.allow_exact_matches = self.read_data(datapath, "allow_exact_matches.csv")
self.allow_exact_matches_and_tolerance = self.read_data(
datapath, "allow_exact_matches_and_tolerance.csv"
)
def test_examples1(self):
Reported by Pylint.
Line: 38
Column: 9
self.asof = self.read_data(datapath, "asof.csv")
self.tolerance = self.read_data(datapath, "tolerance.csv")
self.allow_exact_matches = self.read_data(datapath, "allow_exact_matches.csv")
self.allow_exact_matches_and_tolerance = self.read_data(
datapath, "allow_exact_matches_and_tolerance.csv"
)
def test_examples1(self):
"""doc-string examples"""
Reported by Pylint.
Line: 1210
Column: 31
tm.assert_frame_equal(result, expected)
@pytest.mark.parametrize(
"func", [lambda x: x, lambda x: to_datetime(x)], ids=["numeric", "datetime"]
)
@pytest.mark.parametrize("side", ["left", "right"])
def test_merge_on_nans(self, func, side):
# GH 23189
msg = f"Merge keys contain null values on {side} side"
Reported by Pylint.
Line: 1
Column: 1
import datetime
import numpy as np
import pytest
import pytz
import pandas as pd
from pandas import (
Index,
Reported by Pylint.
pandas/tests/tseries/offsets/test_ticks.py
121 issues
Line: 9
Column: 1
timedelta,
)
from hypothesis import (
assume,
example,
given,
settings,
strategies as st,
Reported by Pylint.
Line: 17
Column: 1
strategies as st,
)
import numpy as np
import pytest
from pandas._libs.tslibs.offsets import delta_to_tick
from pandas import (
Timedelta,
Reported by Pylint.
Line: 19
Column: 1
import numpy as np
import pytest
from pandas._libs.tslibs.offsets import delta_to_tick
from pandas import (
Timedelta,
Timestamp,
)
Reported by Pylint.
Line: 19
Column: 1
import numpy as np
import pytest
from pandas._libs.tslibs.offsets import delta_to_tick
from pandas import (
Timedelta,
Timestamp,
)
Reported by Pylint.
Line: 258
Column: 8
assert not isinstance(result, cls)
assert result.delta == off.delta / 1000
if cls._nanos_inc < Timedelta(seconds=1).value:
# Case where we end up with a bigger class
result = off / 0.001
assert isinstance(result, offsets.Tick)
assert not isinstance(result, cls)
assert result.delta == off.delta / 0.001
Reported by Pylint.
Line: 294
Column: 9
)
with pytest.raises(TypeError, match=msg):
2 / off
with pytest.raises(TypeError, match=msg):
2.0 / off
assert (td64 * 2.5) / off == 2.5
Reported by Pylint.
Line: 296
Column: 9
with pytest.raises(TypeError, match=msg):
2 / off
with pytest.raises(TypeError, match=msg):
2.0 / off
assert (td64 * 2.5) / off == 2.5
if cls is not Nano:
# skip pytimedelta for Nano since it gets dropped
Reported by Pylint.
Line: 364
Column: 13
for left, right in [("infer", off), (off, "infer")]:
with pytest.raises(TypeError, match=msg):
left < right
with pytest.raises(TypeError, match=msg):
left <= right
with pytest.raises(TypeError, match=msg):
left > right
with pytest.raises(TypeError, match=msg):
Reported by Pylint.
Line: 366
Column: 13
with pytest.raises(TypeError, match=msg):
left < right
with pytest.raises(TypeError, match=msg):
left <= right
with pytest.raises(TypeError, match=msg):
left > right
with pytest.raises(TypeError, match=msg):
left >= right
Reported by Pylint.
Line: 368
Column: 13
with pytest.raises(TypeError, match=msg):
left <= right
with pytest.raises(TypeError, match=msg):
left > right
with pytest.raises(TypeError, match=msg):
left >= right
@pytest.mark.parametrize("cls", tick_classes)
Reported by Pylint.