Skip to content

TST: added test for cut when labels are tuples of Timestamps (#40661) #43850

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 2 commits into from
Oct 3, 2021
Merged
Changes from 1 commit
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
11 changes: 11 additions & 0 deletions pandas/tests/reshape/test_cut.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,3 +725,14 @@ def test_cut_with_nonexact_categorical_indices():
)

tm.assert_frame_equal(expected, result)


def test_cut_with_timestamp_tuple_labels():
# GH 40661
data = [2, 4, 6]
bins = [1, 3, 5, 7]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't have to define data and bins, you are using it only once. Can directly pass it into cut

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes definitely. Thank you 👍

labels = [(Timestamp(10),), (Timestamp(20),), (Timestamp(30),)]
result = cut(data, bins=bins, labels=labels)

expected = Categorical.from_codes([0, 1, 2], labels, ordered=True)
tm.assert_categorical_equal(result, expected)