The following issues were found
pandas/tests/io/xml/test_to_xml.py
178 issues
Line: 10
Column: 1
import os
import numpy as np
import pytest
import pandas.util._test_decorators as td
from pandas import (
DataFrame,
Reported by Pylint.
Line: 12
Column: 1
import numpy as np
import pytest
import pandas.util._test_decorators as td
from pandas import (
DataFrame,
Index,
)
Reported by Pylint.
Line: 14
Column: 1
import pandas.util._test_decorators as td
from pandas import (
DataFrame,
Index,
)
import pandas._testing as tm
Reported by Pylint.
Line: 18
Column: 1
DataFrame,
Index,
)
import pandas._testing as tm
from pandas.io.common import get_handle
from pandas.io.xml import read_xml
"""
Reported by Pylint.
Line: 20
Column: 1
)
import pandas._testing as tm
from pandas.io.common import get_handle
from pandas.io.xml import read_xml
"""
CHECKLIST
Reported by Pylint.
Line: 21
Column: 1
import pandas._testing as tm
from pandas.io.common import get_handle
from pandas.io.xml import read_xml
"""
CHECKLIST
[x] - ValueError: "Values for parser can only be lxml or etree."
Reported by Pylint.
Line: 1019
Column: 5
@td.skip_if_no("lxml")
def test_stylesheet_wrong_path(datapath):
from lxml.etree import XMLSyntaxError
xsl = os.path.join("data", "xml", "row_field_output.xslt")
with pytest.raises(
XMLSyntaxError,
Reported by Pylint.
Line: 1033
Column: 5
@td.skip_if_no("lxml")
@pytest.mark.parametrize("val", ["", b""])
def test_empty_string_stylesheet(val):
from lxml.etree import XMLSyntaxError
with pytest.raises(
XMLSyntaxError, match=("Document is empty|Start tag expected, '<' not found")
):
geom_df.to_xml(stylesheet=val)
Reported by Pylint.
Line: 1043
Column: 5
@td.skip_if_no("lxml")
def test_incorrect_xsl_syntax():
from lxml.etree import XMLSyntaxError
xsl = """\
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="utf-8" indent="yes" >
<xsl:strip-space elements="*"/>
Reported by Pylint.
Line: 1072
Column: 5
@td.skip_if_no("lxml")
def test_incorrect_xsl_eval():
from lxml.etree import XSLTParseError
xsl = """\
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="utf-8" indent="yes" />
<xsl:strip-space elements="*"/>
Reported by Pylint.
pandas/tests/dtypes/test_missing.py
178 issues
Line: 6
Column: 1
from decimal import Decimal
import numpy as np
import pytest
from pandas._config import config as cf
from pandas._libs import missing as libmissing
from pandas._libs.tslibs import (
Reported by Pylint.
Line: 10
Column: 1
from pandas._config import config as cf
from pandas._libs import missing as libmissing
from pandas._libs.tslibs import (
iNaT,
is_null_datetimelike,
)
Reported by Pylint.
Line: 210
Column: 15
def test_isna_old_datetimelike(self):
# isna_old should work for dt64tz, td64, and period, not just tznaive
dti = date_range("2016-01-01", periods=3)
dta = dti._data
dta[-1] = NaT
expected = np.array([False, False, True], dtype=bool)
objs = [dta, dta.tz_localize("US/Eastern"), dta - dta, dta.to_period("D")]
Reported by Pylint.
Line: 1
Column: 1
from contextlib import nullcontext
from datetime import datetime
from decimal import Decimal
import numpy as np
import pytest
from pandas._config import config as cf
Reported by Pylint.
Line: 51
Column: 1
@pytest.mark.parametrize("notna_f", [notna, notnull])
def test_notna_notnull(notna_f):
assert notna_f(1.0)
assert not notna_f(None)
assert not notna_f(np.NaN)
with cf.option_context("mode.use_inf_as_na", False):
Reported by Pylint.
Line: 52
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
@pytest.mark.parametrize("notna_f", [notna, notnull])
def test_notna_notnull(notna_f):
assert notna_f(1.0)
assert not notna_f(None)
assert not notna_f(np.NaN)
with cf.option_context("mode.use_inf_as_na", False):
assert notna_f(np.inf)
Reported by Bandit.
Line: 53
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
@pytest.mark.parametrize("notna_f", [notna, notnull])
def test_notna_notnull(notna_f):
assert notna_f(1.0)
assert not notna_f(None)
assert not notna_f(np.NaN)
with cf.option_context("mode.use_inf_as_na", False):
assert notna_f(np.inf)
assert notna_f(-np.inf)
Reported by Bandit.
Line: 54
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def test_notna_notnull(notna_f):
assert notna_f(1.0)
assert not notna_f(None)
assert not notna_f(np.NaN)
with cf.option_context("mode.use_inf_as_na", False):
assert notna_f(np.inf)
assert notna_f(-np.inf)
Reported by Bandit.
Line: 57
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
assert not notna_f(np.NaN)
with cf.option_context("mode.use_inf_as_na", False):
assert notna_f(np.inf)
assert notna_f(-np.inf)
arr = np.array([1.5, np.inf, 3.5, -np.inf])
result = notna_f(arr)
assert result.all()
Reported by Bandit.
Line: 58
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
with cf.option_context("mode.use_inf_as_na", False):
assert notna_f(np.inf)
assert notna_f(-np.inf)
arr = np.array([1.5, np.inf, 3.5, -np.inf])
result = notna_f(arr)
assert result.all()
Reported by Bandit.
pandas/tests/tseries/offsets/test_offsets.py
178 issues
Line: 17
Column: 1
)
import numpy as np
import pytest
from pandas._libs.tslibs import (
NaT,
Timestamp,
conversion,
Reported by Pylint.
Line: 19
Column: 1
import numpy as np
import pytest
from pandas._libs.tslibs import (
NaT,
Timestamp,
conversion,
timezones,
)
Reported by Pylint.
Line: 19
Column: 1
import numpy as np
import pytest
from pandas._libs.tslibs import (
NaT,
Timestamp,
conversion,
timezones,
)
Reported by Pylint.
Line: 25
Column: 1
conversion,
timezones,
)
import pandas._libs.tslibs.offsets as liboffsets
from pandas._libs.tslibs.offsets import (
_get_offset,
_offset_map,
)
from pandas._libs.tslibs.period import INVALID_FREQ_ERR_MSG
Reported by Pylint.
Line: 25
Column: 1
conversion,
timezones,
)
import pandas._libs.tslibs.offsets as liboffsets
from pandas._libs.tslibs.offsets import (
_get_offset,
_offset_map,
)
from pandas._libs.tslibs.period import INVALID_FREQ_ERR_MSG
Reported by Pylint.
Line: 26
Column: 1
timezones,
)
import pandas._libs.tslibs.offsets as liboffsets
from pandas._libs.tslibs.offsets import (
_get_offset,
_offset_map,
)
from pandas._libs.tslibs.period import INVALID_FREQ_ERR_MSG
from pandas.compat import np_datetime64_compat
Reported by Pylint.
Line: 26
Column: 1
timezones,
)
import pandas._libs.tslibs.offsets as liboffsets
from pandas._libs.tslibs.offsets import (
_get_offset,
_offset_map,
)
from pandas._libs.tslibs.period import INVALID_FREQ_ERR_MSG
from pandas.compat import np_datetime64_compat
Reported by Pylint.
Line: 30
Column: 1
_get_offset,
_offset_map,
)
from pandas._libs.tslibs.period import INVALID_FREQ_ERR_MSG
from pandas.compat import np_datetime64_compat
from pandas.errors import PerformanceWarning
from pandas import DatetimeIndex
import pandas._testing as tm
Reported by Pylint.
Line: 30
Column: 1
_get_offset,
_offset_map,
)
from pandas._libs.tslibs.period import INVALID_FREQ_ERR_MSG
from pandas.compat import np_datetime64_compat
from pandas.errors import PerformanceWarning
from pandas import DatetimeIndex
import pandas._testing as tm
Reported by Pylint.
Line: 471
Column: 15
result = offset_s + dti
tm.assert_index_equal(result, dti)
dta = dti._data
with tm.assert_produces_warning(warn):
result = dta + offset_s
tm.assert_equal(result, dta)
with tm.assert_produces_warning(warn):
result = offset_s + dta
Reported by Pylint.
asv_bench/benchmarks/categoricals.py
177 issues
Line: 7
Column: 1
import numpy as np
import pandas as pd
from .pandas_vb_common import tm
try:
from pandas.api.types import union_categoricals
Reported by Pylint.
Line: 9
Column: 1
import pandas as pd
from .pandas_vb_common import tm
try:
from pandas.api.types import union_categoricals
except ImportError:
try:
Reported by Pylint.
Line: 342
Column: 1
self.c.searchsorted(self.key)
from .pandas_vb_common import setup # noqa: F401 isort:skip
Reported by Pylint.
Line: 23
Column: 9
class Constructor:
def setup(self):
N = 10 ** 5
self.categories = list("abcde")
self.cat_idx = pd.Index(self.categories)
self.values = np.tile(self.categories, N)
self.codes = np.tile(range(len(self.categories)), N)
self.datetimes = pd.Series(
Reported by Pylint.
Line: 24
Column: 9
def setup(self):
N = 10 ** 5
self.categories = list("abcde")
self.cat_idx = pd.Index(self.categories)
self.values = np.tile(self.categories, N)
self.codes = np.tile(range(len(self.categories)), N)
self.datetimes = pd.Series(
pd.date_range("1995-01-01 00:00:00", periods=N / 10, freq="s")
Reported by Pylint.
Line: 25
Column: 9
N = 10 ** 5
self.categories = list("abcde")
self.cat_idx = pd.Index(self.categories)
self.values = np.tile(self.categories, N)
self.codes = np.tile(range(len(self.categories)), N)
self.datetimes = pd.Series(
pd.date_range("1995-01-01 00:00:00", periods=N / 10, freq="s")
)
Reported by Pylint.
Line: 26
Column: 9
self.categories = list("abcde")
self.cat_idx = pd.Index(self.categories)
self.values = np.tile(self.categories, N)
self.codes = np.tile(range(len(self.categories)), N)
self.datetimes = pd.Series(
pd.date_range("1995-01-01 00:00:00", periods=N / 10, freq="s")
)
self.datetimes_with_nat = self.datetimes.copy()
Reported by Pylint.
Line: 28
Column: 9
self.values = np.tile(self.categories, N)
self.codes = np.tile(range(len(self.categories)), N)
self.datetimes = pd.Series(
pd.date_range("1995-01-01 00:00:00", periods=N / 10, freq="s")
)
self.datetimes_with_nat = self.datetimes.copy()
self.datetimes_with_nat.iloc[-1] = pd.NaT
Reported by Pylint.
Line: 31
Column: 9
self.datetimes = pd.Series(
pd.date_range("1995-01-01 00:00:00", periods=N / 10, freq="s")
)
self.datetimes_with_nat = self.datetimes.copy()
self.datetimes_with_nat.iloc[-1] = pd.NaT
self.values_some_nan = list(np.tile(self.categories + [np.nan], N))
self.values_all_nan = [np.nan] * len(self.values)
self.values_all_int8 = np.ones(N, "int8")
Reported by Pylint.
Line: 34
Column: 9
self.datetimes_with_nat = self.datetimes.copy()
self.datetimes_with_nat.iloc[-1] = pd.NaT
self.values_some_nan = list(np.tile(self.categories + [np.nan], N))
self.values_all_nan = [np.nan] * len(self.values)
self.values_all_int8 = np.ones(N, "int8")
self.categorical = pd.Categorical(self.values, self.categories)
self.series = pd.Series(self.categorical)
self.intervals = pd.interval_range(0, 1, periods=N // 10)
Reported by Pylint.
pandas/tests/scalar/timestamp/test_unary_ops.py
175 issues
Line: 5
Column: 1
from dateutil.tz import gettz
import numpy as np
import pytest
import pytz
from pytz import utc
from pandas._libs import lib
from pandas._libs.tslibs import (
Reported by Pylint.
Line: 6
Column: 1
from dateutil.tz import gettz
import numpy as np
import pytest
import pytz
from pytz import utc
from pandas._libs import lib
from pandas._libs.tslibs import (
NaT,
Reported by Pylint.
Line: 7
Column: 1
import numpy as np
import pytest
import pytz
from pytz import utc
from pandas._libs import lib
from pandas._libs.tslibs import (
NaT,
Timedelta,
Reported by Pylint.
Line: 9
Column: 1
import pytz
from pytz import utc
from pandas._libs import lib
from pandas._libs.tslibs import (
NaT,
Timedelta,
Timestamp,
conversion,
Reported by Pylint.
Line: 10
Column: 1
from pytz import utc
from pandas._libs import lib
from pandas._libs.tslibs import (
NaT,
Timedelta,
Timestamp,
conversion,
iNaT,
Reported by Pylint.
Line: 18
Column: 1
iNaT,
to_offset,
)
from pandas._libs.tslibs.period import INVALID_FREQ_ERR_MSG
import pandas.util._test_decorators as td
import pandas._testing as tm
Reported by Pylint.
Line: 18
Column: 1
iNaT,
to_offset,
)
from pandas._libs.tslibs.period import INVALID_FREQ_ERR_MSG
import pandas.util._test_decorators as td
import pandas._testing as tm
Reported by Pylint.
Line: 283
Column: 41
@pytest.mark.parametrize(
"method", [Timestamp.round, Timestamp.floor, Timestamp.ceil]
)
def test_round_sanity(self, method, n):
val = np.random.randint(iNaT + 1, lib.i8max, dtype=np.int64)
ts = Timestamp(val)
def checker(res, ts, nanos):
if method is Timestamp.round:
Reported by Pylint.
Line: 431
Column: 43
@pytest.mark.parametrize(
"tz, normalize",
[
(pytz.timezone("US/Eastern"), lambda x: x.tzinfo.normalize(x)),
(gettz("US/Eastern"), lambda x: x),
],
)
def test_replace_across_dst(self, tz, normalize):
# GH#18319 check that 1) timezone is correctly normalized and
Reported by Pylint.
Line: 1
Column: 1
from datetime import datetime
from dateutil.tz import gettz
import numpy as np
import pytest
import pytz
from pytz import utc
from pandas._libs import lib
Reported by Pylint.
pandas/tests/frame/methods/test_astype.py
173 issues
Line: 4
Column: 1
import re
import numpy as np
import pytest
import pandas.util._test_decorators as td
import pandas as pd
from pandas import (
Reported by Pylint.
Line: 529
Column: 21
{
"A": date_range("20130101", periods=3),
"B": (
date_range("20130101", periods=3, tz="US/Eastern")
.tz_convert("UTC")
.tz_localize(None)
),
"C": (
date_range("20130101", periods=3, tz="CET")
Reported by Pylint.
Line: 529
Column: 21
{
"A": date_range("20130101", periods=3),
"B": (
date_range("20130101", periods=3, tz="US/Eastern")
.tz_convert("UTC")
.tz_localize(None)
),
"C": (
date_range("20130101", periods=3, tz="CET")
Reported by Pylint.
Line: 534
Column: 21
.tz_localize(None)
),
"C": (
date_range("20130101", periods=3, tz="CET")
.tz_convert("UTC")
.tz_localize(None)
),
}
)
Reported by Pylint.
Line: 534
Column: 21
.tz_localize(None)
),
"C": (
date_range("20130101", periods=3, tz="CET")
.tz_convert("UTC")
.tz_localize(None)
),
}
)
Reported by Pylint.
Line: 73
Column: 14
def test_astype_mixed_type(self, mixed_type_frame):
# mixed casting
mn = mixed_type_frame._get_numeric_data().copy()
mn["little_float"] = np.array(12345.0, dtype="float16")
mn["big_float"] = np.array(123456789101112.0, dtype="float64")
casted = mn.astype("float64")
_check_cast(casted, "float64")
Reported by Pylint.
Line: 117
Column: 9
# this is the only real reason to do it this way
tf = np.round(float_frame).astype(np.int32)
casted = tf.astype(np.float32, copy=False)
# TODO(wesm): verification?
tf = float_frame.astype(np.float64)
casted = tf.astype(np.int64, copy=False) # noqa
Reported by Pylint.
Line: 119
Column: 3
tf = np.round(float_frame).astype(np.int32)
casted = tf.astype(np.float32, copy=False)
# TODO(wesm): verification?
tf = float_frame.astype(np.float64)
casted = tf.astype(np.int64, copy=False) # noqa
def test_astype_with_view_mixed_float(self, mixed_float_frame):
Reported by Pylint.
Line: 127
Column: 9
tf = mixed_float_frame.reindex(columns=["A", "B", "C"])
casted = tf.astype(np.int64)
casted = tf.astype(np.float32) # noqa
@pytest.mark.parametrize("dtype", [np.int32, np.int64])
@pytest.mark.parametrize("val", [np.nan, np.inf])
def test_astype_cast_nan_inf_int(self, val, dtype):
Reported by Pylint.
Line: 157
Column: 75
expected = DataFrame(
{
"a": list(map(str, map(lambda x: Timestamp(x)._date_repr, a._values))),
"b": list(map(str, map(Timestamp, b._values))),
"c": list(map(lambda x: Timedelta(x)._repr_base(), c._values)),
"d": list(map(str, d._values)),
"e": list(map(str, e._values)),
}
Reported by Pylint.
pandas/tests/arrays/sparse/test_libsparse.py
172 issues
Line: 4
Column: 1
import operator
import numpy as np
import pytest
import pandas._libs.sparse as splib
import pandas.util._test_decorators as td
from pandas import Series
Reported by Pylint.
Line: 6
Column: 1
import numpy as np
import pytest
import pandas._libs.sparse as splib
import pandas.util._test_decorators as td
from pandas import Series
import pandas._testing as tm
from pandas.core.arrays.sparse import (
Reported by Pylint.
Line: 6
Column: 1
import numpy as np
import pytest
import pandas._libs.sparse as splib
import pandas.util._test_decorators as td
from pandas import Series
import pandas._testing as tm
from pandas.core.arrays.sparse import (
Reported by Pylint.
Line: 102
Column: 9
assert isinstance(iresult, IntIndex)
tm.assert_numpy_array_equal(iresult.indices, bresult.to_int_index().indices)
"""
x: ----
y: ----
r: --------
"""
xloc = [0]
Reported by Pylint.
Line: 114
Column: 9
eloc = [0]
elen = [9]
_check_case(xloc, xlen, yloc, ylen, eloc, elen)
"""
x: ----- -----
y: ----- --
"""
xloc = [0, 10]
xlen = [5, 5]
Reported by Pylint.
Line: 125
Column: 9
eloc = [0, 10, 17]
elen = [7, 5, 2]
_check_case(xloc, xlen, yloc, ylen, eloc, elen)
"""
x: ------
y: -------
r: ----------
"""
xloc = [1]
Reported by Pylint.
Line: 137
Column: 9
eloc = [1]
elen = [7]
_check_case(xloc, xlen, yloc, ylen, eloc, elen)
"""
x: ------ -----
y: -------
r: -------------
"""
xloc = [2, 10]
Reported by Pylint.
Line: 149
Column: 9
eloc = [2]
elen = [12]
_check_case(xloc, xlen, yloc, ylen, eloc, elen)
"""
x: --- -----
y: -------
r: -------------
"""
xloc = [0, 5]
Reported by Pylint.
Line: 161
Column: 9
eloc = [0]
elen = [10]
_check_case(xloc, xlen, yloc, ylen, eloc, elen)
"""
x: ------ -----
y: ------- ---
r: -------------
"""
xloc = [2, 10]
Reported by Pylint.
Line: 173
Column: 9
eloc = [2]
elen = [15]
_check_case(xloc, xlen, yloc, ylen, eloc, elen)
"""
x: ----------------------
y: ---- ---- ---
r: ----------------------
"""
xloc = [2]
Reported by Pylint.
pandas/core/indexes/multi.py
171 issues
Line: 23
Column: 1
from pandas._config import get_option
from pandas._libs import (
algos as libalgos,
index as libindex,
lib,
)
from pandas._libs.hashtable import duplicated
Reported by Pylint.
Line: 23
Column: 1
from pandas._config import get_option
from pandas._libs import (
algos as libalgos,
index as libindex,
lib,
)
from pandas._libs.hashtable import duplicated
Reported by Pylint.
Line: 23
Column: 1
from pandas._config import get_option
from pandas._libs import (
algos as libalgos,
index as libindex,
lib,
)
from pandas._libs.hashtable import duplicated
Reported by Pylint.
Line: 28
Column: 1
index as libindex,
lib,
)
from pandas._libs.hashtable import duplicated
from pandas._typing import (
AnyArrayLike,
DtypeObj,
Scalar,
Shape,
Reported by Pylint.
Line: 28
Column: 1
index as libindex,
lib,
)
from pandas._libs.hashtable import duplicated
from pandas._typing import (
AnyArrayLike,
DtypeObj,
Scalar,
Shape,
Reported by Pylint.
Line: 1268
Column: 19
result = level_nbytes + label_nbytes + names_nbytes
# include our engine hashtable
result += self._engine.sizeof(deep=deep)
return result
# --------------------------------------------------------------------
# Rendering Methods
Reported by Pylint.
Line: 1583
Column: 16
decreasing) values.
"""
# monotonic decreasing if and only if reverse is monotonic increasing
return self[::-1].is_monotonic_increasing
@cache_readonly
def _inferred_type_levels(self) -> list[str]:
"""return a list of the inferred types, one for each level"""
return [i.inferred_type for i in self.levels]
Reported by Pylint.
Line: 2156
Column: 16
return Index._with_infer(new_tuples)
def argsort(self, *args, **kwargs) -> np.ndarray:
return self._values.argsort(*args, **kwargs)
@Appender(_index_shared_docs["repeat"] % _index_doc_kwargs)
def repeat(self, repeats: int, axis=None) -> MultiIndex:
nv.validate_repeat((), {"axis": axis})
# error: Incompatible types in assignment (expression has type "ndarray",
Reported by Pylint.
Line: 2844
Column: 24
if keylen == self.nlevels and self.is_unique:
try:
return self._engine.get_loc(key)
except TypeError:
# e.g. test_partial_slicing_with_multiindex partial string slicing
loc, _ = self.get_loc_level(key, list(range(self.nlevels)))
return loc
Reported by Pylint.
Line: 3003
Column: 33
if len(key) == self.nlevels and self.is_unique:
# Complete key in unique index -> standard get_loc
try:
return (self._engine.get_loc(key), None)
except KeyError as err:
raise KeyError(key) from err
except TypeError:
# e.g. partial string indexing
# test_partial_string_timestamp_multiindex
Reported by Pylint.
pandas/tests/groupby/test_categorical.py
171 issues
Line: 4
Column: 1
from datetime import datetime
import numpy as np
import pytest
import pandas.util._test_decorators as td
import pandas as pd
from pandas import (
Reported by Pylint.
Line: 608
Column: 9
def test_categorical_index():
s = np.random.RandomState(12345)
levels = ["foo", "bar", "baz", "qux"]
codes = s.randint(0, 4, size=20)
cats = Categorical.from_codes(codes, levels, ordered=True)
df = DataFrame(np.repeat(np.arange(20), 4).reshape(-1, 4), columns=list("abcd"))
df["cats"] = cats
Reported by Pylint.
Line: 144
Column: 51
tm.assert_series_equal(result, df["a"])
tm.assert_series_equal(
df.a.groupby(c, observed=False).transform(lambda xs: np.sum(xs)), df["a"]
)
tm.assert_frame_equal(df.groupby(c, observed=False).transform(sum), df[["a"]])
tm.assert_frame_equal(
df.groupby(c, observed=False).transform(lambda xs: np.max(xs)), df[["a"]]
)
Reported by Pylint.
Line: 148
Column: 49
)
tm.assert_frame_equal(df.groupby(c, observed=False).transform(sum), df[["a"]])
tm.assert_frame_equal(
df.groupby(c, observed=False).transform(lambda xs: np.max(xs)), df[["a"]]
)
# Filter
tm.assert_series_equal(df.a.groupby(c, observed=False).filter(np.all), df["a"])
tm.assert_frame_equal(df.groupby(c, observed=False).filter(np.all), df)
Reported by Pylint.
Line: 163
Column: 51
tm.assert_series_equal(result, df["a"])
tm.assert_series_equal(
df.a.groupby(c, observed=False).transform(lambda xs: np.sum(xs)), df["a"]
)
tm.assert_frame_equal(df.groupby(c, observed=False).transform(sum), df[["a"]])
tm.assert_frame_equal(
df.groupby(c, observed=False).transform(lambda xs: np.sum(xs)), df[["a"]]
)
Reported by Pylint.
Line: 167
Column: 49
)
tm.assert_frame_equal(df.groupby(c, observed=False).transform(sum), df[["a"]])
tm.assert_frame_equal(
df.groupby(c, observed=False).transform(lambda xs: np.sum(xs)), df[["a"]]
)
# GH 9603
df = DataFrame({"a": [1, 0, 0, 0]})
c = pd.cut(df.a, [0, 1, 2, 3, 4], labels=Categorical(list("abcd")))
Reported by Pylint.
Line: 288
Column: 32
with tm.assert_produces_warning(
FutureWarning, match="Select only valid", check_stacklevel=False
):
result = grouped.apply(lambda x: np.mean(x))
tm.assert_frame_equal(result, expected)
result = grouped.mean()
tm.assert_frame_equal(result, expected)
Reported by Pylint.
Line: 304
Column: 3
tm.assert_series_equal(result, expected)
# TODO(ArrayManager) incorrect dtype for mean()
@td.skip_array_manager_not_yet_implemented
def test_observed(observed, using_array_manager):
# multiple groupers, don't re-expand the output space
# of the grouper
# gh-14942 (implement)
Reported by Pylint.
Line: 306
Column: 29
# TODO(ArrayManager) incorrect dtype for mean()
@td.skip_array_manager_not_yet_implemented
def test_observed(observed, using_array_manager):
# multiple groupers, don't re-expand the output space
# of the grouper
# gh-14942 (implement)
# gh-10132 (back-compat)
# gh-8138 (back-compat)
Reported by Pylint.
Line: 1178
Column: 5
-------
df_cat: DataFrame
"""
df_cat = df.copy()[:4] # leave out some groups
df_cat["A"] = df_cat["A"].astype("category")
df_cat["B"] = df_cat["B"].astype("category")
df_cat["C"] = Series([1, 2, 3, 4])
df_cat = df_cat.drop(["D"], axis=1)
return df_cat
Reported by Pylint.
pandas/tests/indexes/period/test_period.py
169 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas._libs.tslibs.period import IncompatibleFrequency
from pandas import (
DatetimeIndex,
Index,
NaT,
Reported by Pylint.
Line: 4
Column: 1
import numpy as np
import pytest
from pandas._libs.tslibs.period import IncompatibleFrequency
from pandas import (
DatetimeIndex,
Index,
NaT,
Reported by Pylint.
Line: 4
Column: 1
import numpy as np
import pytest
from pandas._libs.tslibs.period import IncompatibleFrequency
from pandas import (
DatetimeIndex,
Index,
NaT,
Reported by Pylint.
Line: 55
Column: 13
def test_no_millisecond_field(self):
msg = "type object 'DatetimeIndex' has no attribute 'millisecond'"
with pytest.raises(AttributeError, match=msg):
DatetimeIndex.millisecond
msg = "'DatetimeIndex' object has no attribute 'millisecond'"
with pytest.raises(AttributeError, match=msg):
DatetimeIndex([]).millisecond
Reported by Pylint.
Line: 59
Column: 13
msg = "'DatetimeIndex' object has no attribute 'millisecond'"
with pytest.raises(AttributeError, match=msg):
DatetimeIndex([]).millisecond
def test_make_time_series(self):
index = period_range(freq="A", start="1/1/2001", end="12/1/2009")
series = Series(1, index=index)
assert isinstance(series, Series)
Reported by Pylint.
Line: 301
Column: 31
)
exp = Index([2011, 2011, -1, 2012, 2012], dtype=np.int64, name="name")
tm.assert_index_equal(idx.year, exp)
exp = Index([1, 2, -1, 3, 4], dtype=np.int64, name="name")
tm.assert_index_equal(idx.month, exp)
def test_pindex_qaccess(self):
pi = PeriodIndex(["2Q05", "3Q05", "4Q05", "1Q06", "2Q06"], freq="Q")
Reported by Pylint.
Line: 303
Column: 31
exp = Index([2011, 2011, -1, 2012, 2012], dtype=np.int64, name="name")
tm.assert_index_equal(idx.year, exp)
exp = Index([1, 2, -1, 3, 4], dtype=np.int64, name="name")
tm.assert_index_equal(idx.month, exp)
def test_pindex_qaccess(self):
pi = PeriodIndex(["2Q05", "3Q05", "4Q05", "1Q06", "2Q06"], freq="Q")
s = Series(np.random.rand(len(pi)), index=pi).cumsum()
# Todo: fix these accessors!
Reported by Pylint.
Line: 320
Column: 16
pi = period_range(start="1/1/11", end="12/31/11", freq="2M")
tm.assert_index_equal(pi, expected)
assert pi.freq == offsets.MonthEnd(2)
assert pi.freqstr == "2M"
pi = period_range(start="1/1/11", periods=6, freq="2M")
tm.assert_index_equal(pi, expected)
assert pi.freq == offsets.MonthEnd(2)
assert pi.freqstr == "2M"
Reported by Pylint.
Line: 325
Column: 16
pi = period_range(start="1/1/11", periods=6, freq="2M")
tm.assert_index_equal(pi, expected)
assert pi.freq == offsets.MonthEnd(2)
assert pi.freqstr == "2M"
def test_iteration(self):
index = period_range(start="1/1/10", periods=4, freq="B")
result = list(index)
Reported by Pylint.
Line: 337
Column: 28
def test_with_multi_index(self):
# #1705
index = date_range("1/1/2012", periods=4, freq="12H")
index_as_arrays = [index.to_period(freq="D"), index.hour]
s = Series([0, 1, 2, 3], index_as_arrays)
assert isinstance(s.index.levels[0], PeriodIndex)
Reported by Pylint.