Skip to content

TST: split up pandas/tests/indexing/test_multiindex.py #23912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Nov 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6d3592a
move file to subdirectory
simonjayhawkins Nov 25, 2018
cdc5f62
split off TestMultiIndexPanel class
simonjayhawkins Nov 25, 2018
55ef180
split off TestMultiIndexSlicers class
simonjayhawkins Nov 25, 2018
2002877
move iloc tests from TestMultiIndexBasic class
simonjayhawkins Nov 25, 2018
beafea9
move loc tests from TestMultiIndexBasic class
simonjayhawkins Nov 25, 2018
e921081
move datetime test
simonjayhawkins Nov 25, 2018
b730f16
move ix test
simonjayhawkins Nov 25, 2018
f0bffc6
move partial tests
simonjayhawkins Nov 25, 2018
fa44d52
move xs tests
simonjayhawkins Nov 25, 2018
5b50ab1
move sorted tests
simonjayhawkins Nov 25, 2018
b0a6d17
fix failing tests
simonjayhawkins Nov 25, 2018
f416034
move more tests to test_slice.py
simonjayhawkins Nov 27, 2018
c509d7f
move tests to test_set_ops.py
simonjayhawkins Nov 27, 2018
4da9174
Merge remote-tracking branch 'upstream/master' into split-mi-test
simonjayhawkins Nov 27, 2018
2bad48c
move test and fixture to test_loc.py
simonjayhawkins Nov 27, 2018
53b5a20
move tests to test_setitem.py
simonjayhawkins Nov 27, 2018
4ce1c8e
move tests to test_getitem.py
simonjayhawkins Nov 27, 2018
600925c
fix failing test
simonjayhawkins Nov 27, 2018
684e3c3
Merge remote-tracking branch 'upstream/master' into split-mi-test
simonjayhawkins Nov 27, 2018
8b016cc
Merge remote-tracking branch 'upstream/master' into split-mi-test
simonjayhawkins Nov 28, 2018
c07e324
Merge remote-tracking branch 'upstream/master' into split-mi-test
simonjayhawkins Nov 28, 2018
5869d15
Merge remote-tracking branch 'upstream/master' into split-mi-test
simonjayhawkins Nov 29, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
32 changes: 32 additions & 0 deletions pandas/tests/indexing/multiindex/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import numpy as np
import pytest

from pandas import DataFrame, Index, MultiIndex
from pandas.util import testing as tm


@pytest.fixture
def multiindex_dataframe_random_data():
"""DataFrame with 2 level MultiIndex with random data"""
index = MultiIndex(levels=[['foo', 'bar', 'baz', 'qux'], ['one', 'two',
'three']],
labels=[[0, 0, 0, 1, 1, 2, 2, 3, 3, 3],
[0, 1, 2, 0, 1, 1, 2, 0, 1, 2]],
names=['first', 'second'])
return DataFrame(np.random.randn(10, 3), index=index,
columns=Index(['A', 'B', 'C'], name='exp'))


@pytest.fixture
def multiindex_year_month_day_dataframe_random_data():
"""DataFrame with 3 level MultiIndex (year, month, day) covering
first 100 business days from 2000-01-01 with random data"""
tm.N = 100
tdf = tm.makeTimeDataFrame()
ymd = tdf.groupby([lambda x: x.year, lambda x: x.month,
lambda x: x.day]).sum()
# use Int64Index, to make sure things work
ymd.index.set_levels([lev.astype('i8') for lev in ymd.index.levels],
inplace=True)
ymd.index.set_names(['year', 'month', 'day'], inplace=True)
return ymd
22 changes: 22 additions & 0 deletions pandas/tests/indexing/multiindex/test_datetime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from datetime import datetime

import numpy as np

from pandas import Index, Period, Series, period_range


def test_multiindex_period_datetime():
# GH4861, using datetime in period of multiindex raises exception

idx1 = Index(['a', 'a', 'a', 'b', 'b'])
idx2 = period_range('2012-01', periods=len(idx1), freq='M')
s = Series(np.random.randn(len(idx1)), [idx1, idx2])

# try Period as index
expected = s.iloc[0]
result = s.loc['a', Period('2012-01')]
assert result == expected

# try datetime as index
result = s.loc['a', datetime(2012, 1, 1)]
assert result == expected
Loading