Skip to content

Commit eea4101

Browse files
code sample for pandas-dev#43767
1 parent 5117fd1 commit eea4101

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

bisect/43767.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# BUG: reset_index after a group_by raise a ValueError for empty dataframe #43767
2+
3+
import datetime as dt
4+
5+
import pandas as pd
6+
7+
print(pd.__version__)
8+
9+
df = pd.DataFrame([(dt.date.today(), "b", 12)], columns=["date", "b", "count"])
10+
df["date"] = pd.to_datetime(df["date"])
11+
df = df[
12+
df["count"] == 1
13+
] # uncomment this line to make the dataframe empty and so reset_index raising an exception
14+
result = df.set_index("date").groupby(["b"]).resample("M").sum().reset_index()
15+
print(result)

0 commit comments

Comments
 (0)