The following issues were found
asv_bench/benchmarks/tslibs/timedelta.py
42 issues
Line: 9
Column: 1
import numpy as np
from pandas import Timedelta
class TimedeltaConstructor:
def setup(self):
self.nptimedelta64 = np.timedelta64(3600)
Reported by Pylint.
Line: 14
Column: 9
class TimedeltaConstructor:
def setup(self):
self.nptimedelta64 = np.timedelta64(3600)
self.dttimedelta = datetime.timedelta(seconds=3600)
self.td = Timedelta(3600, unit="s")
def time_from_int(self):
Timedelta(123456789)
Reported by Pylint.
Line: 15
Column: 9
class TimedeltaConstructor:
def setup(self):
self.nptimedelta64 = np.timedelta64(3600)
self.dttimedelta = datetime.timedelta(seconds=3600)
self.td = Timedelta(3600, unit="s")
def time_from_int(self):
Timedelta(123456789)
Reported by Pylint.
Line: 16
Column: 9
def setup(self):
self.nptimedelta64 = np.timedelta64(3600)
self.dttimedelta = datetime.timedelta(seconds=3600)
self.td = Timedelta(3600, unit="s")
def time_from_int(self):
Timedelta(123456789)
def time_from_unit(self):
Reported by Pylint.
Line: 60
Column: 9
return td
def time_timedelta_days(self, td):
td.days
def time_timedelta_seconds(self, td):
td.seconds
def time_timedelta_microseconds(self, td):
Reported by Pylint.
Line: 63
Column: 9
td.days
def time_timedelta_seconds(self, td):
td.seconds
def time_timedelta_microseconds(self, td):
td.microseconds
def time_timedelta_nanoseconds(self, td):
Reported by Pylint.
Line: 66
Column: 9
td.seconds
def time_timedelta_microseconds(self, td):
td.microseconds
def time_timedelta_nanoseconds(self, td):
td.nanoseconds
Reported by Pylint.
Line: 69
Column: 9
td.microseconds
def time_timedelta_nanoseconds(self, td):
td.nanoseconds
Reported by Pylint.
Line: 12
Column: 1
from pandas import Timedelta
class TimedeltaConstructor:
def setup(self):
self.nptimedelta64 = np.timedelta64(3600)
self.dttimedelta = datetime.timedelta(seconds=3600)
self.td = Timedelta(3600, unit="s")
Reported by Pylint.
Line: 13
Column: 5
class TimedeltaConstructor:
def setup(self):
self.nptimedelta64 = np.timedelta64(3600)
self.dttimedelta = datetime.timedelta(seconds=3600)
self.td = Timedelta(3600, unit="s")
def time_from_int(self):
Reported by Pylint.
asv_bench/benchmarks/eval.py
42 issues
Line: 3
Column: 1
import numpy as np
import pandas as pd
try:
import pandas.core.computation.expressions as expr
except ImportError:
import pandas.computation.expressions as expr
Reported by Pylint.
Line: 66
Column: 1
self.df.query("(a >= @self.min_val) & (a <= @self.max_val)")
from .pandas_vb_common import setup # noqa: F401 isort:skip
Reported by Pylint.
Line: 16
Column: 21
params = [["numexpr", "python"], [1, "all"]]
param_names = ["engine", "threads"]
def setup(self, engine, threads):
self.df = pd.DataFrame(np.random.randn(20000, 100))
self.df2 = pd.DataFrame(np.random.randn(20000, 100))
self.df3 = pd.DataFrame(np.random.randn(20000, 100))
self.df4 = pd.DataFrame(np.random.randn(20000, 100))
Reported by Pylint.
Line: 17
Column: 9
param_names = ["engine", "threads"]
def setup(self, engine, threads):
self.df = pd.DataFrame(np.random.randn(20000, 100))
self.df2 = pd.DataFrame(np.random.randn(20000, 100))
self.df3 = pd.DataFrame(np.random.randn(20000, 100))
self.df4 = pd.DataFrame(np.random.randn(20000, 100))
if threads == 1:
Reported by Pylint.
Line: 18
Column: 9
def setup(self, engine, threads):
self.df = pd.DataFrame(np.random.randn(20000, 100))
self.df2 = pd.DataFrame(np.random.randn(20000, 100))
self.df3 = pd.DataFrame(np.random.randn(20000, 100))
self.df4 = pd.DataFrame(np.random.randn(20000, 100))
if threads == 1:
expr.set_numexpr_threads(1)
Reported by Pylint.
Line: 19
Column: 9
def setup(self, engine, threads):
self.df = pd.DataFrame(np.random.randn(20000, 100))
self.df2 = pd.DataFrame(np.random.randn(20000, 100))
self.df3 = pd.DataFrame(np.random.randn(20000, 100))
self.df4 = pd.DataFrame(np.random.randn(20000, 100))
if threads == 1:
expr.set_numexpr_threads(1)
Reported by Pylint.
Line: 20
Column: 9
self.df = pd.DataFrame(np.random.randn(20000, 100))
self.df2 = pd.DataFrame(np.random.randn(20000, 100))
self.df3 = pd.DataFrame(np.random.randn(20000, 100))
self.df4 = pd.DataFrame(np.random.randn(20000, 100))
if threads == 1:
expr.set_numexpr_threads(1)
def time_add(self, engine, threads):
Reported by Pylint.
Line: 25
Column: 32
if threads == 1:
expr.set_numexpr_threads(1)
def time_add(self, engine, threads):
pd.eval("self.df + self.df2 + self.df3 + self.df4", engine=engine)
def time_and(self, engine, threads):
pd.eval(
"(self.df > 0) & (self.df2 > 0) & (self.df3 > 0) & (self.df4 > 0)",
Reported by Pylint.
Line: 28
Column: 32
def time_add(self, engine, threads):
pd.eval("self.df + self.df2 + self.df3 + self.df4", engine=engine)
def time_and(self, engine, threads):
pd.eval(
"(self.df > 0) & (self.df2 > 0) & (self.df3 > 0) & (self.df4 > 0)",
engine=engine,
)
Reported by Pylint.
Line: 34
Column: 40
engine=engine,
)
def time_chained_cmp(self, engine, threads):
pd.eval("self.df < self.df2 < self.df3 < self.df4", engine=engine)
def time_mult(self, engine, threads):
pd.eval("self.df * self.df2 * self.df3 * self.df4", engine=engine)
Reported by Pylint.
pandas/core/indexes/numeric.py
42 issues
Line: 11
Column: 1
import numpy as np
from pandas._libs import (
index as libindex,
lib,
)
from pandas._typing import (
Dtype,
Reported by Pylint.
Line: 11
Column: 1
import numpy as np
from pandas._libs import (
index as libindex,
lib,
)
from pandas._typing import (
Dtype,
Reported by Pylint.
Line: 132
Column: 11
"i": "integer",
"u": "integer",
"f": "floating",
}[self.dtype.kind]
def __new__(cls, data=None, dtype: Dtype | None = None, copy=False, name=None):
name = maybe_extract_name(name, data, cls)
subarr = cls._ensure_array(data, dtype, copy)
Reported by Pylint.
Line: 232
Column: 27
if is_float(key) and int(key) != key:
# otherwise the `key in self._engine` check casts e.g. 1.1 -> 1
return False
return key in self._engine
except (OverflowError, TypeError, ValueError):
return False
@doc(Index.astype)
def astype(self, dtype, copy=True):
Reported by Pylint.
Line: 258
Column: 24
# NumericIndex[int32] and not Int64Index with dtype int64.
# When Int64Index etc. are removed from the code base, removed this also.
if not is_extension_array_dtype(dtype) and is_numeric_dtype(dtype):
return self._constructor(self, dtype=dtype, copy=copy)
return super().astype(dtype, copy=copy)
# ----------------------------------------------------------------
# Indexing Methods
Reported by Pylint.
Line: 258
Column: 24
# NumericIndex[int32] and not Int64Index with dtype int64.
# When Int64Index etc. are removed from the code base, removed this also.
if not is_extension_array_dtype(dtype) and is_numeric_dtype(dtype):
return self._constructor(self, dtype=dtype, copy=copy)
return super().astype(dtype, copy=copy)
# ----------------------------------------------------------------
# Indexing Methods
Reported by Pylint.
Line: 258
Column: 24
# NumericIndex[int32] and not Int64Index with dtype int64.
# When Int64Index etc. are removed from the code base, removed this also.
if not is_extension_array_dtype(dtype) and is_numeric_dtype(dtype):
return self._constructor(self, dtype=dtype, copy=copy)
return super().astype(dtype, copy=copy)
# ----------------------------------------------------------------
# Indexing Methods
Reported by Pylint.
Line: 378
Column: 16
FutureWarning,
stacklevel=2,
)
return self._values.view(self._default_dtype)
class Int64Index(IntegerIndex):
_index_descr_args = {
"klass": "Int64Index",
Reported by Pylint.
Line: 82
Column: 1
"""
class NumericIndex(Index):
_index_descr_args = {
"klass": "NumericIndex",
"ltype": "integer or float",
"dtype": "inferred",
"extra": "",
Reported by Pylint.
Line: 82
Column: 1
"""
class NumericIndex(Index):
_index_descr_args = {
"klass": "NumericIndex",
"ltype": "integer or float",
"dtype": "inferred",
"extra": "",
Reported by Pylint.
pandas/tests/frame/methods/test_isin.py
42 issues
Line: 2
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas import (
DataFrame,
MultiIndex,
Series,
)
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas import (
DataFrame,
MultiIndex,
Series,
)
Reported by Pylint.
Line: 13
Column: 1
import pandas._testing as tm
class TestDataFrameIsIn:
def test_isin(self):
# GH#4211
df = DataFrame(
{
"vals": [1, 2, 3, 4],
Reported by Pylint.
Line: 14
Column: 5
class TestDataFrameIsIn:
def test_isin(self):
# GH#4211
df = DataFrame(
{
"vals": [1, 2, 3, 4],
"ids": ["a", "b", "f", "n"],
Reported by Pylint.
Line: 14
Column: 5
class TestDataFrameIsIn:
def test_isin(self):
# GH#4211
df = DataFrame(
{
"vals": [1, 2, 3, 4],
"ids": ["a", "b", "f", "n"],
Reported by Pylint.
Line: 16
Column: 9
class TestDataFrameIsIn:
def test_isin(self):
# GH#4211
df = DataFrame(
{
"vals": [1, 2, 3, 4],
"ids": ["a", "b", "f", "n"],
"ids2": ["a", "n", "c", "n"],
},
Reported by Pylint.
Line: 31
Column: 5
tm.assert_frame_equal(result, expected)
@pytest.mark.parametrize("empty", [[], Series(dtype=object), np.array([])])
def test_isin_empty(self, empty):
# GH#16991
df = DataFrame({"A": ["a", "b", "c"], "B": ["a", "e", "f"]})
expected = DataFrame(False, df.index, df.columns)
result = df.isin(empty)
Reported by Pylint.
Line: 31
Column: 5
tm.assert_frame_equal(result, expected)
@pytest.mark.parametrize("empty", [[], Series(dtype=object), np.array([])])
def test_isin_empty(self, empty):
# GH#16991
df = DataFrame({"A": ["a", "b", "c"], "B": ["a", "e", "f"]})
expected = DataFrame(False, df.index, df.columns)
result = df.isin(empty)
Reported by Pylint.
Line: 33
Column: 9
@pytest.mark.parametrize("empty", [[], Series(dtype=object), np.array([])])
def test_isin_empty(self, empty):
# GH#16991
df = DataFrame({"A": ["a", "b", "c"], "B": ["a", "e", "f"]})
expected = DataFrame(False, df.index, df.columns)
result = df.isin(empty)
tm.assert_frame_equal(result, expected)
Reported by Pylint.
Line: 39
Column: 5
result = df.isin(empty)
tm.assert_frame_equal(result, expected)
def test_isin_dict(self):
df = DataFrame({"A": ["a", "b", "c"], "B": ["a", "e", "f"]})
d = {"A": ["a"]}
expected = DataFrame(False, df.index, df.columns)
expected.loc[0, "A"] = True
Reported by Pylint.
pandas/core/dtypes/api.py
42 issues
Line: 3
Column: 1
# flake8: noqa
from pandas.core.dtypes.common import (
is_array_like,
is_bool,
is_bool_dtype,
is_categorical,
is_categorical_dtype,
is_complex,
Reported by Pylint.
Line: 3
Column: 1
# flake8: noqa
from pandas.core.dtypes.common import (
is_array_like,
is_bool,
is_bool_dtype,
is_categorical,
is_categorical_dtype,
is_complex,
Reported by Pylint.
Line: 3
Column: 1
# flake8: noqa
from pandas.core.dtypes.common import (
is_array_like,
is_bool,
is_bool_dtype,
is_categorical,
is_categorical_dtype,
is_complex,
Reported by Pylint.
Line: 3
Column: 1
# flake8: noqa
from pandas.core.dtypes.common import (
is_array_like,
is_bool,
is_bool_dtype,
is_categorical,
is_categorical_dtype,
is_complex,
Reported by Pylint.
Line: 3
Column: 1
# flake8: noqa
from pandas.core.dtypes.common import (
is_array_like,
is_bool,
is_bool_dtype,
is_categorical,
is_categorical_dtype,
is_complex,
Reported by Pylint.
Line: 3
Column: 1
# flake8: noqa
from pandas.core.dtypes.common import (
is_array_like,
is_bool,
is_bool_dtype,
is_categorical,
is_categorical_dtype,
is_complex,
Reported by Pylint.
Line: 3
Column: 1
# flake8: noqa
from pandas.core.dtypes.common import (
is_array_like,
is_bool,
is_bool_dtype,
is_categorical,
is_categorical_dtype,
is_complex,
Reported by Pylint.
Line: 3
Column: 1
# flake8: noqa
from pandas.core.dtypes.common import (
is_array_like,
is_bool,
is_bool_dtype,
is_categorical,
is_categorical_dtype,
is_complex,
Reported by Pylint.
Line: 3
Column: 1
# flake8: noqa
from pandas.core.dtypes.common import (
is_array_like,
is_bool,
is_bool_dtype,
is_categorical,
is_categorical_dtype,
is_complex,
Reported by Pylint.
Line: 3
Column: 1
# flake8: noqa
from pandas.core.dtypes.common import (
is_array_like,
is_bool,
is_bool_dtype,
is_categorical,
is_categorical_dtype,
is_complex,
Reported by Pylint.
pandas/tests/window/moments/test_moments_ewm.py
42 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas import (
DataFrame,
Series,
)
import pandas._testing as tm
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas import (
DataFrame,
Series,
)
import pandas._testing as tm
Reported by Pylint.
Line: 12
Column: 1
@pytest.mark.parametrize("name", ["var", "std", "mean"])
def test_ewma_series(series, name):
series_result = getattr(series.ewm(com=10), name)()
assert isinstance(series_result, Series)
@pytest.mark.parametrize("name", ["var", "std", "mean"])
Reported by Pylint.
Line: 14
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
@pytest.mark.parametrize("name", ["var", "std", "mean"])
def test_ewma_series(series, name):
series_result = getattr(series.ewm(com=10), name)()
assert isinstance(series_result, Series)
@pytest.mark.parametrize("name", ["var", "std", "mean"])
def test_ewma_frame(frame, name):
frame_result = getattr(frame.ewm(com=10), name)()
Reported by Bandit.
Line: 18
Column: 1
@pytest.mark.parametrize("name", ["var", "std", "mean"])
def test_ewma_frame(frame, name):
frame_result = getattr(frame.ewm(com=10), name)()
assert isinstance(frame_result, DataFrame)
def test_ewma_adjust():
Reported by Pylint.
Line: 20
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
@pytest.mark.parametrize("name", ["var", "std", "mean"])
def test_ewma_frame(frame, name):
frame_result = getattr(frame.ewm(com=10), name)()
assert isinstance(frame_result, DataFrame)
def test_ewma_adjust():
vals = Series(np.zeros(1000))
vals[5] = 1
Reported by Bandit.
Line: 23
Column: 1
assert isinstance(frame_result, DataFrame)
def test_ewma_adjust():
vals = Series(np.zeros(1000))
vals[5] = 1
result = vals.ewm(span=100, adjust=False).mean().sum()
assert np.abs(result - 1) < 1e-2
Reported by Pylint.
Line: 27
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
vals = Series(np.zeros(1000))
vals[5] = 1
result = vals.ewm(span=100, adjust=False).mean().sum()
assert np.abs(result - 1) < 1e-2
@pytest.mark.parametrize("adjust", [True, False])
@pytest.mark.parametrize("ignore_na", [True, False])
def test_ewma_cases(adjust, ignore_na):
Reported by Bandit.
Line: 32
Column: 1
@pytest.mark.parametrize("adjust", [True, False])
@pytest.mark.parametrize("ignore_na", [True, False])
def test_ewma_cases(adjust, ignore_na):
# try adjust/ignore_na args matrix
s = Series([1.0, 2.0, 4.0, 8.0])
if adjust:
Reported by Pylint.
Line: 35
Column: 5
def test_ewma_cases(adjust, ignore_na):
# try adjust/ignore_na args matrix
s = Series([1.0, 2.0, 4.0, 8.0])
if adjust:
expected = Series([1.0, 1.6, 2.736842, 4.923077])
else:
expected = Series([1.0, 1.333333, 2.222222, 4.148148])
Reported by Pylint.
pandas/tests/io/test_user_agent.py
41 issues
Line: 9
Column: 1
from io import BytesIO
import threading
import pytest
import pandas.util._test_decorators as td
import pandas as pd
import pandas._testing as tm
Reported by Pylint.
Line: 127
Column: 9
# so just overwrite that attribute on this instance to not do that
# protected by an importorskip in the respective test
import fsspec
response_df.to_parquet(
"memory://fastparquet_user_agent.parquet",
index=False,
engine="fastparquet",
Reported by Pylint.
Line: 30
Column: 9
shared logic at the start of a GET request
"""
self.send_response(200)
self.requested_from_user_agent = self.headers["User-Agent"]
response_df = pd.DataFrame(
{
"header": [self.requested_from_user_agent],
}
)
Reported by Pylint.
Line: 191
Column: 3
ParquetFastParquetUserAgentResponder,
pd.read_parquet,
"fastparquet",
# TODO(ArrayManager) fastparquet
marks=td.skip_array_manager_not_yet_implemented,
),
(PickleUserAgentResponder, pd.read_pickle, None),
(StataUserAgentResponder, pd.read_stata, None),
(GzippedCSVUserAgentResponder, pd.read_csv, None),
Reported by Pylint.
Line: 232
Column: 3
ParquetFastParquetUserAgentResponder,
pd.read_parquet,
"fastparquet",
# TODO(ArrayManager) fastparquet
marks=td.skip_array_manager_not_yet_implemented,
),
(PickleUserAgentResponder, pd.read_pickle, None),
(StataUserAgentResponder, pd.read_stata, None),
(GzippedCSVUserAgentResponder, pd.read_csv, None),
Reported by Pylint.
Line: 336
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b108_hardcoded_tmp_directory.html
"storage_options passed with buffer, or non-supported URL"
)
with pytest.raises(ValueError, match=msg):
true_df.to_parquet("/tmp/junk.parquet", storage_options=headers, engine=engine)
Reported by Bandit.
Line: 38
Column: 5
)
return response_df
def gzip_bytes(self, response_bytes):
"""
some web servers will send back gzipped files to save bandwidth
"""
bio = BytesIO()
zipper = gzip.GzipFile(fileobj=bio, mode="w")
Reported by Pylint.
Line: 56
Column: 1
self.wfile.write(response_bytes)
class CSVUserAgentResponder(BaseUserAgentResponder):
def do_GET(self):
response_df = self.start_processing_headers()
self.send_header("Content-Type", "text/csv")
self.end_headers()
Reported by Pylint.
Line: 57
Column: 5
class CSVUserAgentResponder(BaseUserAgentResponder):
def do_GET(self):
response_df = self.start_processing_headers()
self.send_header("Content-Type", "text/csv")
self.end_headers()
Reported by Pylint.
Line: 57
Column: 5
class CSVUserAgentResponder(BaseUserAgentResponder):
def do_GET(self):
response_df = self.start_processing_headers()
self.send_header("Content-Type", "text/csv")
self.end_headers()
Reported by Pylint.
pandas/tests/arrays/floating/test_comparison.py
41 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 import BaseOpsUtil
class TestComparisonOps(BaseOpsUtil):
Reported by Pylint.
Line: 15
Column: 33
# array
result = pd.Series(op(data, other))
expected = pd.Series(op(data._data, other), dtype="boolean")
# fill the nan locations
expected[data._mask] = pd.NA
tm.assert_series_equal(result, expected)
Reported by Pylint.
Line: 18
Column: 18
expected = pd.Series(op(data._data, other), dtype="boolean")
# fill the nan locations
expected[data._mask] = pd.NA
tm.assert_series_equal(result, expected)
# series
s = pd.Series(data)
Reported by Pylint.
Line: 26
Column: 33
s = pd.Series(data)
result = op(s, other)
expected = op(pd.Series(data._data), other)
# fill the nan locations
expected[data._mask] = pd.NA
expected = expected.astype("boolean")
Reported by Pylint.
Line: 29
Column: 18
expected = op(pd.Series(data._data), other)
# fill the nan locations
expected[data._mask] = pd.NA
expected = expected.astype("boolean")
tm.assert_series_equal(result, expected)
@pytest.mark.parametrize("other", [True, False, pd.NA, -1.0, 0.0, 1])
Reported by Pylint.
Line: 44
Column: 25
if other is pd.NA:
expected = pd.array([None, None, None], dtype="boolean")
else:
values = op(a._data, other)
expected = pd.arrays.BooleanArray(values, a._mask, copy=True)
tm.assert_extension_array_equal(result, expected)
# ensure we haven't mutated anything inplace
result[0] = pd.NA
Reported by Pylint.
Line: 45
Column: 55
expected = pd.array([None, None, None], dtype="boolean")
else:
values = op(a._data, other)
expected = pd.arrays.BooleanArray(values, a._mask, copy=True)
tm.assert_extension_array_equal(result, expected)
# ensure we haven't mutated anything inplace
result[0] = pd.NA
tm.assert_extension_array_equal(a, pd.array([1.0, 0.0, None], dtype="Float64"))
Reported by Pylint.
Line: 58
Column: 30
b = pd.array([0, 1, None, 0, 1, None], dtype="Float64")
result = op(a, b)
values = op(a._data, b._data)
mask = a._mask | b._mask
expected = pd.arrays.BooleanArray(values, mask)
tm.assert_extension_array_equal(result, expected)
Reported by Pylint.
Line: 58
Column: 21
b = pd.array([0, 1, None, 0, 1, None], dtype="Float64")
result = op(a, b)
values = op(a._data, b._data)
mask = a._mask | b._mask
expected = pd.arrays.BooleanArray(values, mask)
tm.assert_extension_array_equal(result, expected)
Reported by Pylint.
Line: 59
Column: 26
result = op(a, b)
values = op(a._data, b._data)
mask = a._mask | b._mask
expected = pd.arrays.BooleanArray(values, mask)
tm.assert_extension_array_equal(result, expected)
# ensure we haven't mutated anything inplace
Reported by Pylint.
pandas/tests/series/methods/test_isin.py
41 issues
Line: 2
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas import (
Series,
date_range,
)
import pandas._testing as tm
Reported by Pylint.
Line: 119
Column: 17
dti = date_range("2013-01-01", "2013-01-05")
ser = Series(dti)
other = dti.tz_localize("UTC")
res = dti.isin(other)
expected = np.array([False] * len(dti), dtype=bool)
tm.assert_numpy_array_equal(res, expected)
Reported by Pylint.
Line: 119
Column: 17
dti = date_range("2013-01-01", "2013-01-05")
ser = Series(dti)
other = dti.tz_localize("UTC")
res = dti.isin(other)
expected = np.array([False] * len(dti), dtype=bool)
tm.assert_numpy_array_equal(res, expected)
Reported by Pylint.
Line: 133
Column: 14
def test_isin_period_freq_mismatch(self):
dti = date_range("2013-01-01", "2013-01-05")
pi = dti.to_period("M")
ser = Series(pi)
# We construct another PeriodIndex with the same i8 values
# but different dtype
dtype = dti.to_period("Y").dtype
Reported by Pylint.
Line: 133
Column: 14
def test_isin_period_freq_mismatch(self):
dti = date_range("2013-01-01", "2013-01-05")
pi = dti.to_period("M")
ser = Series(pi)
# We construct another PeriodIndex with the same i8 values
# but different dtype
dtype = dti.to_period("Y").dtype
Reported by Pylint.
Line: 138
Column: 17
# We construct another PeriodIndex with the same i8 values
# but different dtype
dtype = dti.to_period("Y").dtype
other = PeriodArray._simple_new(pi.asi8, dtype=dtype)
res = pi.isin(other)
expected = np.array([False] * len(pi), dtype=bool)
tm.assert_numpy_array_equal(res, expected)
Reported by Pylint.
Line: 138
Column: 17
# We construct another PeriodIndex with the same i8 values
# but different dtype
dtype = dti.to_period("Y").dtype
other = PeriodArray._simple_new(pi.asi8, dtype=dtype)
res = pi.isin(other)
expected = np.array([False] * len(pi), dtype=bool)
tm.assert_numpy_array_equal(res, expected)
Reported by Pylint.
Line: 139
Column: 17
# We construct another PeriodIndex with the same i8 values
# but different dtype
dtype = dti.to_period("Y").dtype
other = PeriodArray._simple_new(pi.asi8, dtype=dtype)
res = pi.isin(other)
expected = np.array([False] * len(pi), dtype=bool)
tm.assert_numpy_array_equal(res, expected)
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
import pandas as pd
from pandas import (
Series,
date_range,
)
import pandas._testing as tm
Reported by Pylint.
Line: 13
Column: 1
from pandas.core.arrays import PeriodArray
class TestSeriesIsIn:
def test_isin(self):
s = Series(["A", "B", "C", "a", "B", "B", "A", "C"])
result = s.isin(["A", "C"])
expected = Series([True, False, True, False, False, False, True, True])
Reported by Pylint.
pandas/tests/io/test_feather.py
41 issues
Line: 3
Column: 1
""" test feather-format compat """
import numpy as np
import pytest
import pandas.util._test_decorators as td
import pandas as pd
import pandas._testing as tm
Reported by Pylint.
Line: 38
Column: 5
with tm.ensure_clean() as path:
to_feather(df, path)
def check_round_trip(self, df, expected=None, write_kwargs={}, **read_kwargs):
if expected is None:
expected = df
with tm.ensure_clean() as path:
Reported by Pylint.
Line: 92
Column: 3
)
df["periods"] = pd.period_range("2013", freq="M", periods=3)
df["timedeltas"] = pd.timedelta_range("1 day", periods=3)
# TODO temporary disable due to regression in pyarrow 0.17.1
# https://github.com/pandas-dev/pandas/issues/34255
# df["intervals"] = pd.interval_range(0, 3, 3)
assert df.dttz.dtype.tz.zone == "US/Eastern"
self.check_round_trip(df)
Reported by Pylint.
Line: 21
Column: 1
@filter_sparse
@pytest.mark.single
@pytest.mark.filterwarnings("ignore:CategoricalBlock is deprecated:DeprecationWarning")
class TestFeather:
def check_error_on_write(self, df, exc, err_msg):
# check that we are raising the exception
# on writing
with pytest.raises(exc, match=err_msg):
Reported by Pylint.
Line: 22
Column: 5
@pytest.mark.single
@pytest.mark.filterwarnings("ignore:CategoricalBlock is deprecated:DeprecationWarning")
class TestFeather:
def check_error_on_write(self, df, exc, err_msg):
# check that we are raising the exception
# on writing
with pytest.raises(exc, match=err_msg):
with tm.ensure_clean() as path:
Reported by Pylint.
Line: 22
Column: 5
@pytest.mark.single
@pytest.mark.filterwarnings("ignore:CategoricalBlock is deprecated:DeprecationWarning")
class TestFeather:
def check_error_on_write(self, df, exc, err_msg):
# check that we are raising the exception
# on writing
with pytest.raises(exc, match=err_msg):
with tm.ensure_clean() as path:
Reported by Pylint.
Line: 22
Column: 5
@pytest.mark.single
@pytest.mark.filterwarnings("ignore:CategoricalBlock is deprecated:DeprecationWarning")
class TestFeather:
def check_error_on_write(self, df, exc, err_msg):
# check that we are raising the exception
# on writing
with pytest.raises(exc, match=err_msg):
with tm.ensure_clean() as path:
Reported by Pylint.
Line: 30
Column: 5
with tm.ensure_clean() as path:
to_feather(df, path)
def check_external_error_on_write(self, df):
# check that we are raising the exception
# on writing
with tm.external_error_raised(Exception):
with tm.ensure_clean() as path:
Reported by Pylint.
Line: 30
Column: 5
with tm.ensure_clean() as path:
to_feather(df, path)
def check_external_error_on_write(self, df):
# check that we are raising the exception
# on writing
with tm.external_error_raised(Exception):
with tm.ensure_clean() as path:
Reported by Pylint.
Line: 30
Column: 5
with tm.ensure_clean() as path:
to_feather(df, path)
def check_external_error_on_write(self, df):
# check that we are raising the exception
# on writing
with tm.external_error_raised(Exception):
with tm.ensure_clean() as path:
Reported by Pylint.