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/frame | public_repos/pandas/pandas/tests/frame/methods/test_matmul.py | import operator
import numpy as np
import pytest
from pandas import (
DataFrame,
Index,
Series,
)
import pandas._testing as tm
class TestMatMul:
def test_matmul(self):
# matmul test is for GH#10259
a = DataFrame(
np.random.default_rng(2).standard_normal((3, 4)),
... | 0 |
public_repos/pandas/pandas/tests/frame | public_repos/pandas/pandas/tests/frame/methods/test_first_valid_index.py | """
Includes test for last_valid_index.
"""
import numpy as np
import pytest
from pandas import (
DataFrame,
Series,
)
import pandas._testing as tm
class TestFirstValidIndex:
def test_first_valid_index_single_nan(self, frame_or_series):
# GH#9752 Series/DataFrame should both return None, not rais... | 0 |
public_repos/pandas/pandas/tests/frame | public_repos/pandas/pandas/tests/frame/methods/test_iterrows.py | from pandas import (
DataFrame,
Timedelta,
)
def test_no_overflow_of_freq_and_time_in_dataframe():
# GH 35665
df = DataFrame(
{
"some_string": ["2222Y3"],
"time": [Timedelta("0 days 00:00:00.990000")],
}
)
for _, row in df.iterrows():
assert row.... | 0 |
public_repos/pandas/pandas/tests/frame | public_repos/pandas/pandas/tests/frame/methods/test_first_and_last.py | """
Note: includes tests for `last`
"""
import pytest
import pandas as pd
from pandas import (
DataFrame,
bdate_range,
)
import pandas._testing as tm
deprecated_msg = "first is deprecated"
last_deprecated_msg = "last is deprecated"
class TestFirst:
def test_first_subset(self, frame_or_series):
t... | 0 |
public_repos/pandas/pandas/tests/frame | public_repos/pandas/pandas/tests/frame/methods/test_sample.py | import numpy as np
import pytest
from pandas import (
DataFrame,
Index,
Series,
)
import pandas._testing as tm
import pandas.core.common as com
class TestSample:
@pytest.fixture
def obj(self, frame_or_series):
if frame_or_series is Series:
arr = np.random.default_rng(2).standa... | 0 |
public_repos/pandas/pandas/tests/frame | public_repos/pandas/pandas/tests/frame/methods/test_to_dict.py | from collections import (
OrderedDict,
defaultdict,
)
from datetime import datetime
import numpy as np
import pytest
import pytz
from pandas import (
NA,
DataFrame,
Index,
MultiIndex,
Series,
Timestamp,
)
import pandas._testing as tm
class TestDataFrameToDict:
def test_to_dict_ti... | 0 |
public_repos/pandas/pandas/tests/frame | public_repos/pandas/pandas/tests/frame/methods/test_add_prefix_suffix.py | import pytest
from pandas import Index
import pandas._testing as tm
def test_add_prefix_suffix(float_frame):
with_prefix = float_frame.add_prefix("foo#")
expected = Index([f"foo#{c}" for c in float_frame.columns])
tm.assert_index_equal(with_prefix.columns, expected)
with_suffix = float_frame.add_suf... | 0 |
public_repos/pandas/pandas/tests/frame | public_repos/pandas/pandas/tests/frame/methods/test_at_time.py | from datetime import time
import numpy as np
import pytest
import pytz
from pandas._libs.tslibs import timezones
from pandas import (
DataFrame,
date_range,
)
import pandas._testing as tm
class TestAtTime:
@pytest.mark.parametrize("tzstr", ["US/Eastern", "dateutil/US/Eastern"])
def test_localized_a... | 0 |
public_repos/pandas/pandas/tests/frame | public_repos/pandas/pandas/tests/frame/methods/test_update.py | import numpy as np
import pytest
import pandas.util._test_decorators as td
import pandas as pd
from pandas import (
DataFrame,
Series,
date_range,
)
import pandas._testing as tm
class TestDataFrameUpdate:
def test_update_nan(self):
# #15593 #15617
# test 1
df1 = DataFrame({"A... | 0 |
public_repos/pandas/pandas/tests/frame | public_repos/pandas/pandas/tests/frame/methods/test_join.py | from datetime import datetime
import numpy as np
import pytest
from pandas.errors import MergeError
import pandas as pd
from pandas import (
DataFrame,
Index,
MultiIndex,
date_range,
period_range,
)
import pandas._testing as tm
from pandas.core.reshape.concat import concat
@pytest.fixture
def f... | 0 |
public_repos/pandas/pandas/tests/frame | public_repos/pandas/pandas/tests/frame/methods/test_copy.py | import numpy as np
import pytest
import pandas.util._test_decorators as td
from pandas import DataFrame
import pandas._testing as tm
class TestCopy:
@pytest.mark.parametrize("attr", ["index", "columns"])
def test_copy_index_name_checking(self, float_frame, attr):
# don't want to be able to modify th... | 0 |
public_repos/pandas/pandas/tests/frame | public_repos/pandas/pandas/tests/frame/methods/test_swapaxes.py | import numpy as np
import pytest
from pandas import DataFrame
import pandas._testing as tm
class TestSwapAxes:
def test_swapaxes(self):
df = DataFrame(np.random.default_rng(2).standard_normal((10, 5)))
msg = "'DataFrame.swapaxes' is deprecated"
with tm.assert_produces_warning(FutureWarnin... | 0 |
public_repos/pandas/pandas/tests/frame | public_repos/pandas/pandas/tests/frame/methods/test_tz_convert.py | import numpy as np
import pytest
from pandas import (
DataFrame,
Index,
MultiIndex,
Series,
date_range,
)
import pandas._testing as tm
class TestTZConvert:
def test_tz_convert(self, frame_or_series):
rng = date_range("1/1/2011", periods=200, freq="D", tz="US/Eastern")
obj = D... | 0 |
public_repos/pandas/pandas/tests/frame | public_repos/pandas/pandas/tests/frame/methods/__init__.py | """
Test files dedicated to individual (stand-alone) DataFrame methods
Ideally these files/tests should correspond 1-to-1 with tests.series.methods
These may also present opportunities for sharing/de-duplicating test code.
"""
| 0 |
public_repos/pandas/pandas/tests/frame | public_repos/pandas/pandas/tests/frame/methods/test_round.py | import numpy as np
import pytest
import pandas as pd
from pandas import (
DataFrame,
Series,
date_range,
)
import pandas._testing as tm
class TestDataFrameRound:
def test_round(self):
# GH#2665
# Test that rounding an empty DataFrame does nothing
df = DataFrame()
tm.a... | 0 |
public_repos/pandas/pandas/tests/frame | public_repos/pandas/pandas/tests/frame/methods/test_to_timestamp.py | from datetime import timedelta
import numpy as np
import pytest
from pandas import (
DataFrame,
DatetimeIndex,
PeriodIndex,
Series,
Timedelta,
date_range,
period_range,
to_datetime,
)
import pandas._testing as tm
def _get_with_delta(delta, freq="YE-DEC"):
return date_range(
... | 0 |
public_repos/pandas/pandas/tests/frame | public_repos/pandas/pandas/tests/frame/methods/test_nlargest.py | """
Note: for naming purposes, most tests are title with as e.g. "test_nlargest_foo"
but are implicitly also testing nsmallest_foo.
"""
from string import ascii_lowercase
import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
from pandas.util.version import Version
@pytest.fixture
def df_... | 0 |
public_repos/pandas/pandas/tests/frame | public_repos/pandas/pandas/tests/frame/methods/test_set_index.py | """
See also: test_reindex.py:TestReindexSetIndex
"""
from datetime import (
datetime,
timedelta,
)
import numpy as np
import pytest
from pandas import (
Categorical,
DataFrame,
DatetimeIndex,
Index,
MultiIndex,
Series,
date_range,
period_range,
to_datetime,
)
import panda... | 0 |
public_repos/pandas/pandas/tests/frame | public_repos/pandas/pandas/tests/frame/indexing/test_set_value.py | import numpy as np
from pandas.core.dtypes.common import is_float_dtype
from pandas import (
DataFrame,
isna,
)
import pandas._testing as tm
class TestSetValue:
def test_set_value(self, float_frame):
for idx in float_frame.index:
for col in float_frame.columns:
float_... | 0 |
public_repos/pandas/pandas/tests/frame | public_repos/pandas/pandas/tests/frame/indexing/test_setitem.py | from datetime import datetime
import numpy as np
import pytest
import pandas.util._test_decorators as td
from pandas.core.dtypes.base import _registry as ea_registry
from pandas.core.dtypes.common import is_object_dtype
from pandas.core.dtypes.dtypes import (
CategoricalDtype,
DatetimeTZDtype,
IntervalDt... | 0 |
public_repos/pandas/pandas/tests/frame | public_repos/pandas/pandas/tests/frame/indexing/test_get_value.py | import pytest
from pandas import (
DataFrame,
MultiIndex,
)
class TestGetValue:
def test_get_set_value_no_partial_indexing(self):
# partial w/ MultiIndex raise exception
index = MultiIndex.from_tuples([(0, 1), (0, 2), (1, 1), (1, 2)])
df = DataFrame(index=index, columns=range(4))
... | 0 |
public_repos/pandas/pandas/tests/frame | public_repos/pandas/pandas/tests/frame/indexing/test_getitem.py | import re
import numpy as np
import pytest
from pandas import (
Categorical,
CategoricalDtype,
CategoricalIndex,
DataFrame,
DateOffset,
DatetimeIndex,
Index,
MultiIndex,
Series,
Timestamp,
concat,
date_range,
get_dummies,
period_range,
)
import pandas._testing a... | 0 |
public_repos/pandas/pandas/tests/frame | public_repos/pandas/pandas/tests/frame/indexing/test_take.py | import pytest
import pandas._testing as tm
class TestDataFrameTake:
def test_take_slices_deprecated(self, float_frame):
# GH#51539
df = float_frame
slc = slice(0, 4, 1)
with tm.assert_produces_warning(FutureWarning):
df.take(slc, axis=0)
with tm.assert_produce... | 0 |
public_repos/pandas/pandas/tests/frame | public_repos/pandas/pandas/tests/frame/indexing/test_coercion.py | """
Tests for values coercion in setitem-like operations on DataFrame.
For the most part, these should be multi-column DataFrames, otherwise
we would share the tests with Series.
"""
import numpy as np
import pytest
import pandas as pd
from pandas import (
DataFrame,
MultiIndex,
NaT,
Series,
Times... | 0 |
public_repos/pandas/pandas/tests/frame | public_repos/pandas/pandas/tests/frame/indexing/test_delitem.py | import re
import numpy as np
import pytest
from pandas import (
DataFrame,
MultiIndex,
)
class TestDataFrameDelItem:
def test_delitem(self, float_frame):
del float_frame["A"]
assert "A" not in float_frame
def test_delitem_multiindex(self):
midx = MultiIndex.from_product([["A... | 0 |
public_repos/pandas/pandas/tests/frame | public_repos/pandas/pandas/tests/frame/indexing/test_get.py | import pytest
from pandas import DataFrame
import pandas._testing as tm
class TestGet:
def test_get(self, float_frame):
b = float_frame.get("B")
tm.assert_series_equal(b, float_frame["B"])
assert float_frame.get("foo") is None
tm.assert_series_equal(
float_frame.get("... | 0 |
public_repos/pandas/pandas/tests/frame | public_repos/pandas/pandas/tests/frame/indexing/test_insert.py | """
test_insert is specifically for the DataFrame.insert method; not to be
confused with tests with "insert" in their names that are really testing
__setitem__.
"""
import numpy as np
import pytest
from pandas.errors import PerformanceWarning
from pandas import (
DataFrame,
Index,
)
import pandas._testing as ... | 0 |
public_repos/pandas/pandas/tests/frame | public_repos/pandas/pandas/tests/frame/indexing/test_indexing.py | from collections import namedtuple
from datetime import (
datetime,
timedelta,
)
from decimal import Decimal
import re
import numpy as np
import pytest
from pandas._libs import iNaT
from pandas.errors import (
InvalidIndexError,
PerformanceWarning,
SettingWithCopyError,
)
import pandas.util._test_... | 0 |
public_repos/pandas/pandas/tests/frame | public_repos/pandas/pandas/tests/frame/indexing/test_xs.py | import re
import numpy as np
import pytest
from pandas.errors import SettingWithCopyError
from pandas import (
DataFrame,
Index,
IndexSlice,
MultiIndex,
Series,
concat,
)
import pandas._testing as tm
from pandas.tseries.offsets import BDay
@pytest.fixture
def four_level_index_dataframe():
... | 0 |
public_repos/pandas/pandas/tests/frame | public_repos/pandas/pandas/tests/frame/indexing/test_mask.py | """
Tests for DataFrame.mask; tests DataFrame.where as a side-effect.
"""
import numpy as np
from pandas import (
NA,
DataFrame,
Float64Dtype,
Series,
StringDtype,
Timedelta,
isna,
)
import pandas._testing as tm
class TestDataFrameMask:
def test_mask(self):
df = DataFrame(np.... | 0 |
public_repos/pandas/pandas/tests/frame | public_repos/pandas/pandas/tests/frame/indexing/test_where.py | from datetime import datetime
from hypothesis import given
import numpy as np
import pytest
from pandas.core.dtypes.common import is_scalar
import pandas as pd
from pandas import (
DataFrame,
DatetimeIndex,
Index,
Series,
StringDtype,
Timestamp,
date_range,
isna,
)
import pandas._test... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/apply/test_series_apply.py | import numpy as np
import pytest
import pandas as pd
from pandas import (
DataFrame,
Index,
MultiIndex,
Series,
concat,
timedelta_range,
)
import pandas._testing as tm
from pandas.tests.apply.common import series_transform_kernels
@pytest.fixture(params=[False, "compat"])
def by_row(request):... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/apply/test_series_transform.py | import numpy as np
import pytest
from pandas import (
DataFrame,
MultiIndex,
Series,
concat,
)
import pandas._testing as tm
@pytest.mark.parametrize(
"args, kwargs, increment",
[((), {}, 0), ((), {"a": 1}, 1), ((2, 3), {}, 32), ((1,), {"c": 2}, 201)],
)
def test_agg_args(args, kwargs, increme... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/apply/test_frame_apply.py | from datetime import datetime
import warnings
import numpy as np
import pytest
from pandas.core.dtypes.dtypes import CategoricalDtype
import pandas as pd
from pandas import (
DataFrame,
MultiIndex,
Series,
Timestamp,
date_range,
)
import pandas._testing as tm
from pandas.tests.frame.common import... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/apply/test_invalid_arg.py | # Tests specifically aimed at detecting bad arguments.
# This file is organized by reason for exception.
# 1. always invalid argument values
# 2. missing column(s)
# 3. incompatible ops/dtype/args/kwargs
# 4. invalid result shape/type
# If your test does not fit into one of these categories, add to this... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/apply/common.py | from pandas.core.groupby.base import transformation_kernels
# There is no Series.cumcount or DataFrame.cumcount
series_transform_kernels = [
x for x in sorted(transformation_kernels) if x != "cumcount"
]
frame_transform_kernels = [x for x in sorted(transformation_kernels) if x != "cumcount"]
| 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/apply/test_str.py | from itertools import chain
import operator
import numpy as np
import pytest
from pandas.core.dtypes.common import is_number
from pandas import (
DataFrame,
Series,
)
import pandas._testing as tm
from pandas.tests.apply.common import (
frame_transform_kernels,
series_transform_kernels,
)
@pytest.ma... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/apply/conftest.py | import numpy as np
import pytest
from pandas import DataFrame
@pytest.fixture
def int_frame_const_col():
"""
Fixture for DataFrame of ints which are constant per column
Columns are ['A', 'B', 'C'], with values (per column): [1, 2, 3]
"""
df = DataFrame(
np.tile(np.arange(3, dtype="int64"... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/apply/test_frame_transform.py | import numpy as np
import pytest
from pandas import (
DataFrame,
MultiIndex,
Series,
)
import pandas._testing as tm
from pandas.tests.apply.common import frame_transform_kernels
from pandas.tests.frame.common import zip_frames
def unpack_obj(obj, klass, axis):
"""
Helper to ensure we have the rig... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/apply/test_series_apply_relabeling.py | import pandas as pd
import pandas._testing as tm
def test_relabel_no_duplicated_method():
# this is to test there is no duplicated method used in agg
df = pd.DataFrame({"A": [1, 2, 1, 2], "B": [1, 2, 3, 4]})
result = df["A"].agg(foo="sum")
expected = df["A"].agg({"foo": "sum"})
tm.assert_series_e... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/apply/test_frame_apply_relabeling.py | import numpy as np
import pytest
from pandas.compat.numpy import np_version_gte1p25
import pandas as pd
import pandas._testing as tm
def test_agg_relabel():
# GH 26513
df = pd.DataFrame({"A": [1, 2, 1, 2], "B": [1, 2, 3, 4], "C": [3, 4, 5, 6]})
# simplest case with one column, one func
result = df.... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/apply/test_numba.py | import numpy as np
import pytest
import pandas.util._test_decorators as td
from pandas import (
DataFrame,
Index,
)
import pandas._testing as tm
pytestmark = [td.skip_if_no("numba"), pytest.mark.single_cpu]
def test_numba_vs_python_noop(float_frame, apply_axis):
func = lambda x: x
result = float_fr... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/libs/test_lib.py | import numpy as np
import pytest
from pandas._libs import (
Timedelta,
lib,
writers as libwriters,
)
from pandas.compat import IS64
from pandas import Index
import pandas._testing as tm
class TestMisc:
def test_max_len_string_array(self):
arr = a = np.array(["foo", "b", np.nan], dtype="objec... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/libs/test_libalgos.py | from datetime import datetime
from itertools import permutations
import numpy as np
from pandas._libs import algos as libalgos
import pandas._testing as tm
def test_ensure_platform_int():
arr = np.arange(100, dtype=np.intp)
result = libalgos.ensure_platform_int(arr)
assert result is arr
def test_is_... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/libs/test_hashtable.py | from collections.abc import Generator
from contextlib import contextmanager
import re
import struct
import tracemalloc
import numpy as np
import pytest
from pandas._libs import hashtable as ht
import pandas as pd
import pandas._testing as tm
from pandas.core.algorithms import isin
@contextmanager
def activated_tra... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/libs/test_join.py | import numpy as np
import pytest
from pandas._libs import join as libjoin
from pandas._libs.join import (
inner_join,
left_outer_join,
)
import pandas._testing as tm
class TestIndexer:
@pytest.mark.parametrize(
"dtype", ["int32", "int64", "float32", "float64", "object"]
)
def test_outer_... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/strings/test_extract.py | from datetime import datetime
import re
import numpy as np
import pytest
from pandas.core.dtypes.dtypes import ArrowDtype
from pandas import (
DataFrame,
Index,
MultiIndex,
Series,
_testing as tm,
)
def test_extract_expand_kwarg_wrong_type_raises(any_string_dtype):
# TODO: should this raise... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/strings/test_string_array.py | import numpy as np
import pytest
from pandas._libs import lib
from pandas import (
NA,
DataFrame,
Series,
_testing as tm,
)
@pytest.mark.filterwarnings("ignore:Falling back")
def test_string_array(nullable_string_dtype, any_string_method):
method_name, args, kwargs = any_string_method
data ... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/strings/test_cat.py | import re
import numpy as np
import pytest
from pandas import (
DataFrame,
Index,
MultiIndex,
Series,
_testing as tm,
concat,
)
@pytest.mark.parametrize("other", [None, Series, Index])
def test_str_cat_name(index_or_series, other):
# GH 21053
box = index_or_series
values = ["a", ... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/strings/test_split_partition.py | from datetime import datetime
import re
import numpy as np
import pytest
import pandas as pd
from pandas import (
DataFrame,
Index,
MultiIndex,
Series,
_testing as tm,
)
from pandas.tests.strings import (
_convert_na_value,
object_pyarrow_numpy,
)
@pytest.mark.parametrize("method", ["spl... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/strings/test_get_dummies.py | import numpy as np
from pandas import (
DataFrame,
Index,
MultiIndex,
Series,
_testing as tm,
)
def test_get_dummies(any_string_dtype):
s = Series(["a|b", "a|c", np.nan], dtype=any_string_dtype)
result = s.str.get_dummies("|")
expected = DataFrame([[1, 1, 0], [1, 0, 1], [0, 0, 0]], co... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/strings/conftest.py | import numpy as np
import pytest
from pandas import Series
from pandas.core.strings.accessor import StringMethods
_any_string_method = [
("cat", (), {"sep": ","}),
("cat", (Series(list("zyx")),), {"sep": ",", "join": "left"}),
("center", (10,), {}),
("contains", ("a",), {}),
("count", ("a",), {}),... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/strings/test_case_justify.py | from datetime import datetime
import operator
import numpy as np
import pytest
from pandas import (
Series,
_testing as tm,
)
def test_title(any_string_dtype):
s = Series(["FOO", "BAR", np.nan, "Blah", "blurg"], dtype=any_string_dtype)
result = s.str.title()
expected = Series(["Foo", "Bar", np.n... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/strings/test_find_replace.py | from datetime import datetime
import re
import numpy as np
import pytest
from pandas.errors import PerformanceWarning
import pandas as pd
from pandas import (
Series,
_testing as tm,
)
from pandas.tests.strings import (
_convert_na_value,
object_pyarrow_numpy,
)
# -----------------------------------... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/strings/test_strings.py | from datetime import (
datetime,
timedelta,
)
import numpy as np
import pytest
from pandas import (
DataFrame,
Index,
MultiIndex,
Series,
)
import pandas._testing as tm
from pandas.core.strings.accessor import StringMethods
from pandas.tests.strings import object_pyarrow_numpy
@pytest.mark.p... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/strings/test_api.py | import pytest
from pandas import (
DataFrame,
Index,
MultiIndex,
Series,
_testing as tm,
)
from pandas.core.strings.accessor import StringMethods
def test_api(any_string_dtype):
# GH 6106, GH 9322
assert Series.str is StringMethods
assert isinstance(Series([""], dtype=any_string_dtype... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/strings/__init__.py | import numpy as np
import pandas as pd
object_pyarrow_numpy = ("object", "string[pyarrow_numpy]")
def _convert_na_value(ser, expected):
if ser.dtype != object:
if ser.dtype.storage == "pyarrow_numpy":
expected = expected.fillna(np.nan)
else:
# GH#18463
expecte... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/construction/test_extract_array.py | from pandas import Index
import pandas._testing as tm
from pandas.core.construction import extract_array
def test_extract_array_rangeindex():
ri = Index(range(5))
expected = ri._values
res = extract_array(ri, extract_numpy=True, extract_range=True)
tm.assert_numpy_array_equal(res, expected)
res =... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/internals/test_internals.py | from datetime import (
date,
datetime,
)
import itertools
import re
import numpy as np
import pytest
from pandas._libs.internals import BlockPlacement
from pandas.compat import IS64
import pandas.util._test_decorators as td
from pandas.core.dtypes.common import is_scalar
import pandas as pd
from pandas impo... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/internals/test_api.py | """
Tests for the pseudo-public API implemented in internals/api.py and exposed
in core.internals
"""
import pandas as pd
import pandas._testing as tm
from pandas.core import internals
from pandas.core.internals import api
def test_internals_api():
assert internals.make_block is api.make_block
def test_namespa... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/internals/test_managers.py | """
Testing interaction between the different managers (BlockManager, ArrayManager)
"""
import os
import subprocess
import sys
import pytest
from pandas.core.dtypes.missing import array_equivalent
import pandas as pd
import pandas._testing as tm
from pandas.core.internals import (
ArrayManager,
BlockManager,... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/generic/test_generic.py | from copy import (
copy,
deepcopy,
)
import numpy as np
import pytest
from pandas.core.dtypes.common import is_scalar
from pandas import (
DataFrame,
Series,
)
import pandas._testing as tm
# ----------------------------------------------------------------------
# Generic types test cases
def const... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/generic/test_label_or_level_utils.py | import pytest
from pandas.core.dtypes.missing import array_equivalent
import pandas as pd
# Fixtures
# ========
@pytest.fixture
def df():
"""DataFrame with columns 'L1', 'L2', and 'L3'"""
return pd.DataFrame({"L1": [1, 2, 3], "L2": [11, 12, 13], "L3": ["A", "B", "C"]})
@pytest.fixture(params=[[], ["L1"], ... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/generic/test_finalize.py | """
An exhaustive list of pandas methods exercising NDFrame.__finalize__.
"""
import operator
import re
import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
# TODO:
# * Binary methods (mul, div, etc.)
# * Binary outputs (align, etc.)
# * top-level methods (concat, merge, get_dummies, etc... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/generic/test_to_xarray.py | import numpy as np
import pytest
from pandas import (
Categorical,
DataFrame,
MultiIndex,
Series,
date_range,
)
import pandas._testing as tm
pytest.importorskip("xarray")
class TestDataFrameToXArray:
@pytest.fixture
def df(self):
return DataFrame(
{
"a... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/generic/test_series.py | from operator import methodcaller
import numpy as np
import pytest
import pandas as pd
from pandas import (
MultiIndex,
Series,
date_range,
)
import pandas._testing as tm
class TestSeries:
@pytest.mark.parametrize("func", ["rename_axis", "_set_axis_name"])
def test_set_axis_name_mi(self, func):
... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/generic/test_frame.py | from copy import deepcopy
from operator import methodcaller
import numpy as np
import pytest
import pandas as pd
from pandas import (
DataFrame,
MultiIndex,
Series,
date_range,
)
import pandas._testing as tm
class TestDataFrame:
@pytest.mark.parametrize("func", ["_set_axis_name", "rename_axis"])... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/generic/test_duplicate_labels.py | """Tests dealing with the NDFrame.allows_duplicates."""
import operator
import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
not_implemented = pytest.mark.xfail(reason="Not implemented.")
# ----------------------------------------------------------------------------
# Preservation
cla... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/indexes/test_subclass.py | """
Tests involving custom Index subclasses
"""
import numpy as np
from pandas import (
DataFrame,
Index,
)
import pandas._testing as tm
class CustomIndex(Index):
def __new__(cls, data, name=None):
# assert that this index class cannot hold strings
if any(isinstance(val, str) for val in d... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/indexes/conftest.py | import numpy as np
import pytest
from pandas import (
Series,
array,
)
import pandas._testing as tm
@pytest.fixture(params=[None, False])
def sort(request):
"""
Valid values for the 'sort' parameter used in the Index
setops methods (intersection, union, etc.)
Caution:
Don't confuse t... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/indexes/test_datetimelike.py | """ generic datetimelike tests """
import numpy as np
import pytest
import pandas as pd
import pandas._testing as tm
class TestDatetimeLike:
@pytest.fixture(
params=[
pd.period_range("20130101", periods=5, freq="D"),
pd.TimedeltaIndex(
[
"0 day... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/indexes/test_base.py | from collections import defaultdict
from datetime import datetime
import math
import operator
import re
import numpy as np
import pytest
from pandas.compat import IS64
from pandas.errors import InvalidIndexError
import pandas.util._test_decorators as td
from pandas.core.dtypes.common import (
is_any_real_numeric... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/indexes/test_common.py | """
Collection of tests asserting things that should be true for
any index subclass except for MultiIndex. Makes use of the `index_flat`
fixture defined in pandas/conftest.py.
"""
from copy import (
copy,
deepcopy,
)
import re
import numpy as np
import pytest
from pandas.compat import IS64
from pandas.compat.... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/indexes/test_frozen.py | import re
import pytest
from pandas.core.indexes.frozen import FrozenList
@pytest.fixture
def lst():
return [1, 2, 3, 4, 5]
@pytest.fixture
def container(lst):
return FrozenList(lst)
@pytest.fixture
def unicode_container():
return FrozenList(["\u05d0", "\u05d1", "c"])
class TestFrozenList:
def... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/indexes/test_old_base.py | from __future__ import annotations
from datetime import datetime
import weakref
import numpy as np
import pytest
from pandas._libs.tslibs import Timestamp
from pandas.core.dtypes.common import (
is_integer_dtype,
is_numeric_dtype,
)
from pandas.core.dtypes.dtypes import CategoricalDtype
import pandas as pd... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/indexes/test_indexing.py | """
test_indexing tests the following Index methods:
__getitem__
get_loc
get_value
__contains__
take
where
get_indexer
get_indexer_for
slice_locs
asof_locs
The corresponding tests.indexes.[index_type].test_indexing files
contain tests for the corresponding methods specific to th... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/indexes/test_setops.py | """
The tests in this package are to ensure the proper resultant dtypes of
set operations.
"""
from datetime import datetime
import operator
import numpy as np
import pytest
from pandas._libs import lib
from pandas.core.dtypes.cast import find_common_type
from pandas import (
CategoricalDtype,
CategoricalIn... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/indexes/test_index_new.py | """
Tests for the Index constructor conducting inference.
"""
from datetime import (
datetime,
timedelta,
timezone,
)
from decimal import Decimal
import numpy as np
import pytest
from pandas._libs.tslibs.timezones import maybe_get_tz
from pandas import (
NA,
Categorical,
CategoricalIndex,
... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/indexes/test_engines.py | import re
import numpy as np
import pytest
from pandas._libs import index as libindex
import pandas as pd
@pytest.fixture(
params=[
(libindex.Int64Engine, np.int64),
(libindex.Int32Engine, np.int32),
(libindex.Int16Engine, np.int16),
(libindex.Int8Engine, np.int8),
(libi... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/indexes/test_any_index.py | """
Tests that can be parametrized over _any_ Index object.
"""
import re
import numpy as np
import pytest
from pandas.errors import InvalidIndexError
import pandas._testing as tm
def test_boolean_context_compat(index):
# GH#7897
with pytest.raises(ValueError, match="The truth value of a"):
if inde... | 0 |
public_repos/pandas/pandas/tests | public_repos/pandas/pandas/tests/indexes/test_numpy_compat.py | import numpy as np
import pytest
from pandas import (
CategoricalIndex,
DatetimeIndex,
Index,
PeriodIndex,
TimedeltaIndex,
isna,
)
import pandas._testing as tm
from pandas.api.types import (
is_complex_dtype,
is_numeric_dtype,
)
from pandas.core.arrays import BooleanArray
from pandas.co... | 0 |
public_repos/pandas/pandas/tests/indexes | public_repos/pandas/pandas/tests/indexes/period/test_freq_attr.py | import pytest
from pandas.compat import PY311
from pandas import (
offsets,
period_range,
)
import pandas._testing as tm
class TestFreq:
def test_freq_setter_deprecated(self):
# GH#20678
idx = period_range("2018Q1", periods=4, freq="Q")
# no warning for getter
with tm.as... | 0 |
public_repos/pandas/pandas/tests/indexes | public_repos/pandas/pandas/tests/indexes/period/test_formats.py | from contextlib import nullcontext
from datetime import (
datetime,
time,
)
import locale
import numpy as np
import pytest
import pandas as pd
from pandas import (
PeriodIndex,
Series,
)
import pandas._testing as tm
def get_local_am_pm():
"""Return the AM and PM strings returned by strftime in c... | 0 |
public_repos/pandas/pandas/tests/indexes | public_repos/pandas/pandas/tests/indexes/period/test_monotonic.py | from pandas import (
Period,
PeriodIndex,
)
def test_is_monotonic_increasing():
# GH#17717
p0 = Period("2017-09-01")
p1 = Period("2017-09-02")
p2 = Period("2017-09-03")
idx_inc0 = PeriodIndex([p0, p1, p2])
idx_inc1 = PeriodIndex([p0, p1, p1])
idx_dec0 = PeriodIndex([p2, p1, p0])
... | 0 |
public_repos/pandas/pandas/tests/indexes | public_repos/pandas/pandas/tests/indexes/period/test_period.py | import numpy as np
import pytest
from pandas._libs.tslibs.period import IncompatibleFrequency
from pandas import (
Index,
NaT,
Period,
PeriodIndex,
Series,
date_range,
offsets,
period_range,
)
import pandas._testing as tm
class TestPeriodIndex:
def test_make_time_series(self):
... | 0 |
public_repos/pandas/pandas/tests/indexes | public_repos/pandas/pandas/tests/indexes/period/test_resolution.py | import pytest
import pandas as pd
class TestResolution:
@pytest.mark.parametrize(
"freq,expected",
[
("Y", "year"),
("Q", "quarter"),
("M", "month"),
("D", "day"),
("h", "hour"),
("min", "minute"),
("s", "second")... | 0 |
public_repos/pandas/pandas/tests/indexes | public_repos/pandas/pandas/tests/indexes/period/test_pickle.py | import numpy as np
import pytest
from pandas import (
NaT,
PeriodIndex,
period_range,
)
import pandas._testing as tm
from pandas.tseries import offsets
class TestPickle:
@pytest.mark.parametrize("freq", ["D", "M", "Y"])
def test_pickle_round_trip(self, freq):
idx = PeriodIndex(["2016-05-... | 0 |
public_repos/pandas/pandas/tests/indexes | public_repos/pandas/pandas/tests/indexes/period/test_indexing.py | from datetime import datetime
import re
import numpy as np
import pytest
from pandas._libs.tslibs import period as libperiod
from pandas.errors import InvalidIndexError
import pandas as pd
from pandas import (
DatetimeIndex,
NaT,
Period,
PeriodIndex,
Series,
Timedelta,
date_range,
not... | 0 |
public_repos/pandas/pandas/tests/indexes | public_repos/pandas/pandas/tests/indexes/period/test_setops.py | import numpy as np
import pytest
import pandas as pd
from pandas import (
PeriodIndex,
date_range,
period_range,
)
import pandas._testing as tm
def _permute(obj):
return obj.take(np.random.default_rng(2).permutation(len(obj)))
class TestPeriodIndex:
def test_union(self, sort):
# union
... | 0 |
public_repos/pandas/pandas/tests/indexes | public_repos/pandas/pandas/tests/indexes/period/test_searchsorted.py | import numpy as np
import pytest
from pandas._libs.tslibs import IncompatibleFrequency
from pandas import (
NaT,
Period,
PeriodIndex,
)
import pandas._testing as tm
class TestSearchsorted:
@pytest.mark.parametrize("freq", ["D", "2D"])
def test_searchsorted(self, freq):
pidx = PeriodIndex... | 0 |
public_repos/pandas/pandas/tests/indexes | public_repos/pandas/pandas/tests/indexes/period/test_period_range.py | import numpy as np
import pytest
from pandas import (
NaT,
Period,
PeriodIndex,
date_range,
period_range,
)
import pandas._testing as tm
class TestPeriodRange:
def test_required_arguments(self):
msg = (
"Of the three parameters: start, end, and periods, exactly two "
... | 0 |
public_repos/pandas/pandas/tests/indexes | public_repos/pandas/pandas/tests/indexes/period/test_partial_slicing.py | import numpy as np
import pytest
from pandas import (
DataFrame,
PeriodIndex,
Series,
date_range,
period_range,
)
import pandas._testing as tm
class TestPeriodIndex:
def test_getitem_periodindex_duplicates_string_slice(
self, using_copy_on_write, warn_copy_on_write
):
# mo... | 0 |
public_repos/pandas/pandas/tests/indexes | public_repos/pandas/pandas/tests/indexes/period/test_constructors.py | import numpy as np
import pytest
from pandas._libs.tslibs.period import IncompatibleFrequency
from pandas.core.dtypes.dtypes import PeriodDtype
from pandas import (
Index,
NaT,
Period,
PeriodIndex,
Series,
date_range,
offsets,
period_range,
)
import pandas._testing as tm
from pandas.c... | 0 |
public_repos/pandas/pandas/tests/indexes | public_repos/pandas/pandas/tests/indexes/period/test_scalar_compat.py | """Tests for PeriodIndex behaving like a vectorized Period scalar"""
import pytest
from pandas import (
Timedelta,
date_range,
period_range,
)
import pandas._testing as tm
class TestPeriodIndexOps:
def test_start_time(self):
# GH#17157
index = period_range(freq="M", start="2016-01-01... | 0 |
public_repos/pandas/pandas/tests/indexes | public_repos/pandas/pandas/tests/indexes/period/test_tools.py | import numpy as np
import pytest
from pandas import (
Period,
PeriodIndex,
period_range,
)
import pandas._testing as tm
class TestPeriodRepresentation:
"""
Wish to match NumPy units
"""
@pytest.mark.parametrize(
"freq, base_date",
[
("W-THU", "1970-01-01"),
... | 0 |
public_repos/pandas/pandas/tests/indexes | public_repos/pandas/pandas/tests/indexes/period/test_join.py | import numpy as np
import pytest
from pandas._libs.tslibs import IncompatibleFrequency
from pandas import (
Index,
PeriodIndex,
period_range,
)
import pandas._testing as tm
class TestJoin:
def test_join_outer_indexer(self):
pi = period_range("1/1/2000", "1/20/2000", freq="D")
result... | 0 |
public_repos/pandas/pandas/tests/indexes/period | public_repos/pandas/pandas/tests/indexes/period/methods/test_factorize.py | import numpy as np
from pandas import PeriodIndex
import pandas._testing as tm
class TestFactorize:
def test_factorize_period(self):
idx1 = PeriodIndex(
["2014-01", "2014-01", "2014-02", "2014-02", "2014-03", "2014-03"],
freq="M",
)
exp_arr = np.array([0, 0, 1, 1,... | 0 |
public_repos/pandas/pandas/tests/indexes/period | public_repos/pandas/pandas/tests/indexes/period/methods/test_astype.py | import numpy as np
import pytest
from pandas import (
CategoricalIndex,
DatetimeIndex,
Index,
NaT,
Period,
PeriodIndex,
period_range,
)
import pandas._testing as tm
class TestPeriodIndexAsType:
@pytest.mark.parametrize("dtype", [float, "timedelta64", "timedelta64[ns]"])
def test_a... | 0 |
public_repos/pandas/pandas/tests/indexes/period | public_repos/pandas/pandas/tests/indexes/period/methods/test_is_full.py | import pytest
from pandas import PeriodIndex
def test_is_full():
index = PeriodIndex([2005, 2007, 2009], freq="Y")
assert not index.is_full
index = PeriodIndex([2005, 2006, 2007], freq="Y")
assert index.is_full
index = PeriodIndex([2005, 2005, 2007], freq="Y")
assert not index.is_full
... | 0 |
public_repos/pandas/pandas/tests/indexes/period | public_repos/pandas/pandas/tests/indexes/period/methods/test_repeat.py | import numpy as np
import pytest
from pandas import (
PeriodIndex,
period_range,
)
import pandas._testing as tm
class TestRepeat:
@pytest.mark.parametrize("use_numpy", [True, False])
@pytest.mark.parametrize(
"index",
[
period_range("2000-01-01", periods=3, freq="D"),
... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.