Skip to content

TST: Add tests for #55431 #58367

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 6 commits into from
Apr 29, 2024
Merged
Changes from 4 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
30 changes: 30 additions & 0 deletions pandas/tests/reshape/test_cut.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,3 +789,33 @@ def test_cut_with_nullable_int64():
result = cut(series, bins=bins)

tm.assert_series_equal(result, expected)


def test_datetime_cut_notna():
# Create a Series with datetime data
data = to_datetime(["2023-09-17", "2023-10-06"])
# Convert the Series to a DatetimeArray
datetime_array = data.array

# Define bins for categorization
bins = date_range(start="2023-09-16", periods=3, freq="10D")

# Use pd.cut to categorize datetime data and capture the result
result = cut(datetime_array, bins=bins)

# Define expected result as an IntervalIndex with specified intervals
expected_intervals = IntervalIndex.from_tuples(
[
(Timestamp("2023-09-16"), Timestamp("2023-09-26")),
(Timestamp("2023-09-26"), Timestamp("2023-10-06")),
]
)

expected = Series(expected_intervals).astype(CategoricalDtype(ordered=True))

# Assert that result matches expected using pandas testing tools
tm.assert_series_equal(Series(result), expected)

# assert not hasattr(
# result, "notna"
# ), "AttributeError related to 'notna' should not be present"
Loading