Skip to content

BUG: resampling DataFrame with DateTimeIndex with holes and uint64 columns leads to error on pandas==1.3.2 (not in 1.2.5) #43329

Closed
@julienl-met

Description

@julienl-met
  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas.


Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

import numpy as np
import pandas as pd

# Data generation: DataFrame with DateTimeIndex, one row per hour, values are 0 or 1.
df = pd.DataFrame(index=pd.date_range(start="2000-01-01", end="2000-01-03 23", freq="H"), columns=["x"], data=[0, 1, 0] * 24)

# Removing some rows in order to have a hole in the dataset
df = df.loc[(df.index < "2000-01-02") | (df.index > "2000-01-03"), :]

# Create dummy indicator
one_hot = pd.get_dummies(df["x"])  # This line leads to having "RuntimeError: empty group with uint64_t"
# one_hot = pd.get_dummies(df["x"], dtype=int)  # This line leads to having expected dataframe

# Keeping, for each day, the maximum day value.
df_output = one_hot.resample("D").max()

# Expected_dataframe: 
df_expected = pd.DataFrame(
    index=pd.date_range(start="2000-01-01", end="2000-01-03", freq="D"),
    data={col: [1, np.nan, 1] for col in [0,1]}
)
pd.testing.assert_frame_equal(df_expected, df_output)

Problem description

With pandas=1.3.2, above code block leads to "RuntimeError: empty group with uint64_t". It was not the case with pandas==1.1.0 for instance. Not an issue for me (problem solved specifying dtype), but probably an issue to solve.

Expected Output

Given in code sample section

Output of pd.show_versions()

INSTALLED VERSIONS

commit : 5f648bf
python : 3.8.5.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.72-microsoft-standard-WSL2
Version : #1 SMP Wed Oct 28 23:40:43 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.3.2
numpy : 1.21.2
pytz : 2021.1
dateutil : 2.8.2
pip : 21.2.4
setuptools : 57.4.0
Cython : None
pytest : 6.2.5
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : 7.27.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.4.3
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : 1.7.1
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugRegressionFunctionality that used to work in a prior pandas version

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions