The following issues were found
asv_bench/benchmarks/rolling.py
168 issues
Line: 3
Column: 1
import numpy as np
import pandas as pd
class Methods:
params = (
["DataFrame", "Series"],
Reported by Pylint.
Line: 303
Column: 1
self.df.ewm(1, method=method).mean(engine="numba")
from .pandas_vb_common import setup # noqa: F401 isort:skip
Reported by Pylint.
Line: 16
Column: 49
)
param_names = ["constructor", "window", "dtype", "method"]
def setup(self, constructor, window, dtype, method):
N = 10 ** 5
arr = (100 * np.random.random(N)).astype(dtype)
self.roll = getattr(pd, constructor)(arr).rolling(window)
def time_rolling(self, constructor, window, dtype, method):
Reported by Pylint.
Line: 19
Column: 9
def setup(self, constructor, window, dtype, method):
N = 10 ** 5
arr = (100 * np.random.random(N)).astype(dtype)
self.roll = getattr(pd, constructor)(arr).rolling(window)
def time_rolling(self, constructor, window, dtype, method):
getattr(self.roll, method)()
def peakmem_rolling(self, constructor, window, dtype, method):
Reported by Pylint.
Line: 21
Column: 49
arr = (100 * np.random.random(N)).astype(dtype)
self.roll = getattr(pd, constructor)(arr).rolling(window)
def time_rolling(self, constructor, window, dtype, method):
getattr(self.roll, method)()
def peakmem_rolling(self, constructor, window, dtype, method):
getattr(self.roll, method)()
Reported by Pylint.
Line: 21
Column: 28
arr = (100 * np.random.random(N)).astype(dtype)
self.roll = getattr(pd, constructor)(arr).rolling(window)
def time_rolling(self, constructor, window, dtype, method):
getattr(self.roll, method)()
def peakmem_rolling(self, constructor, window, dtype, method):
getattr(self.roll, method)()
Reported by Pylint.
Line: 21
Column: 41
arr = (100 * np.random.random(N)).astype(dtype)
self.roll = getattr(pd, constructor)(arr).rolling(window)
def time_rolling(self, constructor, window, dtype, method):
getattr(self.roll, method)()
def peakmem_rolling(self, constructor, window, dtype, method):
getattr(self.roll, method)()
Reported by Pylint.
Line: 24
Column: 31
def time_rolling(self, constructor, window, dtype, method):
getattr(self.roll, method)()
def peakmem_rolling(self, constructor, window, dtype, method):
getattr(self.roll, method)()
class Apply:
params = (
Reported by Pylint.
Line: 24
Column: 44
def time_rolling(self, constructor, window, dtype, method):
getattr(self.roll, method)()
def peakmem_rolling(self, constructor, window, dtype, method):
getattr(self.roll, method)()
class Apply:
params = (
Reported by Pylint.
Line: 24
Column: 52
def time_rolling(self, constructor, window, dtype, method):
getattr(self.roll, method)()
def peakmem_rolling(self, constructor, window, dtype, method):
getattr(self.roll, method)()
class Apply:
params = (
Reported by Pylint.
pandas/tests/apply/test_series_apply.py
167 issues
Line: 7
Column: 1
)
import numpy as np
import pytest
import pandas as pd
from pandas import (
DataFrame,
Index,
Reported by Pylint.
Line: 159
Column: 14
def test_apply_datetimetz():
values = pd.date_range("2011-01-01", "2011-01-02", freq="H").tz_localize(
"Asia/Tokyo"
)
s = Series(values, name="XX")
result = s.apply(lambda x: x + pd.offsets.Day())
Reported by Pylint.
Line: 159
Column: 14
def test_apply_datetimetz():
values = pd.date_range("2011-01-01", "2011-01-02", freq="H").tz_localize(
"Asia/Tokyo"
)
s = Series(values, name="XX")
result = s.apply(lambda x: x + pd.offsets.Day())
Reported by Pylint.
Line: 165
Column: 18
s = Series(values, name="XX")
result = s.apply(lambda x: x + pd.offsets.Day())
exp_values = pd.date_range("2011-01-02", "2011-01-03", freq="H").tz_localize(
"Asia/Tokyo"
)
exp = Series(exp_values, name="XX")
tm.assert_series_equal(result, exp)
Reported by Pylint.
Line: 165
Column: 18
s = Series(values, name="XX")
result = s.apply(lambda x: x + pd.offsets.Day())
exp_values = pd.date_range("2011-01-02", "2011-01-03", freq="H").tz_localize(
"Asia/Tokyo"
)
exp = Series(exp_values, name="XX")
tm.assert_series_equal(result, exp)
Reported by Pylint.
Line: 616
Column: 9
# https://github.com/pandas-dev/pandas/issues/29733
# Check collections.abc.Mapping support as mapper for Series.map
class NonDictMappingWithMissing(non_dict_mapping_subclass):
def __missing__(key):
return "missing"
s = Series([1, 2, 3])
not_a_dictionary = NonDictMappingWithMissing({3: "three"})
result = s.map(not_a_dictionary)
Reported by Pylint.
Line: 616
Column: 9
# https://github.com/pandas-dev/pandas/issues/29733
# Check collections.abc.Mapping support as mapper for Series.map
class NonDictMappingWithMissing(non_dict_mapping_subclass):
def __missing__(key):
return "missing"
s = Series([1, 2, 3])
not_a_dictionary = NonDictMappingWithMissing({3: "three"})
result = s.map(not_a_dictionary)
Reported by Pylint.
Line: 681
Column: 14
def test_map_datetimetz():
values = pd.date_range("2011-01-01", "2011-01-02", freq="H").tz_localize(
"Asia/Tokyo"
)
s = Series(values, name="XX")
# keep tz
Reported by Pylint.
Line: 681
Column: 14
def test_map_datetimetz():
values = pd.date_range("2011-01-01", "2011-01-02", freq="H").tz_localize(
"Asia/Tokyo"
)
s = Series(values, name="XX")
# keep tz
Reported by Pylint.
Line: 688
Column: 18
# keep tz
result = s.map(lambda x: x + pd.offsets.Day())
exp_values = pd.date_range("2011-01-02", "2011-01-03", freq="H").tz_localize(
"Asia/Tokyo"
)
exp = Series(exp_values, name="XX")
tm.assert_series_equal(result, exp)
Reported by Pylint.
pandas/tests/window/test_groupby.py
167 issues
Line: 2
Column: 1
import numpy as np
import pytest
from pandas import (
DataFrame,
Index,
MultiIndex,
Series,
Timestamp,
Reported by Pylint.
Line: 26
Column: 13
msg = r"groupby\(\) got an unexpected keyword argument 'foo'"
with pytest.raises(TypeError, match=msg):
self.frame.groupby("A", foo=1)
g = self.frame.groupby("A")
assert not g.mutated
g = get_groupby(self.frame, by="A", mutated=True)
assert g.mutated
Reported by Pylint.
Line: 143
Column: 9
result = getattr(r.B, f)(pairwise=True)
def func(x):
return getattr(x.B.rolling(4), f)(pairwise=True)
expected = g.apply(func)
tm.assert_series_equal(result, expected)
Reported by Pylint.
Line: 878
Column: 9
result = getattr(r.B, f)(pairwise=True)
def func(x):
return getattr(x.B.expanding(), f)(pairwise=True)
expected = g.apply(func)
tm.assert_series_equal(result, expected)
Reported by Pylint.
Line: 20
Column: 9
class TestRolling:
def setup_method(self):
self.frame = DataFrame({"A": [1] * 20 + [2] * 12 + [3] * 8, "B": np.arange(40)})
def test_mutated(self):
msg = r"groupby\(\) got an unexpected keyword argument 'foo'"
with pytest.raises(TypeError, match=msg):
Reported by Pylint.
Line: 806
Column: 9
class TestExpanding:
def setup_method(self):
self.frame = DataFrame({"A": [1] * 20 + [2] * 12 + [3] * 8, "B": np.arange(40)})
@pytest.mark.parametrize(
"f", ["sum", "mean", "min", "max", "count", "kurt", "skew"]
)
def test_expanding(self, f):
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas import (
DataFrame,
Index,
MultiIndex,
Series,
Timestamp,
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
from pandas import (
DataFrame,
Index,
MultiIndex,
Series,
Timestamp,
Reported by Pylint.
Line: 18
Column: 1
from pandas.core.groupby.groupby import get_groupby
class TestRolling:
def setup_method(self):
self.frame = DataFrame({"A": [1] * 20 + [2] * 12 + [3] * 8, "B": np.arange(40)})
def test_mutated(self):
Reported by Pylint.
Line: 18
Column: 1
from pandas.core.groupby.groupby import get_groupby
class TestRolling:
def setup_method(self):
self.frame = DataFrame({"A": [1] * 20 + [2] * 12 + [3] * 8, "B": np.arange(40)})
def test_mutated(self):
Reported by Pylint.
asv_bench/benchmarks/timeseries.py
166 issues
Line: 6
Column: 1
import dateutil
import numpy as np
from pandas import (
DataFrame,
Series,
date_range,
period_range,
timedelta_range,
Reported by Pylint.
Line: 14
Column: 1
timedelta_range,
)
from pandas.tseries.frequencies import infer_freq
try:
from pandas.plotting._matplotlib.converter import DatetimeConverter
except ImportError:
from pandas.tseries.converter import DatetimeConverter
Reported by Pylint.
Line: 306
Column: 1
self.series.dt.year
from .pandas_vb_common import setup # noqa: F401 isort:skip
Reported by Pylint.
Line: 40
Column: 9
),
"tz_naive": date_range(start="2000", periods=N, freq="s"),
}
self.index = dtidxes[index_type]
def time_add_timedelta(self, index_type):
self.index + timedelta(minutes=2)
def time_normalize(self, index_type):
Reported by Pylint.
Line: 42
Column: 34
}
self.index = dtidxes[index_type]
def time_add_timedelta(self, index_type):
self.index + timedelta(minutes=2)
def time_normalize(self, index_type):
self.index.normalize()
Reported by Pylint.
Line: 43
Column: 9
self.index = dtidxes[index_type]
def time_add_timedelta(self, index_type):
self.index + timedelta(minutes=2)
def time_normalize(self, index_type):
self.index.normalize()
def time_unique(self, index_type):
Reported by Pylint.
Line: 45
Column: 30
def time_add_timedelta(self, index_type):
self.index + timedelta(minutes=2)
def time_normalize(self, index_type):
self.index.normalize()
def time_unique(self, index_type):
self.index.unique()
Reported by Pylint.
Line: 48
Column: 27
def time_normalize(self, index_type):
self.index.normalize()
def time_unique(self, index_type):
self.index.unique()
def time_to_time(self, index_type):
self.index.time
Reported by Pylint.
Line: 51
Column: 28
def time_unique(self, index_type):
self.index.unique()
def time_to_time(self, index_type):
self.index.time
def time_get(self, index_type):
self.index[0]
Reported by Pylint.
Line: 52
Column: 9
self.index.unique()
def time_to_time(self, index_type):
self.index.time
def time_get(self, index_type):
self.index[0]
def time_timeseries_is_month_start(self, index_type):
Reported by Pylint.
pandas/tests/groupby/transform/test_transform.py
166 issues
Line: 5
Column: 1
from io import StringIO
import numpy as np
import pytest
from pandas.core.dtypes.common import (
ensure_platform_int,
is_timedelta64_dtype,
)
Reported by Pylint.
Line: 1053
Column: 25
dates = date_range("1/1/2011", periods=10, freq="D")
stocks = DataFrame({"price": np.arange(10.0)}, index=dates)
stocks["week_id"] = dates.isocalendar().week
result = stocks.groupby(stocks["week_id"])["price"].transform(func)
expected = Series(data=pd.to_datetime(values), index=dates, name="price")
Reported by Pylint.
Line: 1053
Column: 25
dates = date_range("1/1/2011", periods=10, freq="D")
stocks = DataFrame({"price": np.arange(10.0)}, index=dates)
stocks["week_id"] = dates.isocalendar().week
result = stocks.groupby(stocks["week_id"])["price"].transform(func)
expected = Series(data=pd.to_datetime(values), index=dates, name="price")
Reported by Pylint.
Line: 170
Column: 3
def test_transform_axis_1(request, transformation_func, using_array_manager):
# GH 36308
if using_array_manager and transformation_func == "pct_change":
# TODO(ArrayManager) column-wise shift
request.node.add_marker(
pytest.mark.xfail(reason="ArrayManager: shift axis=1 not yet implemented")
)
warn = None
if transformation_func == "tshift":
Reported by Pylint.
Line: 486
Column: 26
g = df.groupby("A")
expected = g.transform(np.mean)
result = g.transform(lambda x: np.mean(x))
tm.assert_frame_equal(result, expected)
def test_groupby_transform_with_int():
Reported by Pylint.
Line: 658
Column: 41
),
],
)
def test_groupby_cum_skipna(op, skipna, input, exp):
df = DataFrame(input)
result = df.groupby("key")["value"].transform(op, skipna=skipna)
if isinstance(exp, dict):
expected = exp[(op, skipna)]
else:
Reported by Pylint.
Line: 727
Column: 17
# bit a of hack to make sure the cythonized shift
# is equivalent to pre 0.17.1 behavior
if op == "shift":
gb._set_group_selection()
if op != "shift" and "int" not in gb_target:
# numeric apply fastpath promotes dtype so have
# to apply separately and concat
i = gb[["int"]].apply(targop)
Reported by Pylint.
Line: 1189
Column: 11
return grp * 2
# Check that the fastpath raises, see _transform_general
obj = gb._obj_with_exclusions
gen = gb.grouper.get_iterator(obj, axis=gb.axis)
fast_path, slow_path = gb._define_paths(func)
_, group = next(gen)
with pytest.raises(NotImplementedError, match="Don't cross the streams"):
Reported by Pylint.
Line: 1191
Column: 16
# Check that the fastpath raises, see _transform_general
obj = gb._obj_with_exclusions
gen = gb.grouper.get_iterator(obj, axis=gb.axis)
fast_path, slow_path = gb._define_paths(func)
_, group = next(gen)
with pytest.raises(NotImplementedError, match="Don't cross the streams"):
fast_path(group)
Reported by Pylint.
Line: 1191
Column: 28
# Check that the fastpath raises, see _transform_general
obj = gb._obj_with_exclusions
gen = gb.grouper.get_iterator(obj, axis=gb.axis)
fast_path, slow_path = gb._define_paths(func)
_, group = next(gen)
with pytest.raises(NotImplementedError, match="Don't cross the streams"):
fast_path(group)
Reported by Pylint.
pandas/util/testing.py
166 issues
Line: 3
Column: 1
import warnings
from pandas._testing import * # noqa
warnings.warn(
(
"pandas.util.testing is deprecated. Use the functions in the "
"public API at pandas.testing instead."
),
Reported by Pylint.
Line: 3
Column: 1
import warnings
from pandas._testing import * # noqa
warnings.warn(
(
"pandas.util.testing is deprecated. Use the functions in the "
"public API at pandas.testing instead."
),
Reported by Pylint.
Line: 3
Column: 1
import warnings
from pandas._testing import * # noqa
warnings.warn(
(
"pandas.util.testing is deprecated. Use the functions in the "
"public API at pandas.testing instead."
),
Reported by Pylint.
Line: 3
Column: 1
import warnings
from pandas._testing import * # noqa
warnings.warn(
(
"pandas.util.testing is deprecated. Use the functions in the "
"public API at pandas.testing instead."
),
Reported by Pylint.
Line: 3
Column: 1
import warnings
from pandas._testing import * # noqa
warnings.warn(
(
"pandas.util.testing is deprecated. Use the functions in the "
"public API at pandas.testing instead."
),
Reported by Pylint.
Line: 3
Column: 1
import warnings
from pandas._testing import * # noqa
warnings.warn(
(
"pandas.util.testing is deprecated. Use the functions in the "
"public API at pandas.testing instead."
),
Reported by Pylint.
Line: 3
Column: 1
import warnings
from pandas._testing import * # noqa
warnings.warn(
(
"pandas.util.testing is deprecated. Use the functions in the "
"public API at pandas.testing instead."
),
Reported by Pylint.
Line: 3
Column: 1
import warnings
from pandas._testing import * # noqa
warnings.warn(
(
"pandas.util.testing is deprecated. Use the functions in the "
"public API at pandas.testing instead."
),
Reported by Pylint.
Line: 3
Column: 1
import warnings
from pandas._testing import * # noqa
warnings.warn(
(
"pandas.util.testing is deprecated. Use the functions in the "
"public API at pandas.testing instead."
),
Reported by Pylint.
Line: 3
Column: 1
import warnings
from pandas._testing import * # noqa
warnings.warn(
(
"pandas.util.testing is deprecated. Use the functions in the "
"public API at pandas.testing instead."
),
Reported by Pylint.
pandas/core/groupby/groupby.py
165 issues
Line: 40
Column: 1
from pandas._config.config import option_context
from pandas._libs import (
Timestamp,
lib,
)
import pandas._libs.groupby as libgroupby
from pandas._typing import (
Reported by Pylint.
Line: 44
Column: 1
Timestamp,
lib,
)
import pandas._libs.groupby as libgroupby
from pandas._typing import (
ArrayLike,
F,
FrameOrSeries,
IndexLabel,
Reported by Pylint.
Line: 44
Column: 1
Timestamp,
lib,
)
import pandas._libs.groupby as libgroupby
from pandas._typing import (
ArrayLike,
F,
FrameOrSeries,
IndexLabel,
Reported by Pylint.
Line: 684
Column: 50
def _selected_obj(self):
# Note: _selected_obj is always just `self.obj` for SeriesGroupBy
if self._selection is None or isinstance(self.obj, Series):
if self._group_selection is not None:
return self.obj[self._group_selection]
return self.obj
else:
return self.obj[self._selection]
Reported by Pylint.
Line: 686
Column: 24
if self._selection is None or isinstance(self.obj, Series):
if self._group_selection is not None:
return self.obj[self._group_selection]
return self.obj
else:
return self.obj[self._selection]
@final
Reported by Pylint.
Line: 687
Column: 20
if self._selection is None or isinstance(self.obj, Series):
if self._group_selection is not None:
return self.obj[self._group_selection]
return self.obj
else:
return self.obj[self._selection]
@final
def _dir_additions(self) -> set[str]:
Reported by Pylint.
Line: 689
Column: 20
return self.obj[self._group_selection]
return self.obj
else:
return self.obj[self._selection]
@final
def _dir_additions(self) -> set[str]:
return self.obj._dir_additions() | self._apply_allowlist
Reported by Pylint.
Line: 693
Column: 16
@final
def _dir_additions(self) -> set[str]:
return self.obj._dir_additions() | self._apply_allowlist
@Substitution(
klass="GroupBy",
examples=dedent(
"""\
Reported by Pylint.
Line: 765
Column: 42
Generator yielding sequence of (name, subsetted object)
for each group
"""
return self.grouper.get_iterator(self.obj, axis=self.axis)
# To track operations that expand dimensions, like ohlc
OutputFrameOrSeries = TypeVar("OutputFrameOrSeries", bound=NDFrame)
Reported by Pylint.
Line: 1087
Column: 28
# get index by slicing original index according to original positions
# slice drops attrs => use set_axis when no rows were dropped
sorted_indexer = result.index
result.index = self._selected_obj.index[sorted_indexer]
else:
result.set_axis(self.obj._get_axis(self.axis), axis=self.axis, inplace=True)
return result
Reported by Pylint.
pandas/tests/resample/test_period_index.py
165 issues
Line: 5
Column: 1
import dateutil
import numpy as np
import pytest
import pytz
from pandas._libs.tslibs.ccalendar import (
DAYS,
MONTHS,
Reported by Pylint.
Line: 6
Column: 1
import dateutil
import numpy as np
import pytest
import pytz
from pandas._libs.tslibs.ccalendar import (
DAYS,
MONTHS,
)
Reported by Pylint.
Line: 8
Column: 1
import pytest
import pytz
from pandas._libs.tslibs.ccalendar import (
DAYS,
MONTHS,
)
from pandas._libs.tslibs.period import IncompatibleFrequency
from pandas.errors import InvalidIndexError
Reported by Pylint.
Line: 8
Column: 1
import pytest
import pytz
from pandas._libs.tslibs.ccalendar import (
DAYS,
MONTHS,
)
from pandas._libs.tslibs.period import IncompatibleFrequency
from pandas.errors import InvalidIndexError
Reported by Pylint.
Line: 12
Column: 1
DAYS,
MONTHS,
)
from pandas._libs.tslibs.period import IncompatibleFrequency
from pandas.errors import InvalidIndexError
import pandas as pd
from pandas import (
DataFrame,
Reported by Pylint.
Line: 12
Column: 1
DAYS,
MONTHS,
)
from pandas._libs.tslibs.period import IncompatibleFrequency
from pandas.errors import InvalidIndexError
import pandas as pd
from pandas import (
DataFrame,
Reported by Pylint.
Line: 329
Column: 17
# GH 23742
index = date_range(start="2017-10-10", end="2017-10-20", freq="1H")
index = index.tz_localize("UTC").tz_convert("America/Sao_Paulo")
df = DataFrame(data=list(range(len(index))), index=index)
result = df.groupby(pd.Grouper(freq="1D")).count()
expected = date_range(
start="2017-10-09",
end="2017-10-20",
Reported by Pylint.
Line: 329
Column: 17
# GH 23742
index = date_range(start="2017-10-10", end="2017-10-20", freq="1H")
index = index.tz_localize("UTC").tz_convert("America/Sao_Paulo")
df = DataFrame(data=list(range(len(index))), index=index)
result = df.groupby(pd.Grouper(freq="1D")).count()
expected = date_range(
start="2017-10-09",
end="2017-10-20",
Reported by Pylint.
Line: 515
Column: 15
# GH 6397
# comparing an offset that doesn't propagate tz's
rng = date_range("1/1/2011", periods=20000, freq="H")
rng = rng.tz_localize("EST")
ts = DataFrame(index=rng)
ts["first"] = np.random.randn(len(rng))
ts["second"] = np.cumsum(np.random.randn(len(rng)))
expected = DataFrame(
{
Reported by Pylint.
Line: 515
Column: 15
# GH 6397
# comparing an offset that doesn't propagate tz's
rng = date_range("1/1/2011", periods=20000, freq="H")
rng = rng.tz_localize("EST")
ts = DataFrame(index=rng)
ts["first"] = np.random.randn(len(rng))
ts["second"] = np.cumsum(np.random.randn(len(rng)))
expected = DataFrame(
{
Reported by Pylint.
pandas/tests/groupby/test_function.py
165 issues
Line: 5
Column: 1
from io import StringIO
import numpy as np
import pytest
from pandas.errors import UnsupportedFunctionCall
import pandas as pd
from pandas import (
Reported by Pylint.
Line: 553
Column: 5
def scipy_sem(*args, **kwargs):
from scipy.stats import sem
return sem(*args, ddof=1, **kwargs)
@pytest.mark.parametrize(
Reported by Pylint.
Line: 620
Column: 11
def test_nlargest_mi_grouper():
# see gh-21411
npr = np.random.RandomState(123456789)
dts = date_range("20180101", periods=10)
iterables = [dts, ["one", "two"]]
idx = MultiIndex.from_product(iterables, names=["first", "second"])
Reported by Pylint.
Line: 84
Column: 8
df.groupby(keys).apply(getattr(np, fname)),
)
if f != sum:
expected = df.groupby(keys).agg(fname).reset_index()
expected.set_index(keys, inplace=True, drop=False)
tm.assert_frame_equal(result, expected, check_dtype=False)
tm.assert_series_equal(getattr(result, fname)(), getattr(df, fname)())
Reported by Pylint.
Line: 169
Column: 3
@pytest.mark.parametrize("method", ["min", "max"])
def test_extrema(self, df, method):
# TODO: min, max *should* handle
# categorical (ordered) dtype
expected_columns = Index(
[
"int",
Reported by Pylint.
Line: 258
Column: 40
# GH#41475 deprecated silently ignoring nuisance columns
warn = None
if len(expected_columns) < len(gb._obj_with_exclusions.columns):
warn = FutureWarning
with tm.assert_produces_warning(warn, match="Dropping invalid columns"):
result = getattr(gb, method)(numeric_only=False)
tm.assert_index_equal(result.columns, expected_columns)
Reported by Pylint.
Line: 288
Column: 3
gni = df.groupby("A", as_index=False)
return gni
# TODO: non-unique columns, as_index=False
@pytest.mark.filterwarnings("ignore:.*Select only valid:FutureWarning")
def test_idxmax(self, gb):
# object dtype so idxmax goes through _aggregate_item_by_item
# GH#5610
# non-cython calls should not include the grouper
Reported by Pylint.
Line: 397
Column: 3
result = df.groupby(bins, observed=observed).median()
expected = df.groupby(bins, observed=observed).agg(lambda x: x.median())
# TODO: GH 41137
tm.assert_frame_equal(result, expected, check_dtype=False)
@pytest.mark.parametrize(
"dtype", ["int8", "int16", "int32", "int64", "float32", "float64", "uint64"]
Reported by Pylint.
Line: 714
Column: 17
getattr(g, func)(foo=1)
def test_cummin(dtypes_for_minmax):
dtype = dtypes_for_minmax[0]
min_val = dtypes_for_minmax[1]
# GH 15048
base_df = DataFrame({"A": [1, 1, 1, 1, 2, 2, 2, 2], "B": [3, 4, 3, 2, 2, 3, 2, 1]})
Reported by Pylint.
Line: 777
Column: 17
tm.assert_frame_equal(expected, result)
def test_cummax(dtypes_for_minmax):
dtype = dtypes_for_minmax[0]
max_val = dtypes_for_minmax[2]
# GH 15048
base_df = DataFrame({"A": [1, 1, 1, 1, 2, 2, 2, 2], "B": [3, 4, 3, 2, 2, 3, 2, 1]})
Reported by Pylint.
pandas/tests/frame/test_subclass.py
164 issues
Line: 2
Column: 1
import numpy as np
import pytest
import pandas.util._test_decorators as td
import pandas as pd
from pandas import (
DataFrame,
Index,
Reported by Pylint.
Line: 89
Column: 16
# see gh-10553
unpickled = tm.round_trip_pickle(df)
tm.assert_frame_equal(df, unpickled)
assert df._metadata == unpickled._metadata
assert df.testattr == unpickled.testattr
def test_indexing_sliced(self):
# GH 11559
df = tm.SubclassedDataFrame(
Reported by Pylint.
Line: 89
Column: 32
# see gh-10553
unpickled = tm.round_trip_pickle(df)
tm.assert_frame_equal(df, unpickled)
assert df._metadata == unpickled._metadata
assert df.testattr == unpickled.testattr
def test_indexing_sliced(self):
# GH 11559
df = tm.SubclassedDataFrame(
Reported by Pylint.
Line: 135
Column: 13
return self.i_dont_exist
with pytest.raises(AttributeError, match=".*i_dont_exist.*"):
A().bar
def test_subclass_align(self):
# GH 12983
df1 = tm.SubclassedDataFrame(
{"a": [1, 3, 5], "b": [1, 3, 5]}, index=list("ACE")
Reported by Pylint.
Line: 537
Column: 18
columns=["first", "last", "variable", "value"],
)
df.apply(lambda x: check_row_subclass(x))
df.apply(lambda x: check_row_subclass(x), axis=1)
expected = tm.SubclassedDataFrame(
[
["John", "Doe", "height", 6.0],
Reported by Pylint.
Line: 538
Column: 18
)
df.apply(lambda x: check_row_subclass(x))
df.apply(lambda x: check_row_subclass(x), axis=1)
expected = tm.SubclassedDataFrame(
[
["John", "Doe", "height", 6.0],
["Mary", "Bo", "height", 6.5],
Reported by Pylint.
Line: 550
Column: 27
columns=["first", "last", "variable", "value"],
)
result = df.apply(lambda x: stretch(x), axis=1)
assert isinstance(result, tm.SubclassedDataFrame)
tm.assert_frame_equal(result, expected)
expected = tm.SubclassedDataFrame([[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]])
Reported by Pylint.
Line: 1
Column: 1
import numpy as np
import pytest
import pandas.util._test_decorators as td
import pandas as pd
from pandas import (
DataFrame,
Index,
Reported by Pylint.
Line: 16
Column: 1
import pandas._testing as tm
class TestDataFrameSubclassing:
def test_frame_subclassing_and_slicing(self):
# Subclass frame and ensure it returns the right class on slicing it
# In reference to PR 9632
class CustomSeries(Series):
Reported by Pylint.
Line: 16
Column: 1
import pandas._testing as tm
class TestDataFrameSubclassing:
def test_frame_subclassing_and_slicing(self):
# Subclass frame and ensure it returns the right class on slicing it
# In reference to PR 9632
class CustomSeries(Series):
Reported by Pylint.