Skip to content

Commit 3ff8145

Browse files
add test for when index is set from column
1 parent 595a291 commit 3ff8145

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

pandas/tests/resample/test_resampler_grouper.py

+27-13
Original file line numberDiff line numberDiff line change
@@ -691,20 +691,34 @@ def test_groupby_resample_on_index_with_list_of_keys_missing_column():
691691
rs[["val_not_in_dataframe"]]
692692

693693

694-
def test_groupby_resample_when_index_is_out_of_order():
694+
@pytest.mark.parametrize(
695+
"df",
696+
[
697+
DataFrame(
698+
data={
699+
"datetime": [
700+
pd.to_datetime("2024-07-30T00:00Z"),
701+
pd.to_datetime("2024-07-30T00:01Z"),
702+
],
703+
"group": ["A", "A"],
704+
"numbers": [100, 200],
705+
},
706+
index=[1, 0],
707+
),
708+
DataFrame(
709+
data={
710+
"datetime": [
711+
pd.to_datetime("2024-07-30T00:00Z"),
712+
pd.to_datetime("2024-07-30T00:01Z"),
713+
],
714+
"group": ["A", "A"],
715+
"numbers": [100, 200],
716+
},
717+
).set_index("group"),
718+
],
719+
)
720+
def test_groupby_resample_on_column_when_index_is_not_a_range_of_numbers(df):
695721
# GH 59350
696-
df = DataFrame(
697-
data={
698-
"datetime": [
699-
pd.to_datetime("2024-07-30T00:00Z"),
700-
pd.to_datetime("2024-07-30T00:01Z"),
701-
],
702-
"group": ["A", "A"],
703-
"numbers": [100, 200],
704-
},
705-
index=[1, 0],
706-
)
707-
708722
gb = df.groupby("group")
709723
rs = gb.resample("1min", on="datetime")
710724
result = rs.aggregate({"numbers": "sum"})

0 commit comments

Comments
 (0)