/usr/local/lib64/python3.6/site-packages/pandas/tests/indexes/multi
NameSizeModeActions
__pycache__/-0755rm
conftest.py22160644editdlrm
test_analytics.py69840644editdlrm
test_astype.py9240644editdlrm
test_compat.py35340644editdlrm
test_constructors.py256460644editdlrm
test_conversion.py41890644editdlrm
test_copy.py23410644editdlrm
test_drop.py44280644editdlrm
test_duplicates.py101630644editdlrm
test_equivalence.py70830644editdlrm
test_formats.py77840644editdlrm
test_get_level_values.py35790644editdlrm
test_get_set.py117200644editdlrm
test_indexing.py299070644editdlrm
test_integrity.py84890644editdlrm
test_isin.py31740644editdlrm
test_join.py37880644editdlrm
test_lexsort.py13510644editdlrm
test_missing.py33780644editdlrm
test_monotonic.py69360644editdlrm
test_names.py45930644editdlrm
test_partial_indexing.py33760644editdlrm
test_reindex.py37450644editdlrm
test_reshape.py50410644editdlrm
test_setops.py121810644editdlrm
test_sorting.py84060644editdlrm
test_take.py25010644editdlrm
__init__.py00644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/pandas/tests/indexes/multi/test_take.py (2501B)
import numpy as np import pytest import pandas as pd import pandas._testing as tm def test_take(idx): indexer = [4, 3, 0, 2] result = idx.take(indexer) expected = idx[indexer] assert result.equals(expected) # GH 10791 msg = "'MultiIndex' object has no attribute 'freq'" with pytest.raises(AttributeError, match=msg): idx.freq def test_take_invalid_kwargs(idx): idx = idx indices = [1, 2] msg = r"take\(\) got an unexpected keyword argument 'foo'" with pytest.raises(TypeError, match=msg): idx.take(indices, foo=2) msg = "the 'out' parameter is not supported" with pytest.raises(ValueError, match=msg): idx.take(indices, out=indices) msg = "the 'mode' parameter is not supported" with pytest.raises(ValueError, match=msg): idx.take(indices, mode="clip") def test_take_fill_value(): # GH 12631 vals = [["A", "B"], [pd.Timestamp("2011-01-01"), pd.Timestamp("2011-01-02")]] idx = pd.MultiIndex.from_product(vals, names=["str", "dt"]) result = idx.take(np.array([1, 0, -1])) exp_vals = [ ("A", pd.Timestamp("2011-01-02")), ("A", pd.Timestamp("2011-01-01")), ("B", pd.Timestamp("2011-01-02")), ] expected = pd.MultiIndex.from_tuples(exp_vals, names=["str", "dt"]) tm.assert_index_equal(result, expected) # fill_value result = idx.take(np.array([1, 0, -1]), fill_value=True) exp_vals = [ ("A", pd.Timestamp("2011-01-02")), ("A", pd.Timestamp("2011-01-01")), (np.nan, pd.NaT), ] expected = pd.MultiIndex.from_tuples(exp_vals, names=["str", "dt"]) tm.assert_index_equal(result, expected) # allow_fill=False result = idx.take(np.array([1, 0, -1]), allow_fill=False, fill_value=True) exp_vals = [ ("A", pd.Timestamp("2011-01-02")), ("A", pd.Timestamp("2011-01-01")), ("B", pd.Timestamp("2011-01-02")), ] expected = pd.MultiIndex.from_tuples(exp_vals, names=["str", "dt"]) tm.assert_index_equal(result, expected) msg = "When allow_fill=True and fill_value is not None, all indices must be >= -1" with pytest.raises(ValueError, match=msg): idx.take(np.array([1, 0, -2]), fill_value=True) with pytest.raises(ValueError, match=msg): idx.take(np.array([1, 0, -5]), fill_value=True) msg = "index -5 is out of bounds for( axis 0 with)? size 4" with pytest.raises(IndexError, match=msg): idx.take(np.array([1, -5]))