Search is not available for this dataset
repo_id
stringlengths
12
110
file_path
stringlengths
24
164
content
stringlengths
3
89.3M
__index_level_0__
int64
0
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/window/test_rolling_quantile.py
from functools import partial import numpy as np import pytest from pandas import ( DataFrame, Series, concat, isna, notna, ) import pandas._testing as tm from pandas.tseries import offsets def scoreatpercentile(a, per): values = np.sort(a, axis=0) idx = int(per / 1.0 * (values.shape[0...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/window/test_rolling_skew_kurt.py
from functools import partial import numpy as np import pytest from pandas import ( DataFrame, Series, concat, isna, notna, ) import pandas._testing as tm from pandas.tseries import offsets @pytest.mark.parametrize("sp_func, roll_func", [["kurtosis", "kurt"], ["skew", "skew"]]) def test_series(...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/window/test_dtypes.py
import numpy as np import pytest from pandas.errors import DataError from pandas.core.dtypes.common import pandas_dtype from pandas import ( NA, DataFrame, Series, ) import pandas._testing as tm # gh-12373 : rolling functions error on float32 data # make sure rolling functions works for different dtypes...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/window/test_timeseries_window.py
import numpy as np import pytest from pandas import ( DataFrame, DatetimeIndex, MultiIndex, NaT, Series, Timestamp, date_range, ) import pandas._testing as tm from pandas.tseries import offsets @pytest.fixture def regular(): return DataFrame( {"A": date_range("20130101", peri...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/window/test_rolling_functions.py
from datetime import datetime import numpy as np import pytest import pandas.util._test_decorators as td from pandas import ( DataFrame, DatetimeIndex, Series, concat, isna, notna, ) import pandas._testing as tm from pandas.tseries import offsets @pytest.mark.parametrize( "compare_func...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/window/test_expanding.py
import numpy as np import pytest from pandas import ( DataFrame, DatetimeIndex, Index, MultiIndex, Series, isna, notna, ) import pandas._testing as tm def test_doc_string(): df = DataFrame({"B": [0, 1, 2, np.nan, 4]}) df df.expanding(2).sum() def test_constructor(frame_or_se...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/window/conftest.py
from datetime import ( datetime, timedelta, ) import numpy as np import pytest import pandas.util._test_decorators as td from pandas import ( DataFrame, Series, bdate_range, ) @pytest.fixture(params=[True, False]) def raw(request): """raw keyword argument for rolling.apply""" return req...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/window/test_win_type.py
import numpy as np import pytest from pandas import ( DataFrame, Series, Timedelta, concat, date_range, ) import pandas._testing as tm from pandas.api.indexers import BaseIndexer @pytest.fixture( params=[ "triang", "blackman", "hamming", "bartlett", "bo...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/window/test_pairwise.py
import numpy as np import pytest from pandas.compat import IS64 from pandas import ( DataFrame, Index, MultiIndex, Series, date_range, ) import pandas._testing as tm from pandas.core.algorithms import safe_sort @pytest.fixture( params=[ DataFrame([[2, 4], [1, 2], [5, 2], [8, 1]], col...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/window/test_ewm.py
import numpy as np import pytest from pandas import ( DataFrame, DatetimeIndex, Series, date_range, ) import pandas._testing as tm def test_doc_string(): df = DataFrame({"B": [0, 1, 2, np.nan, 4]}) df df.ewm(com=0.5).mean() def test_constructor(frame_or_series): c = frame_or_series(...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/window/test_online.py
import numpy as np import pytest from pandas.compat import ( is_ci_environment, is_platform_mac, is_platform_windows, ) from pandas import ( DataFrame, Series, ) import pandas._testing as tm pytestmark = [ pytest.mark.single_cpu, pytest.mark.skipif( is_ci_environment() and (is_pla...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/window/test_api.py
import numpy as np import pytest from pandas.errors import ( DataError, SpecificationError, ) from pandas import ( DataFrame, Index, MultiIndex, Period, Series, Timestamp, concat, date_range, timedelta_range, ) import pandas._testing as tm def test_getitem(step): fram...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/window/test_groupby.py
import numpy as np import pytest from pandas import ( DataFrame, Index, MultiIndex, Series, Timestamp, date_range, to_datetime, ) import pandas._testing as tm from pandas.api.indexers import BaseIndexer from pandas.core.groupby.groupby import get_groupby @pytest.fixture def times_frame():...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/window/test_base_indexer.py
import numpy as np import pytest from pandas import ( DataFrame, MultiIndex, Series, concat, date_range, ) import pandas._testing as tm from pandas.api.indexers import ( BaseIndexer, FixedForwardWindowIndexer, ) from pandas.core.indexers.objects import ( ExpandingIndexer, FixedWindo...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/window/test_numba.py
import numpy as np import pytest from pandas.compat import ( is_ci_environment, is_platform_mac, is_platform_windows, ) from pandas.errors import NumbaUtilError import pandas.util._test_decorators as td from pandas import ( DataFrame, Series, option_context, to_datetime, ) import pandas._t...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/window/test_cython_aggregations.py
from functools import partial import sys import numpy as np import pytest import pandas._libs.window.aggregations as window_aggregations from pandas import Series import pandas._testing as tm def _get_rolling_aggregations(): # list pairs of name and function # each function has this signature: # (const...
0
public_repos/pandas/pandas/tests/window
public_repos/pandas/pandas/tests/window/moments/test_moments_consistency_expanding.py
import numpy as np import pytest from pandas import Series import pandas._testing as tm def no_nans(x): return x.notna().all().all() def all_na(x): return x.isnull().all().all() @pytest.mark.parametrize("f", [lambda v: Series(v).sum(), np.nansum, np.sum]) def test_expanding_apply_consistency_sum_nans(req...
0
public_repos/pandas/pandas/tests/window
public_repos/pandas/pandas/tests/window/moments/conftest.py
import itertools import numpy as np import pytest from pandas import ( DataFrame, Series, notna, ) def create_series(): return [ Series(dtype=np.float64, name="a"), Series([np.nan] * 5), Series([1.0] * 5), Series(range(5, 0, -1)), Series(range(5)), Ser...
0
public_repos/pandas/pandas/tests/window
public_repos/pandas/pandas/tests/window/moments/test_moments_consistency_ewm.py
import numpy as np import pytest from pandas import ( DataFrame, Series, concat, ) import pandas._testing as tm def create_mock_weights(obj, com, adjust, ignore_na): if isinstance(obj, DataFrame): if not len(obj.columns): return DataFrame(index=obj.index, columns=obj.columns) ...
0
public_repos/pandas/pandas/tests/window
public_repos/pandas/pandas/tests/window/moments/test_moments_consistency_rolling.py
import numpy as np import pytest from pandas import Series import pandas._testing as tm def no_nans(x): return x.notna().all().all() def all_na(x): return x.isnull().all().all() @pytest.fixture(params=[(1, 0), (5, 1)]) def rolling_consistency_cases(request): """window, min_periods""" return reque...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/computation/test_eval.py
from __future__ import annotations from functools import reduce from itertools import product import operator import numpy as np import pytest from pandas.compat import PY312 from pandas.errors import ( NumExprClobberingError, PerformanceWarning, UndefinedVariableError, ) import pandas.util._test_decorat...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/computation/test_compat.py
import pytest from pandas.compat._optional import VERSIONS import pandas as pd from pandas.core.computation import expr from pandas.core.computation.engines import ENGINES from pandas.util.version import Version def test_compat(): # test we have compat with our version of numexpr from pandas.core.computati...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/copy_view/test_functions.py
import numpy as np import pytest from pandas import ( DataFrame, Index, Series, concat, merge, ) import pandas._testing as tm from pandas.tests.copy_view.util import get_array def test_concat_frames(using_copy_on_write): df = DataFrame({"b": ["a"] * 3}) df2 = DataFrame({"a": ["a"] * 3}) ...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/copy_view/test_core_functionalities.py
import numpy as np import pytest from pandas import DataFrame import pandas._testing as tm from pandas.tests.copy_view.util import get_array def test_assigning_to_same_variable_removes_references(using_copy_on_write): df = DataFrame({"a": [1, 2, 3]}) df = df.reset_index() if using_copy_on_write: ...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/copy_view/test_setitem.py
import numpy as np import pytest from pandas import ( DataFrame, Index, MultiIndex, RangeIndex, Series, ) import pandas._testing as tm from pandas.tests.copy_view.util import get_array # ----------------------------------------------------------------------------- # Copy/view behaviour for the val...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/copy_view/test_astype.py
import pickle import numpy as np import pytest from pandas.compat.pyarrow import pa_version_under12p0 import pandas.util._test_decorators as td import pandas as pd from pandas import ( DataFrame, Series, Timestamp, date_range, ) import pandas._testing as tm from pandas.tests.copy_view.util import get...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/copy_view/test_internals.py
import numpy as np import pytest import pandas.util._test_decorators as td import pandas as pd from pandas import DataFrame import pandas._testing as tm from pandas.tests.copy_view.util import get_array @td.skip_array_manager_invalid_test def test_consolidate(using_copy_on_write): # create unconsolidated DataFr...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/copy_view/test_methods.py
import numpy as np import pytest from pandas.errors import SettingWithCopyWarning import pandas as pd from pandas import ( DataFrame, Index, MultiIndex, Period, Series, Timestamp, date_range, period_range, ) import pandas._testing as tm from pandas.tests.copy_view.util import get_array...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/copy_view/test_array.py
import numpy as np import pytest from pandas import ( DataFrame, Series, date_range, ) import pandas._testing as tm from pandas.tests.copy_view.util import get_array # ----------------------------------------------------------------------------- # Copy/view behaviour for accessing underlying array of Seri...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/copy_view/test_indexing.py
import numpy as np import pytest from pandas.errors import SettingWithCopyWarning from pandas.core.dtypes.common import is_float_dtype import pandas as pd from pandas import ( DataFrame, Series, ) import pandas._testing as tm from pandas.tests.copy_view.util import get_array @pytest.fixture(params=["numpy"...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/copy_view/test_clip.py
import numpy as np from pandas import DataFrame import pandas._testing as tm from pandas.tests.copy_view.util import get_array def test_clip_inplace_reference(using_copy_on_write): df = DataFrame({"a": [1.5, 2, 3]}) df_copy = df.copy() arr_a = get_array(df, "a") view = df[:] df.clip(lower=2, inpl...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/copy_view/util.py
from pandas import ( Categorical, Index, Series, ) from pandas.core.arrays import BaseMaskedArray def get_array(obj, col=None): """ Helper method to get array for a DataFrame column or a Series. Equivalent of df[col].values, but without going through normal getitem, which triggers trackin...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/copy_view/test_util.py
import numpy as np from pandas import DataFrame from pandas.tests.copy_view.util import get_array def test_get_array_numpy(): df = DataFrame({"a": [1, 2, 3]}) assert np.shares_memory(get_array(df, "a"), get_array(df, "a")) def test_get_array_masked(): df = DataFrame({"a": [1, 2, 3]}, dtype="Int64") ...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/copy_view/test_replace.py
import numpy as np import pytest from pandas import ( Categorical, DataFrame, ) import pandas._testing as tm from pandas.tests.copy_view.util import get_array @pytest.mark.parametrize( "replace_kwargs", [ {"to_replace": {"a": 1, "b": 4}, "value": -1}, # Test CoW splits blocks to avoid...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/copy_view/test_constructors.py
import numpy as np import pytest import pandas as pd from pandas import ( DataFrame, DatetimeIndex, Index, Period, PeriodIndex, Series, Timedelta, TimedeltaIndex, Timestamp, ) import pandas._testing as tm from pandas.tests.copy_view.util import get_array # -------------------------...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/copy_view/test_interp_fillna.py
import numpy as np import pytest from pandas import ( NA, ArrowDtype, DataFrame, Interval, NaT, Series, Timestamp, interval_range, ) import pandas._testing as tm from pandas.tests.copy_view.util import get_array @pytest.mark.parametrize("method", ["pad", "nearest", "linear"]) def test...
0
public_repos/pandas/pandas/tests/copy_view
public_repos/pandas/pandas/tests/copy_view/index/test_index.py
import numpy as np import pytest from pandas import ( DataFrame, Index, Series, ) import pandas._testing as tm from pandas.tests.copy_view.util import get_array def index_view(index_data=[1, 2]): df = DataFrame({"a": index_data, "b": 1.5}) view = df[:] df = df.set_index("a", drop=True) id...
0
public_repos/pandas/pandas/tests/copy_view
public_repos/pandas/pandas/tests/copy_view/index/test_timedeltaindex.py
import pytest from pandas import ( Series, Timedelta, TimedeltaIndex, timedelta_range, ) import pandas._testing as tm pytestmark = pytest.mark.filterwarnings( "ignore:Setting a value on a view:FutureWarning" ) @pytest.mark.parametrize( "cons", [ lambda x: TimedeltaIndex(x), ...
0
public_repos/pandas/pandas/tests/copy_view
public_repos/pandas/pandas/tests/copy_view/index/test_periodindex.py
import pytest from pandas import ( Period, PeriodIndex, Series, period_range, ) import pandas._testing as tm pytestmark = pytest.mark.filterwarnings( "ignore:Setting a value on a view:FutureWarning" ) @pytest.mark.parametrize( "cons", [ lambda x: PeriodIndex(x), lambda x:...
0
public_repos/pandas/pandas/tests/copy_view
public_repos/pandas/pandas/tests/copy_view/index/test_datetimeindex.py
import pytest from pandas import ( DatetimeIndex, Series, Timestamp, date_range, ) import pandas._testing as tm pytestmark = pytest.mark.filterwarnings( "ignore:Setting a value on a view:FutureWarning" ) @pytest.mark.parametrize( "cons", [ lambda x: DatetimeIndex(x), lamb...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/plotting/test_misc.py
""" Test cases for misc plot functions """ import os import numpy as np import pytest import pandas.util._test_decorators as td from pandas import ( DataFrame, Index, Series, Timestamp, date_range, interval_range, period_range, plotting, ) import pandas._testing as tm from pandas.test...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/plotting/test_backend.py
import sys import types import pytest import pandas.util._test_decorators as td import pandas @pytest.fixture def dummy_backend(): db = types.ModuleType("pandas_dummy_backend") setattr(db, "plot", lambda *args, **kwargs: "used_dummy") return db @pytest.fixture def restore_backend(): """Restore th...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/plotting/common.py
""" Module consolidating common testing functions for checking plotting. """ from __future__ import annotations from typing import TYPE_CHECKING import numpy as np from pandas.core.dtypes.api import is_list_like import pandas as pd from pandas import Series import pandas._testing as tm if TYPE_CHECKING: from ...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/plotting/conftest.py
import gc import numpy as np import pytest from pandas import ( DataFrame, to_datetime, ) @pytest.fixture(autouse=True) def mpl_cleanup(): # matplotlib/testing/decorators.py#L24 # 1) Resets units registry # 2) Resets rc_context # 3) Closes all figures mpl = pytest.importorskip("matplotli...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/plotting/test_style.py
import pytest from pandas import Series pytest.importorskip("matplotlib") from pandas.plotting._matplotlib.style import get_standard_colors class TestGetStandardColors: @pytest.mark.parametrize( "num_colors, expected", [ (3, ["red", "green", "blue"]), (5, ["red", "green",...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/plotting/test_datetimelike.py
""" Test cases for time series specific (freq conversion, etc) """ from datetime import ( date, datetime, time, timedelta, ) import pickle import numpy as np import pytest from pandas._libs.tslibs import ( BaseOffset, to_offset, ) from pandas._libs.tslibs.dtypes import freq_to_period_freqstr ...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/plotting/test_converter.py
from datetime import ( date, datetime, ) import subprocess import sys import numpy as np import pytest import pandas._config.config as cf from pandas._libs.tslibs import to_offset from pandas import ( Index, Period, PeriodIndex, Series, Timestamp, arrays, date_range, ) import pan...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/plotting/test_common.py
import pytest from pandas import DataFrame from pandas.tests.plotting.common import ( _check_plot_works, _check_ticks_props, _gen_two_subplots, ) plt = pytest.importorskip("matplotlib.pyplot") class TestCommon: def test__check_ticks_props(self): # GH 34768 df = DataFrame({"b": [0, 1,...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/plotting/test_boxplot_method.py
""" Test cases for .boxplot method """ import itertools import string import numpy as np import pytest from pandas import ( DataFrame, MultiIndex, Series, date_range, plotting, timedelta_range, ) import pandas._testing as tm from pandas.tests.plotting.common import ( _check_axes_shape, ...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/plotting/test_hist_method.py
""" Test cases for .hist method """ import re import numpy as np import pytest from pandas import ( DataFrame, Index, Series, to_datetime, ) import pandas._testing as tm from pandas.tests.plotting.common import ( _check_ax_scales, _check_axes_shape, _check_colors, _check_legend_labels,...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/plotting/test_groupby.py
""" Test cases for GroupBy.plot """ import numpy as np import pytest from pandas import ( DataFrame, Index, Series, ) from pandas.tests.plotting.common import ( _check_axes_shape, _check_legend_labels, ) pytest.importorskip("matplotlib") class TestDataFrameGroupByPlots: def test_series_gro...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/plotting/test_series.py
""" Test cases for Series.plot """ from datetime import datetime from itertools import chain import numpy as np import pytest from pandas.compat import is_platform_linux from pandas.compat.numpy import np_version_gte1p24 import pandas.util._test_decorators as td import pandas as pd from pandas import ( DataFrame...
0
public_repos/pandas/pandas/tests/plotting
public_repos/pandas/pandas/tests/plotting/frame/test_hist_box_by.py
import re import numpy as np import pytest from pandas import DataFrame import pandas._testing as tm from pandas.tests.plotting.common import ( _check_axes_shape, _check_plot_works, get_x_axis, get_y_axis, ) pytest.importorskip("matplotlib") @pytest.fixture def hist_df(): df = DataFrame( ...
0
public_repos/pandas/pandas/tests/plotting
public_repos/pandas/pandas/tests/plotting/frame/test_frame_subplots.py
""" Test cases for DataFrame.plot """ import string import numpy as np import pytest from pandas.compat import is_platform_linux from pandas.compat.numpy import np_version_gte1p24 import pandas as pd from pandas import ( DataFrame, Series, date_range, ) import pandas._testing as tm from pandas.tests.plo...
0
public_repos/pandas/pandas/tests/plotting
public_repos/pandas/pandas/tests/plotting/frame/test_frame_groupby.py
""" Test cases for DataFrame.plot """ import pytest from pandas import DataFrame from pandas.tests.plotting.common import _check_visible pytest.importorskip("matplotlib") class TestDataFramePlotsGroupby: def _assert_ytickslabels_visibility(self, axes, expected): for ax, exp in zip(axes, expected): ...
0
public_repos/pandas/pandas/tests/plotting
public_repos/pandas/pandas/tests/plotting/frame/test_frame.py
""" Test cases for DataFrame.plot """ from datetime import ( date, datetime, ) import gc import itertools import re import string import weakref import numpy as np import pytest from pandas.core.dtypes.api import is_list_like import pandas as pd from pandas import ( DataFrame, MultiIndex, PeriodI...
0
public_repos/pandas/pandas/tests/plotting
public_repos/pandas/pandas/tests/plotting/frame/test_frame_color.py
""" Test cases for DataFrame.plot """ import re import numpy as np import pytest import pandas as pd from pandas import DataFrame import pandas._testing as tm from pandas.tests.plotting.common import ( _check_colors, _check_plot_works, _unpack_cycler, ) from pandas.util.version import Version mpl = pytes...
0
public_repos/pandas/pandas/tests/plotting
public_repos/pandas/pandas/tests/plotting/frame/test_frame_legend.py
import numpy as np import pytest import pandas.util._test_decorators as td from pandas import ( DataFrame, date_range, ) from pandas.tests.plotting.common import ( _check_legend_labels, _check_legend_marker, _check_text_labels, ) from pandas.util.version import Version mpl = pytest.importorskip("...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/tools/test_to_numeric.py
import decimal import numpy as np from numpy import iinfo import pytest import pandas as pd from pandas import ( ArrowDtype, DataFrame, Index, Series, to_numeric, ) import pandas._testing as tm @pytest.fixture(params=[None, "ignore", "raise", "coerce"]) def errors(request): return request.pa...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/tools/test_to_datetime.py
""" test to_datetime """ import calendar from collections import deque from datetime import ( date, datetime, timedelta, timezone, ) from decimal import Decimal import locale from dateutil.parser import parse from dateutil.tz.tz import tzoffset import numpy as np import pytest import pytz from pandas...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/tools/test_to_timedelta.py
from datetime import ( time, timedelta, ) import numpy as np import pytest from pandas.errors import OutOfBoundsTimedelta import pandas as pd from pandas import ( Series, TimedeltaIndex, isna, to_timedelta, ) import pandas._testing as tm from pandas.core.arrays import TimedeltaArray class T...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/tools/test_to_time.py
from datetime import time import locale import numpy as np import pytest from pandas.compat import PY311 from pandas import Series import pandas._testing as tm from pandas.core.tools.times import to_time # The tests marked with this are locale-dependent. # They pass, except when the machine locale is zh_CN or it_IT...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/interchange/test_spec_conformance.py
""" A verbatim copy (vendored) of the spec tests. Taken from https://github.com/data-apis/dataframe-api """ import ctypes import math import pytest import pandas as pd @pytest.fixture def df_from_dict(): def maker(dct, is_categorical=False): df = pd.DataFrame(dct) return df.astype("category") if...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/interchange/test_impl.py
from datetime import datetime import numpy as np import pytest from pandas._libs.tslibs import iNaT from pandas.compat import ( is_ci_environment, is_platform_windows, ) from pandas.compat.numpy import np_version_lt1p23 import pandas as pd import pandas._testing as tm from pandas.core.interchange.column impo...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/interchange/test_utils.py
import numpy as np import pytest import pandas as pd from pandas.core.interchange.utils import dtype_to_arrow_c_fmt # TODO: use ArrowSchema to get reference C-string. # At the time, there is no way to access ArrowSchema holding a type format string # from python. The only way to access it is to export the structure t...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/groupby/test_groupby_subclass.py
from datetime import datetime import numpy as np import pytest from pandas import ( DataFrame, Index, Series, ) import pandas._testing as tm from pandas.tests.groupby import get_groupby_method_args pytestmark = pytest.mark.filterwarnings( "ignore:Passing a BlockManager|Passing a SingleBlockManager:De...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/groupby/test_index_as_string.py
import numpy as np import pytest import pandas as pd import pandas._testing as tm @pytest.fixture(params=[["inner"], ["inner", "outer"]]) def frame(request): levels = request.param df = pd.DataFrame( { "outer": ["a", "a", "a", "b", "b", "b"], "inner": [1, 2, 3, 1, 2, 3], ...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/groupby/test_raises.py
# Only tests that raise an error and have no better location should go here. # Tests for specific groupby methods should go in their respective # test file. import datetime import re import numpy as np import pytest from pandas import ( Categorical, DataFrame, Grouper, Series, ) import pandas._testin...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/groupby/test_reductions.py
import builtins import datetime as dt from string import ascii_lowercase import numpy as np import pytest from pandas._libs.tslibs import iNaT import pandas as pd from pandas import ( DataFrame, MultiIndex, Series, Timestamp, date_range, isna, ) import pandas._testing as tm from pandas.util i...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/groupby/test_function.py
import re import numpy as np import pytest from pandas._libs import lib import pandas as pd from pandas import ( DataFrame, Index, Series, Timestamp, date_range, ) import pandas._testing as tm from pandas.tests.groupby import get_groupby_method_args class TestNumericOnly: # make sure that w...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/groupby/test_apply.py
from datetime import ( date, datetime, ) import numpy as np import pytest import pandas as pd from pandas import ( DataFrame, Index, MultiIndex, Series, bdate_range, ) import pandas._testing as tm from pandas.tests.groupby import get_groupby_method_args def test_apply_func_that_appends_g...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/groupby/test_filters.py
from string import ascii_lowercase import numpy as np import pytest import pandas as pd from pandas import ( DataFrame, Series, Timestamp, ) import pandas._testing as tm def test_filter_series(): s = Series([1, 3, 20, 5, 22, 24, 7]) expected_odd = Series([1, 3, 5, 7], index=[0, 1, 3, 6]) exp...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/groupby/test_libgroupby.py
import numpy as np import pytest from pandas._libs import groupby as libgroupby from pandas._libs.groupby import ( group_cumprod, group_cumsum, group_mean, group_sum, group_var, ) from pandas.core.dtypes.common import ensure_platform_int from pandas import isna import pandas._testing as tm clas...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/groupby/test_pipe.py
import numpy as np import pandas as pd from pandas import ( DataFrame, Index, ) import pandas._testing as tm def test_pipe(): # Test the pipe method of DataFrameGroupBy. # Issue #17871 random_state = np.random.default_rng(2) df = DataFrame( { "A": ["foo", "bar", "foo", "...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/groupby/test_timegrouper.py
""" test with the TimeGrouper / grouping with datetimes """ from datetime import ( datetime, timedelta, ) import numpy as np import pytest import pytz import pandas as pd from pandas import ( DataFrame, DatetimeIndex, Index, MultiIndex, Series, Timestamp, date_range, offsets, )...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/groupby/test_counting.py
from itertools import product from string import ascii_lowercase import numpy as np import pytest from pandas import ( DataFrame, Index, MultiIndex, Period, Series, Timedelta, Timestamp, date_range, ) import pandas._testing as tm class TestCounting: def test_cumcount(self): ...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/groupby/test_grouping.py
""" test where we are determining what we are grouping, or getting groups """ from datetime import ( date, timedelta, ) import numpy as np import pytest import pandas as pd from pandas import ( CategoricalIndex, DataFrame, Grouper, Index, MultiIndex, Series, Timestamp, date_ran...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/groupby/test_missing.py
import numpy as np import pytest import pandas as pd from pandas import ( DataFrame, Index, date_range, ) import pandas._testing as tm @pytest.mark.parametrize("func", ["ffill", "bfill"]) def test_groupby_column_index_name_lost_fill_funcs(func): # GH: 29764 groupby loses index sometimes df = Data...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/groupby/test_apply_mutate.py
import numpy as np import pandas as pd import pandas._testing as tm def test_group_by_copy(): # GH#44803 df = pd.DataFrame( { "name": ["Alice", "Bob", "Carl"], "age": [20, 21, 20], } ).set_index("name") msg = "DataFrameGroupBy.apply operated on the grouping co...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/groupby/conftest.py
import numpy as np import pytest from pandas import DataFrame import pandas._testing as tm from pandas.core.groupby.base import ( reduction_kernels, transformation_kernels, ) @pytest.fixture(params=[True, False]) def sort(request): return request.param @pytest.fixture(params=[True, False]) def as_index...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/groupby/test_indexing.py
# Test GroupBy._positional_selector positional grouped indexing GH#42864 import numpy as np import pytest import pandas as pd import pandas._testing as tm @pytest.mark.parametrize( "arg, expected_rows", [ [0, [0, 1, 4]], [2, [5]], [5, []], [-1, [3, 4, 7]], [-2, [1, 6]...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/groupby/test_bin_groupby.py
import numpy as np import pytest from pandas._libs import lib import pandas.util._test_decorators as td import pandas as pd import pandas._testing as tm def assert_block_lengths(x): assert len(x) == len(x._mgr.blocks[0].mgr_locs) return 0 def cumsum_max(x): x.cumsum().max() return 0 @pytest.mark...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/groupby/test_api.py
""" Tests of the groupby API, including internal consistency and with other pandas objects. Tests in this file should only check the existence, names, and arguments of groupby methods. It should not test the results of any groupby operation. """ import inspect import pytest from pandas import ( DataFrame, S...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/groupby/test_groupby.py
from datetime import datetime from decimal import Decimal import re import numpy as np import pytest from pandas.errors import ( PerformanceWarning, SpecificationError, ) import pandas.util._test_decorators as td import pandas as pd from pandas import ( Categorical, DataFrame, Grouper, Index,...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/groupby/test_numba.py
import pytest from pandas import ( DataFrame, Series, option_context, ) import pandas._testing as tm pytestmark = pytest.mark.single_cpu pytest.importorskip("numba") @pytest.mark.filterwarnings("ignore") # Filter warnings when parallel=True and the function can't be parallelized by Numba class TestEngi...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/groupby/test_categorical.py
from datetime import datetime import numpy as np import pytest import pandas as pd from pandas import ( Categorical, CategoricalIndex, DataFrame, Index, MultiIndex, Series, qcut, ) import pandas._testing as tm from pandas.api.typing import SeriesGroupBy from pandas.tests.groupby import get...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/groupby/test_groupby_dropna.py
import numpy as np import pytest from pandas.compat.pyarrow import pa_version_under10p1 from pandas.core.dtypes.missing import na_value_for_dtype import pandas as pd import pandas._testing as tm from pandas.tests.groupby import get_groupby_method_args @pytest.mark.parametrize( "dropna, tuples, outputs", [ ...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/groupby/__init__.py
def get_groupby_method_args(name, obj): """ Get required arguments for a groupby method. When parametrizing a test over groupby methods (e.g. "sum", "mean", "fillna"), it is often the case that arguments are required for certain methods. Parameters ---------- name: str Name of the ...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/groupby/test_cumulative.py
import numpy as np import pytest from pandas.errors import UnsupportedFunctionCall import pandas.util._test_decorators as td import pandas as pd from pandas import ( DataFrame, Series, ) import pandas._testing as tm @pytest.fixture( params=[np.int32, np.int64, np.float32, np.float64, "Int64", "Float64"]...
0
public_repos/pandas/pandas/tests/groupby
public_repos/pandas/pandas/tests/groupby/transform/test_transform.py
""" test with the .transform """ import numpy as np import pytest from pandas._libs import lib from pandas.core.dtypes.common import ensure_platform_int import pandas as pd from pandas import ( Categorical, DataFrame, MultiIndex, Series, Timestamp, concat, date_range, ) import pandas._tes...
0
public_repos/pandas/pandas/tests/groupby
public_repos/pandas/pandas/tests/groupby/transform/test_numba.py
import numpy as np import pytest from pandas.errors import NumbaUtilError from pandas import ( DataFrame, Series, option_context, ) import pandas._testing as tm pytestmark = pytest.mark.single_cpu def test_correct_function_signature(): pytest.importorskip("numba") def incorrect_function(x): ...
0
public_repos/pandas/pandas/tests/groupby
public_repos/pandas/pandas/tests/groupby/aggregate/test_cython.py
""" test cython .agg behavior """ import numpy as np import pytest from pandas.core.dtypes.common import ( is_float_dtype, is_integer_dtype, ) import pandas as pd from pandas import ( DataFrame, Index, NaT, Series, Timedelta, Timestamp, bdate_range, ) import pandas._testing as tm ...
0
public_repos/pandas/pandas/tests/groupby
public_repos/pandas/pandas/tests/groupby/aggregate/test_aggregate.py
""" test .agg behavior / note that .apply is tested generally in test_groupby.py """ import datetime import functools from functools import partial import re import numpy as np import pytest from pandas.errors import SpecificationError from pandas.core.dtypes.common import is_integer_dtype import pandas as pd from ...
0
public_repos/pandas/pandas/tests/groupby
public_repos/pandas/pandas/tests/groupby/aggregate/test_other.py
""" test all other .agg behavior """ import datetime as dt from functools import partial import numpy as np import pytest from pandas.errors import SpecificationError import pandas as pd from pandas import ( DataFrame, Index, MultiIndex, PeriodIndex, Series, date_range, period_range, ) i...
0
public_repos/pandas/pandas/tests/groupby
public_repos/pandas/pandas/tests/groupby/aggregate/test_numba.py
import numpy as np import pytest from pandas.errors import NumbaUtilError from pandas import ( DataFrame, Index, NamedAgg, Series, option_context, ) import pandas._testing as tm pytestmark = pytest.mark.single_cpu def test_correct_function_signature(): pytest.importorskip("numba") def ...
0
public_repos/pandas/pandas/tests/groupby
public_repos/pandas/pandas/tests/groupby/methods/test_is_monotonic.py
import numpy as np import pytest from pandas import ( DataFrame, Index, Series, ) import pandas._testing as tm @pytest.mark.parametrize( "in_vals, out_vals", [ # Basics: strictly increasing (T), strictly decreasing (F), # abs val increasing (F), non-strictly increasing (T) ...
0
public_repos/pandas/pandas/tests/groupby
public_repos/pandas/pandas/tests/groupby/methods/test_groupby_shift_diff.py
import numpy as np import pytest from pandas import ( DataFrame, NaT, Series, Timedelta, Timestamp, date_range, ) import pandas._testing as tm def test_group_shift_with_null_key(): # This test is designed to replicate the segfault in issue #13813. n_rows = 1200 # Generate a moder...
0
public_repos/pandas/pandas/tests/groupby
public_repos/pandas/pandas/tests/groupby/methods/test_nth.py
import numpy as np import pytest import pandas as pd from pandas import ( DataFrame, Index, MultiIndex, Series, Timestamp, isna, ) import pandas._testing as tm def test_first_last_nth(df): # tests for first / last / nth grouped = df.groupby("A") first = grouped.first() expecte...
0
public_repos/pandas/pandas/tests/groupby
public_repos/pandas/pandas/tests/groupby/methods/test_skew.py
import numpy as np import pandas as pd import pandas._testing as tm def test_groupby_skew_equivalence(): # Test that that groupby skew method (which uses libgroupby.group_skew) # matches the results of operating group-by-group (which uses nanops.nanskew) nrows = 1000 ngroups = 3 ncols = 2 na...
0
public_repos/pandas/pandas/tests/groupby
public_repos/pandas/pandas/tests/groupby/methods/test_describe.py
import numpy as np import pytest import pandas as pd from pandas import ( DataFrame, Index, MultiIndex, Timestamp, ) import pandas._testing as tm def test_apply_describe_bug(mframe): grouped = mframe.groupby(level="first") grouped.describe() # it works! def test_series_describe_multikey():...
0