Skip to content

Commit 68519b6

Browse files
code sample for pandas-dev#46218
1 parent 445484c commit 68519b6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

bisect/46218.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# BUG: pd.cut regression starting in version 1.4.0 when operating on datetime #46218
2+
3+
import pandas as pd
4+
5+
print(pd.__version__)
6+
7+
idx = pd.interval_range(
8+
pd.Timestamp("2022-02-25"),
9+
pd.Timestamp("2022-02-27"),
10+
freq="1D",
11+
)
12+
13+
result = pd.cut(pd.Series([pd.Timestamp("2022-02-26")]), bins=idx).value_counts()
14+
print(result)
15+
16+
dtype = pd.CategoricalDtype(idx, ordered=True)
17+
expected = pd.Series([1, 0], index=idx.astype(dtype))
18+
pd.testing.assert_series_equal(result, expected)

0 commit comments

Comments
 (0)