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/dtypes/test_common.py
from __future__ import annotations import numpy as np import pytest import pandas.util._test_decorators as td from pandas.core.dtypes.astype import astype_array import pandas.core.dtypes.common as com from pandas.core.dtypes.dtypes import ( CategoricalDtype, CategoricalDtypeType, DatetimeTZDtype, Ext...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/dtypes/test_inference.py
""" These the test the public routines exposed in types/common.py related to inference and not otherwise tested in types/test_common.py """ import collections from collections import namedtuple from collections.abc import Iterator from datetime import ( date, datetime, time, timedelta, ) from decimal i...
0
public_repos/pandas/pandas/tests/dtypes
public_repos/pandas/pandas/tests/dtypes/cast/test_downcast.py
import decimal import numpy as np import pytest from pandas.core.dtypes.cast import maybe_downcast_to_dtype from pandas import ( Series, Timedelta, ) import pandas._testing as tm @pytest.mark.parametrize( "arr,dtype,expected", [ ( np.array([8.5, 8.6, 8.7, 8.8, 8.9999999999995]),...
0
public_repos/pandas/pandas/tests/dtypes
public_repos/pandas/pandas/tests/dtypes/cast/test_construct_object_arr.py
import pytest from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike @pytest.mark.parametrize("datum1", [1, 2.0, "3", (4, 5), [6, 7], None]) @pytest.mark.parametrize("datum2", [8, 9.0, "10", (11, 12), [13, 14], None]) def test_cast_1d_array(datum1, datum2): data = [datum1, datum2] result...
0
public_repos/pandas/pandas/tests/dtypes
public_repos/pandas/pandas/tests/dtypes/cast/test_infer_datetimelike.py
import numpy as np import pytest from pandas import ( DataFrame, NaT, Series, Timestamp, ) @pytest.mark.parametrize( "data,exp_size", [ # see gh-16362. ([[NaT, "a", "b", 0], [NaT, "b", "c", 1]], 8), ([[NaT, "a", 0], [NaT, "b", 1]], 6), ], ) def test_maybe_infer_to_...
0
public_repos/pandas/pandas/tests/dtypes
public_repos/pandas/pandas/tests/dtypes/cast/test_infer_dtype.py
from datetime import ( date, datetime, timedelta, ) import numpy as np import pytest from pandas.core.dtypes.cast import ( infer_dtype_from, infer_dtype_from_array, infer_dtype_from_scalar, ) from pandas.core.dtypes.common import is_dtype_equal from pandas import ( Categorical, Interv...
0
public_repos/pandas/pandas/tests/dtypes
public_repos/pandas/pandas/tests/dtypes/cast/test_find_common_type.py
import numpy as np import pytest from pandas.core.dtypes.cast import find_common_type from pandas.core.dtypes.common import pandas_dtype from pandas.core.dtypes.dtypes import ( CategoricalDtype, DatetimeTZDtype, IntervalDtype, PeriodDtype, ) from pandas import ( Categorical, Index, ) @pytest...
0
public_repos/pandas/pandas/tests/dtypes
public_repos/pandas/pandas/tests/dtypes/cast/test_can_hold_element.py
import numpy as np from pandas.core.dtypes.cast import can_hold_element def test_can_hold_element_range(any_int_numpy_dtype): # GH#44261 dtype = np.dtype(any_int_numpy_dtype) arr = np.array([], dtype=dtype) rng = range(2, 127) assert can_hold_element(arr, rng) # negatives -> can't be held b...
0
public_repos/pandas/pandas/tests/dtypes
public_repos/pandas/pandas/tests/dtypes/cast/test_construct_from_scalar.py
import numpy as np import pytest from pandas.core.dtypes.cast import construct_1d_arraylike_from_scalar from pandas.core.dtypes.dtypes import CategoricalDtype from pandas import ( Categorical, Timedelta, ) import pandas._testing as tm def test_cast_1d_array_like_from_scalar_categorical(): # see gh-19565...
0
public_repos/pandas/pandas/tests/dtypes
public_repos/pandas/pandas/tests/dtypes/cast/test_promote.py
""" These test the method maybe_promote from core/dtypes/cast.py """ import datetime from decimal import Decimal import numpy as np import pytest from pandas._libs.tslibs import NaT from pandas.core.dtypes.cast import maybe_promote from pandas.core.dtypes.common import is_scalar from pandas.core.dtypes.dtypes impor...
0
public_repos/pandas/pandas/tests/dtypes
public_repos/pandas/pandas/tests/dtypes/cast/test_maybe_box_native.py
from datetime import datetime import numpy as np import pytest from pandas.core.dtypes.cast import maybe_box_native from pandas import ( Interval, Period, Timedelta, Timestamp, ) @pytest.mark.parametrize( "obj,expected_dtype", [ (b"\x00\x10", bytes), (int(4), int), (...
0
public_repos/pandas/pandas/tests/dtypes
public_repos/pandas/pandas/tests/dtypes/cast/test_dict_compat.py
import numpy as np from pandas.core.dtypes.cast import dict_compat from pandas import Timestamp def test_dict_compat(): data_datetime64 = {np.datetime64("1990-03-15"): 1, np.datetime64("2015-03-15"): 2} data_unchanged = {1: 2, 3: 4, 5: 6} expected = {Timestamp("1990-3-15"): 1, Timestamp("2015-03-15"): 2...
0
public_repos/pandas/pandas/tests/dtypes
public_repos/pandas/pandas/tests/dtypes/cast/test_construct_ndarray.py
import numpy as np import pytest import pandas._testing as tm from pandas.core.construction import sanitize_array @pytest.mark.parametrize( "values, dtype, expected", [ ([1, 2, 3], None, np.array([1, 2, 3], dtype=np.int64)), (np.array([1, 2, 3]), None, np.array([1, 2, 3])), (["1", "2"...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/series/test_reductions.py
import numpy as np import pytest import pandas as pd from pandas import Series import pandas._testing as tm @pytest.mark.parametrize("operation, expected", [("min", "a"), ("max", "b")]) def test_reductions_series_strings(operation, expected): # GH#31746 ser = Series(["a", "b"], dtype="string") res_operat...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/series/test_validate.py
import pytest @pytest.mark.parametrize( "func", [ "reset_index", "_set_name", "sort_values", "sort_index", "rename", "dropna", "drop_duplicates", ], ) @pytest.mark.parametrize("inplace", [1, "True", [1, 2, 3], 5.0]) def test_validate_bool_args(string...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/series/test_logical_ops.py
from datetime import datetime import operator import numpy as np import pytest from pandas import ( DataFrame, Index, Series, bdate_range, ) import pandas._testing as tm from pandas.core import ops class TestSeriesLogicalOps: @pytest.mark.filterwarnings("ignore:Downcasting object dtype arrays:Fu...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/series/test_subclass.py
import numpy as np import pytest import pandas as pd import pandas._testing as tm pytestmark = pytest.mark.filterwarnings( "ignore:Passing a BlockManager|Passing a SingleBlockManager:DeprecationWarning" ) class TestSeriesSubclassing: @pytest.mark.parametrize( "idx_method, indexer, exp_data, exp_idx"...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/series/test_npfuncs.py
""" Tests for np.foo applied to Series, not necessarily ufuncs. """ import numpy as np import pytest from pandas import Series import pandas._testing as tm class TestPtp: def test_ptp(self): # GH#21614 N = 1000 arr = np.random.default_rng(2).standard_normal(N) ser = Series(arr) ...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/series/test_formats.py
from datetime import ( datetime, timedelta, ) import numpy as np import pytest import pandas as pd from pandas import ( Categorical, DataFrame, Index, Series, date_range, option_context, period_range, timedelta_range, ) import pandas._testing as tm class TestSeriesRepr: d...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/series/test_missing.py
from datetime import timedelta import numpy as np import pytest from pandas._libs import iNaT import pandas as pd from pandas import ( Categorical, Index, NaT, Series, isna, ) import pandas._testing as tm class TestSeriesMissingData: def test_categorical_nan_handling(self): # NaNs a...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/series/test_arithmetic.py
from datetime import ( date, timedelta, timezone, ) from decimal import Decimal import operator import numpy as np import pytest from pandas._libs import lib from pandas._libs.tslibs import IncompatibleFrequency import pandas as pd from pandas import ( Categorical, DatetimeTZDtype, Index, ...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/series/test_api.py
import inspect import pydoc import numpy as np import pytest import pandas as pd from pandas import ( DataFrame, Index, Series, date_range, ) import pandas._testing as tm class TestSeriesMisc: def test_tab_completion(self): # GH 9910 s = Series(list("abcd")) # Series of s...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/series/test_constructors.py
from collections import OrderedDict from collections.abc import Iterator from datetime import ( datetime, timedelta, ) from dateutil.tz import tzoffset import numpy as np from numpy import ma import pytest from pandas._libs import ( iNaT, lib, ) from pandas.errors import IntCastingNaNError import pand...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/series/test_iteration.py
class TestIteration: def test_keys(self, datetime_series): assert datetime_series.keys() is datetime_series.index def test_iter_datetimes(self, datetime_series): for i, val in enumerate(datetime_series): # pylint: disable-next=unnecessary-list-index-lookup assert val == ...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/series/test_ufunc.py
from collections import deque import re import string import numpy as np import pytest import pandas.util._test_decorators as td import pandas as pd import pandas._testing as tm from pandas.arrays import SparseArray @pytest.fixture(params=[np.add, np.logaddexp]) def ufunc(request): # dunder op return reque...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/series/test_unary.py
import pytest from pandas import Series import pandas._testing as tm class TestSeriesUnaryOps: # __neg__, __pos__, __invert__ def test_neg(self): ser = tm.makeStringSeries() ser.name = "series" tm.assert_series_equal(-ser, -1 * ser) def test_invert(self): ser = tm.makeSt...
0
public_repos/pandas/pandas/tests
public_repos/pandas/pandas/tests/series/test_cumulative.py
""" Tests for Series cumulative operations. See also -------- tests.frame.test_cumulative """ import numpy as np import pytest import pandas as pd import pandas._testing as tm methods = { "cumsum": np.cumsum, "cumprod": np.cumprod, "cummin": np.minimum.accumulate, "cummax": np.maximum.accumulate, } ...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/accessors/test_dt_accessor.py
import calendar from datetime import ( date, datetime, time, ) import locale import unicodedata import numpy as np import pytest import pytz from pandas._libs.tslibs.timezones import maybe_get_tz from pandas.errors import SettingWithCopyError from pandas.core.dtypes.common import ( is_integer_dtype, ...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/accessors/test_struct_accessor.py
import re import pytest from pandas import ( ArrowDtype, DataFrame, Index, Series, ) import pandas._testing as tm pa = pytest.importorskip("pyarrow") def test_struct_accessor_dtypes(): ser = Series( [], dtype=ArrowDtype( pa.struct( [ ...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/accessors/test_str_accessor.py
import pytest from pandas import Series import pandas._testing as tm class TestStrAccessor: def test_str_attribute(self): # GH#9068 methods = ["strip", "rstrip", "lstrip"] ser = Series([" jack", "jill ", " jesse ", "frank"]) for method in methods: expected = Series([ge...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/accessors/test_list_accessor.py
import re import pytest from pandas import ( ArrowDtype, Series, ) import pandas._testing as tm pa = pytest.importorskip("pyarrow") from pandas.compat import pa_version_under11p0 @pytest.mark.parametrize( "list_dtype", ( pa.list_(pa.int64()), pa.list_(pa.int64(), list_size=3), ...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/accessors/test_sparse_accessor.py
from pandas import Series class TestSparseAccessor: def test_sparse_accessor_updates_on_inplace(self): ser = Series([1, 1, 2, 3], dtype="Sparse[int]") return_value = ser.drop([0, 1], inplace=True) assert return_value is None assert ser.sparse.density == 1.0
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/accessors/test_cat_accessor.py
import numpy as np import pytest from pandas import ( Categorical, DataFrame, Index, Series, Timestamp, date_range, period_range, timedelta_range, ) import pandas._testing as tm from pandas.core.arrays.categorical import CategoricalAccessor from pandas.core.indexes.accessors import Prop...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_argsort.py
import numpy as np import pytest from pandas import ( Series, Timestamp, isna, ) import pandas._testing as tm class TestSeriesArgsort: def test_argsort_axis(self): # GH#54257 ser = Series(range(3)) msg = "No axis named 2 for object type Series" with pytest.raises(Valu...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_truncate.py
from datetime import datetime import pytest import pandas as pd from pandas import ( Series, date_range, ) import pandas._testing as tm class TestTruncate: def test_truncate_datetimeindex_tz(self): # GH 9243 idx = date_range("4/1/2005", "4/30/2005", freq="D", tz="US/Pacific") s =...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_is_monotonic.py
import numpy as np from pandas import ( Series, date_range, ) class TestIsMonotonic: def test_is_monotonic_numeric(self): ser = Series(np.random.default_rng(2).integers(0, 10, size=1000)) assert not ser.is_monotonic_increasing ser = Series(np.arange(1000)) assert ser.is_mo...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_between.py
import numpy as np import pytest from pandas import ( Series, bdate_range, date_range, period_range, ) import pandas._testing as tm class TestBetween: def test_between(self): series = Series(date_range("1/1/2000", periods=10)) left, right = series[[2, 7]] result = series....
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_explode.py
import numpy as np import pytest import pandas as pd import pandas._testing as tm def test_basic(): s = pd.Series([[0, 1, 2], np.nan, [], (3, 4)], index=list("abcd"), name="foo") result = s.explode() expected = pd.Series( [0, 1, 2, np.nan, np.nan, 3, 4], index=list("aaabcdd"), dtype=object, name=...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_to_numpy.py
import numpy as np import pytest from pandas import ( NA, Series, ) import pandas._testing as tm @pytest.mark.parametrize("dtype", ["int64", "float64"]) def test_to_numpy_na_value(dtype): # GH#48951 ser = Series([1, 2, NA, 4]) result = ser.to_numpy(dtype=dtype, na_value=0) expected = np.array...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_sort_values.py
import numpy as np import pytest from pandas import ( Categorical, DataFrame, Series, ) import pandas._testing as tm class TestSeriesSortValues: def test_sort_values(self, datetime_series, using_copy_on_write): # check indexes are reordered corresponding with the values ser = Series([...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_dropna.py
import numpy as np import pytest from pandas import ( DatetimeIndex, IntervalIndex, NaT, Period, Series, Timestamp, ) import pandas._testing as tm class TestDropna: def test_dropna_empty(self): ser = Series([], dtype=object) assert len(ser.dropna()) == 0 return_va...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_is_unique.py
import numpy as np import pytest from pandas import Series @pytest.mark.parametrize( "data, expected", [ (np.random.default_rng(2).integers(0, 10, size=1000), False), (np.arange(1000), True), ([], True), ([np.nan], True), (["foo", "bar", np.nan], True), (["foo"...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_astype.py
from datetime import ( datetime, timedelta, ) from importlib import reload import string import sys import numpy as np import pytest from pandas._libs.tslibs import iNaT import pandas.util._test_decorators as td from pandas import ( NA, Categorical, CategoricalDtype, DatetimeTZDtype, Inde...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_isin.py
import numpy as np import pytest import pandas as pd from pandas import ( Series, date_range, ) import pandas._testing as tm from pandas.core import algorithms from pandas.core.arrays import PeriodArray class TestSeriesIsIn: def test_isin(self): s = Series(["A", "B", "C", "a", "B", "B", "A", "C"]...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_describe.py
import numpy as np import pytest from pandas.compat.numpy import np_version_gte1p25 from pandas.core.dtypes.common import ( is_complex_dtype, is_extension_array_dtype, ) from pandas import ( NA, Period, Series, Timedelta, Timestamp, date_range, ) import pandas._testing as tm class T...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_tolist.py
import pytest import pandas.util._test_decorators as td from pandas import ( Interval, Period, Series, Timedelta, Timestamp, ) @pytest.mark.parametrize( "values, dtype, expected_dtype", ( ([1], "int64", int), ([1], "Int64", int), ([1.0], "float64", float), ...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_quantile.py
import numpy as np import pytest from pandas.core.dtypes.common import is_integer import pandas as pd from pandas import ( Index, Series, ) import pandas._testing as tm from pandas.core.indexes.datetimes import Timestamp class TestSeriesQuantile: def test_quantile(self, datetime_series): q = dat...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_get_numeric_data.py
from pandas import ( Index, Series, date_range, ) import pandas._testing as tm class TestGetNumericData: def test_get_numeric_data_preserve_dtype( self, using_copy_on_write, warn_copy_on_write ): # get the numeric data obj = Series([1, 2, 3]) result = obj._get_numer...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_head_tail.py
import pandas._testing as tm def test_head_tail(string_series): tm.assert_series_equal(string_series.head(), string_series[:5]) tm.assert_series_equal(string_series.head(0), string_series[0:0]) tm.assert_series_equal(string_series.tail(), string_series[-5:]) tm.assert_series_equal(string_series.tail(0...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_pct_change.py
import numpy as np import pytest from pandas import ( Series, date_range, ) import pandas._testing as tm class TestSeriesPctChange: def test_pct_change(self, datetime_series): msg = ( "The 'fill_method' keyword being not None and the 'limit' keyword in " "Series.pct_change...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_dtypes.py
import numpy as np class TestSeriesDtypes: def test_dtype(self, datetime_series): assert datetime_series.dtype == np.dtype("float64") assert datetime_series.dtypes == np.dtype("float64")
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_diff.py
import numpy as np import pytest from pandas import ( Series, TimedeltaIndex, date_range, ) import pandas._testing as tm class TestSeriesDiff: def test_diff_np(self): # TODO(__array_function__): could make np.diff return a Series # matching ser.diff() ser = Series(np.arange(...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_reindex_like.py
from datetime import datetime import numpy as np from pandas import Series import pandas._testing as tm def test_reindex_like(datetime_series): other = datetime_series[::2] tm.assert_series_equal( datetime_series.reindex(other.index), datetime_series.reindex_like(other) ) # GH#7179 day1...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_compare.py
import numpy as np import pytest import pandas as pd import pandas._testing as tm @pytest.mark.parametrize("align_axis", [0, 1, "index", "columns"]) def test_compare_axis(align_axis): # GH#30429 s1 = pd.Series(["a", "b", "c"]) s2 = pd.Series(["x", "b", "z"]) result = s1.compare(s2, align_axis=align_...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_set_name.py
from datetime import datetime from pandas import Series class TestSetName: def test_set_name(self): ser = Series([1, 2, 3]) ser2 = ser._set_name("foo") assert ser2.name == "foo" assert ser.name is None assert ser is not ser2 def test_set_name_attribute(self): ...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_reindex.py
import numpy as np import pytest import pandas.util._test_decorators as td from pandas import ( NA, Categorical, Float64Dtype, Index, MultiIndex, NaT, Period, PeriodIndex, RangeIndex, Series, Timedelta, Timestamp, date_range, isna, ) import pandas._testing as tm...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_equals.py
from contextlib import nullcontext import copy import numpy as np import pytest from pandas._libs.missing import is_matching_na from pandas.compat.numpy import np_version_gte1p25 from pandas.core.dtypes.common import is_float from pandas import ( Index, MultiIndex, Series, ) import pandas._testing as tm...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_drop.py
import pytest from pandas import ( Index, Series, ) import pandas._testing as tm from pandas.api.types import is_bool_dtype @pytest.mark.parametrize( "data, index, drop_labels, axis, expected_data, expected_index", [ # Unique Index ([1, 2], ["one", "two"], ["two"], 0, [1], ["one"]), ...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_item.py
""" Series.item method, mainly testing that we get python scalars as opposed to numpy scalars. """ import pytest from pandas import ( Series, Timedelta, Timestamp, date_range, ) class TestItem: def test_item(self): # We are testing that we get python scalars as opposed to numpy scalars ...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_view.py
import numpy as np import pytest from pandas import ( Index, Series, array, date_range, ) import pandas._testing as tm class TestView: def test_view_i8_to_datetimelike(self): dti = date_range("2000", periods=4, tz="US/Central") ser = Series(dti.asi8) result = ser.view(dti...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_rank.py
from itertools import chain import operator import numpy as np import pytest from pandas._libs.algos import ( Infinity, NegInfinity, ) import pandas.util._test_decorators as td from pandas import ( NA, NaT, Series, Timestamp, date_range, ) import pandas._testing as tm from pandas.api.type...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_nunique.py
import numpy as np from pandas import ( Categorical, Series, ) def test_nunique(): # basics.rst doc example series = Series(np.random.default_rng(2).standard_normal(500)) series[20:500] = np.nan series[10:20] = 5000 result = series.nunique() assert result == 11 def test_nunique_cate...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_rename.py
from datetime import datetime import re import numpy as np import pytest from pandas import ( Index, MultiIndex, Series, ) import pandas._testing as tm class TestRename: def test_rename(self, datetime_series): ts = datetime_series renamer = lambda x: x.strftime("%Y%m%d") rena...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_repeat.py
import numpy as np import pytest from pandas import ( MultiIndex, Series, ) import pandas._testing as tm class TestRepeat: def test_repeat(self): ser = Series(np.random.default_rng(2).standard_normal(3), index=["a", "b", "c"]) reps = ser.repeat(5) exp = Series(ser.values.repeat(5...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_info.py
from io import StringIO from string import ascii_uppercase import textwrap import numpy as np import pytest from pandas.compat import PYPY from pandas import ( CategoricalIndex, MultiIndex, Series, date_range, ) def test_info_categorical_column_just_works(): n = 2500 data = np.array(list("a...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_unique.py
import numpy as np from pandas import ( Categorical, IntervalIndex, Series, date_range, ) import pandas._testing as tm class TestUnique: def test_unique_uint64(self): ser = Series([1, 2, 2**63, 2**63], dtype=np.uint64) res = ser.unique() exp = np.array([1, 2, 2**63], dtype...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_sort_index.py
import numpy as np import pytest from pandas import ( DatetimeIndex, IntervalIndex, MultiIndex, Series, ) import pandas._testing as tm @pytest.fixture(params=["quicksort", "mergesort", "heapsort", "stable"]) def sort_kind(request): return request.param class TestSeriesSortIndex: def test_so...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_size.py
import pytest from pandas import Series @pytest.mark.parametrize( "data, index, expected", [ ([1, 2, 3], None, 3), ({"a": 1, "b": 2, "c": 3}, None, 3), ([1, 2, 3], ["x", "y", "z"], 3), ([1, 2, 3, 4, 5], ["x", "y", "z", "w", "n"], 5), ([1, 2, 3], None, 3), ([1, ...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_duplicated.py
import numpy as np import pytest from pandas import ( NA, Categorical, Series, ) import pandas._testing as tm @pytest.mark.parametrize( "keep, expected", [ ("first", Series([False, False, True, False, True], name="name")), ("last", Series([True, True, False, False, False], name="n...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_to_csv.py
from datetime import datetime from io import StringIO import numpy as np import pytest import pandas as pd from pandas import Series import pandas._testing as tm from pandas.io.common import get_handle class TestSeriesToCSV: def read_csv(self, path, **kwargs): params = {"index_col": 0, "header": None} ...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_value_counts.py
import numpy as np import pytest import pandas as pd from pandas import ( Categorical, CategoricalIndex, Index, Series, ) import pandas._testing as tm class TestSeriesValueCounts: def test_value_counts_datetime(self, unit): # most dtypes are tested in tests/base values = [ ...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_values.py
import numpy as np import pytest from pandas import ( IntervalIndex, Series, period_range, ) import pandas._testing as tm class TestValues: @pytest.mark.parametrize( "data", [ period_range("2000", periods=4), IntervalIndex.from_breaks([1, 2, 3, 4]), ], ...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_align.py
from datetime import timezone import numpy as np import pytest import pandas as pd from pandas import ( Series, date_range, period_range, ) import pandas._testing as tm @pytest.mark.parametrize( "first_slice,second_slice", [ [[2, None], [None, -5]], [[None, 0], [None, -5]], ...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_infer_objects.py
import numpy as np from pandas import ( Series, interval_range, ) import pandas._testing as tm class TestInferObjects: def test_copy(self, index_or_series): # GH#50096 # case where we don't need to do inference because it is already non-object obj = index_or_series(np.array([1, 2,...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_fillna.py
from datetime import ( datetime, timedelta, timezone, ) import numpy as np import pytest import pytz from pandas import ( Categorical, DataFrame, DatetimeIndex, NaT, Period, Series, Timedelta, Timestamp, date_range, isna, ) import pandas._testing as tm from pandas.c...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_searchsorted.py
import numpy as np import pytest import pandas as pd from pandas import ( Series, Timestamp, date_range, ) import pandas._testing as tm from pandas.api.types import is_scalar class TestSeriesSearchSorted: def test_searchsorted(self): ser = Series([1, 2, 3]) result = ser.searchsorted(...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_combine.py
from pandas import Series import pandas._testing as tm class TestCombine: def test_combine_scalar(self): # GH#21248 # Note - combine() with another Series is tested elsewhere because # it is used when testing operators ser = Series([i * 10 for i in range(5)]) result = ser.c...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_reset_index.py
from datetime import datetime import numpy as np import pytest import pandas as pd from pandas import ( DataFrame, Index, MultiIndex, RangeIndex, Series, date_range, ) import pandas._testing as tm class TestResetIndex: def test_reset_index_dti_round_trip(self): dti = date_range(s...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_interpolate.py
import numpy as np import pytest import pandas.util._test_decorators as td import pandas as pd from pandas import ( Index, MultiIndex, Series, date_range, isna, ) import pandas._testing as tm @pytest.fixture( params=[ "linear", "index", "values", "nearest", ...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_rename_axis.py
import pytest from pandas import ( Index, MultiIndex, Series, ) import pandas._testing as tm class TestSeriesRenameAxis: def test_rename_axis_mapper(self): # GH 19978 mi = MultiIndex.from_product([["a", "b", "c"], [1, 2]], names=["ll", "nn"]) ser = Series(list(range(len(mi))),...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_clip.py
from datetime import datetime import numpy as np import pytest import pandas as pd from pandas import ( Series, Timestamp, isna, notna, ) import pandas._testing as tm class TestSeriesClip: def test_clip(self, datetime_series): val = datetime_series.median() assert datetime_serie...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_asof.py
import numpy as np import pytest from pandas._libs.tslibs import IncompatibleFrequency from pandas import ( DatetimeIndex, PeriodIndex, Series, Timestamp, date_range, isna, notna, offsets, period_range, ) import pandas._testing as tm class TestSeriesAsof: def test_asof_nanose...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_map.py
from collections import ( Counter, defaultdict, ) from decimal import Decimal import math import numpy as np import pytest import pandas as pd from pandas import ( DataFrame, Index, MultiIndex, Series, isna, timedelta_range, ) import pandas._testing as tm def test_series_map_box_time...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_combine_first.py
from datetime import datetime import numpy as np import pandas as pd from pandas import ( Period, Series, date_range, period_range, to_datetime, ) import pandas._testing as tm class TestCombineFirst: def test_combine_first_period_datetime(self): # GH#3367 didx = date_range(st...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_isna.py
""" We also test Series.notna in this file. """ import numpy as np from pandas import ( Period, Series, ) import pandas._testing as tm class TestIsna: def test_isna_period_dtype(self): # GH#13737 ser = Series([Period("2011-01", freq="M"), Period("NaT", freq="M")]) expected = Seri...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_drop_duplicates.py
import numpy as np import pytest import pandas as pd from pandas import ( Categorical, Series, ) import pandas._testing as tm @pytest.mark.parametrize( "keep, expected", [ ("first", Series([False, False, False, False, True, True, False])), ("last", Series([False, True, True, False, Fa...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_replace.py
import re import numpy as np import pytest import pandas as pd import pandas._testing as tm from pandas.core.arrays import IntervalArray class TestSeriesReplace: def test_replace_explicit_none(self): # GH#36984 if the user explicitly passes value=None, give it to them ser = pd.Series([0, 0, ""],...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_unstack.py
import numpy as np import pytest import pandas as pd from pandas import ( DataFrame, MultiIndex, Series, ) import pandas._testing as tm def test_unstack_preserves_object(): mi = MultiIndex.from_product([["bar", "foo"], ["one", "two"]]) ser = Series(np.arange(4.0), index=mi, dtype=object) re...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_tz_localize.py
from datetime import timezone import pytest import pytz from pandas._libs.tslibs import timezones from pandas import ( DatetimeIndex, NaT, Series, Timestamp, date_range, ) import pandas._testing as tm class TestTZLocalize: def test_series_tz_localize_ambiguous_bool(self): # make sur...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_pop.py
from pandas import Series import pandas._testing as tm def test_pop(): # GH#6600 ser = Series([0, 4, 0], index=["A", "B", "C"], name=4) result = ser.pop("B") assert result == 4 expected = Series([0, 0], index=["A", "C"], name=4) tm.assert_series_equal(ser, expected)
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_cov_corr.py
import math import numpy as np import pytest import pandas as pd from pandas import ( Series, isna, ) import pandas._testing as tm class TestSeriesCov: def test_cov(self, datetime_series): # full overlap tm.assert_almost_equal( datetime_series.cov(datetime_series), datetime_s...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_count.py
import numpy as np import pandas as pd from pandas import ( Categorical, Series, ) import pandas._testing as tm class TestSeriesCount: def test_count(self, datetime_series): assert datetime_series.count() == len(datetime_series) datetime_series[::2] = np.nan assert datetime_seri...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_convert_dtypes.py
from itertools import product import numpy as np import pytest from pandas._libs import lib import pandas as pd import pandas._testing as tm # Each test case consists of a tuple with the data and dtype to create the # test Series, the default dtype for the expected result (which is valid # for most cases), and the ...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_matmul.py
import operator import numpy as np import pytest from pandas import ( DataFrame, Series, ) import pandas._testing as tm class TestMatmul: def test_matmul(self): # matmul test is for GH#10259 a = Series( np.random.default_rng(2).standard_normal(4), index=["p", "q", "r", "s"] ...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_to_frame.py
import pytest from pandas import ( DataFrame, Index, Series, ) import pandas._testing as tm class TestToFrame: def test_to_frame_respects_name_none(self): # GH#44212 if we explicitly pass name=None, then that should be respected, # not changed to 0 # GH-45448 this is first de...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_autocorr.py
import numpy as np class TestAutoCorr: def test_autocorr(self, datetime_series): # Just run the function corr1 = datetime_series.autocorr() # Now run it with the lag parameter corr2 = datetime_series.autocorr(lag=1) # corr() with lag needs Series of at least length 2 ...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_to_dict.py
import collections import numpy as np import pytest from pandas import Series import pandas._testing as tm class TestSeriesToDict: @pytest.mark.parametrize( "mapping", (dict, collections.defaultdict(list), collections.OrderedDict) ) def test_to_dict(self, mapping, datetime_series): # GH#...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_add_prefix_suffix.py
import pytest from pandas import Index import pandas._testing as tm def test_add_prefix_suffix(string_series): with_prefix = string_series.add_prefix("foo#") expected = Index([f"foo#{c}" for c in string_series.index]) tm.assert_index_equal(with_prefix.index, expected) with_suffix = string_series.add...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_update.py
import numpy as np import pytest import pandas.util._test_decorators as td from pandas import ( CategoricalDtype, DataFrame, NaT, Series, Timestamp, ) import pandas._testing as tm class TestUpdate: def test_update(self, using_copy_on_write): s = Series([1.5, np.nan, 3.0, 4.0, np.nan]...
0
public_repos/pandas/pandas/tests/series
public_repos/pandas/pandas/tests/series/methods/test_copy.py
import numpy as np import pytest from pandas import ( Series, Timestamp, ) import pandas._testing as tm class TestCopy: @pytest.mark.parametrize("deep", ["default", None, False, True]) def test_copy(self, deep, using_copy_on_write, warn_copy_on_write): ser = Series(np.arange(10), dtype="float...
0