Skip to content

BUG: typeerror: datetime64 type does not support sum operations #52558

@muazhari

Description

@muazhari

Pandas version checks

  • I have checked that this issue has not already been reported.

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

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

item_transactions_df = pd.DataFrame([value.dict() for value in item_transactions])

# item_transaction_df.dtypes 
# quantity_after            float64
# account_id                 object
# item_id                    object
# created_at         datetime64[ns]
# quantity_before           float64
# id                         object
# timestamp          datetime64[ns]
# updated_at         datetime64[ns]
# dtype: object

grouped_inventory_controls_df = item_transactions_df \
            .sort_values(by=["timestamp"], ascending=True) \
            .groupby(by=pd.Grouper(key="timestamp", freq='1D')) \
            .first()

resampled_item_transactions_df = grouped_inventory_controls_df \
            .resample(request.resample) \
            .sum()

Issue Description

Displayed error message:

typeerror: datetime64 type does not support sum operations

However, in version pandas==1.5.3, that error doesn't show up.

Expected Behavior

Could do group by and resample normally.

Installed Versions

INSTALLED VERSIONS

commit : 478d340
python : 3.9.13.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.22621
machine : AMD64
processor : Intel64 Family 6 Model 183 Stepping 1, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.1252

pandas : 2.0.0
numpy : 1.21.5
pytz : 2022.1
dateutil : 2.8.2
setuptools : 63.4.1
pip : 22.2.2
Cython : 0.29.32
pytest : 7.3.0
hypothesis : None
sphinx : 5.0.2
blosc : None
feather : None
xlsxwriter : 3.0.3
lxml.etree : 4.9.1
html5lib : None
pymysql : None
psycopg2 : 2.9.6
jinja2 : 2.11.3
IPython : 7.31.1
pandas_datareader: None
bs4 : 4.11.1
bottleneck : 1.3.5
brotli :
fastparquet : None
fsspec : 2022.7.1
gcsfs : None
matplotlib : 3.5.2
numba : 0.55.1
numexpr : 2.8.3
odfpy : None
openpyxl : 3.0.10
pandas_gbq : None
pyarrow : 10.0.1
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.8.1
snappy :
sqlalchemy : 1.4.41
tables : 3.6.1
tabulate : 0.8.10
xarray : 0.20.1
xlrd : 2.0.1
zstandard : None
tzdata : 2022.7
qtpy : 2.2.0
pyqt5 : None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions