Skip to content

TST: Add test_datetime_object_multiindex test #52913

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
Changes from all commits
Commits
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
24 changes: 24 additions & 0 deletions pandas/tests/test_multilevel.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import datetime

import numpy as np
import pytest

Expand Down Expand Up @@ -266,6 +268,28 @@ def test_subsets_multiindex_dtype(self):
result = df.a.b.dtypes
tm.assert_series_equal(result, expected)

def test_datetime_object_multiindex(self):
data_dic = {
(0, datetime.date(2018, 3, 3)): {"A": 1, "B": 10},
(0, datetime.date(2018, 3, 4)): {"A": 2, "B": 11},
(1, datetime.date(2018, 3, 3)): {"A": 3, "B": 12},
(1, datetime.date(2018, 3, 4)): {"A": 4, "B": 13},
}
result = DataFrame.from_dict(data_dic, orient="index")
data = {"A": [1, 2, 3, 4], "B": [10, 11, 12, 13]}
index = [
[0, 0, 1, 1],
[
datetime.date(2018, 3, 3),
datetime.date(2018, 3, 4),
datetime.date(2018, 3, 3),
datetime.date(2018, 3, 4),
],
]
expected = DataFrame(data=data, index=index)

tm.assert_frame_equal(result, expected)


class TestSorted:
"""everything you wanted to test about sorting"""
Expand Down