Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8228971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:38:25+00:00 2026-06-07T16:38:25+00:00

I need to store Python decimal type values in a pandas TimeSeries / DataFrame

  • 0

I need to store Python decimal type values in a pandas TimeSeries/DataFrame object. Pandas gives me an error when using the “groupby” and “mean” on the TimeSeries/DataFrame. The following code based on floats works well:

[0]: by = lambda x: lambda y: getattr(y, x)

[1]: rng = date_range('1/1/2000', periods=40, freq='4h')

[2]: rnd = np.random.randn(len(rng))

[3]: ts = TimeSeries(rnd, index=rng)

[4]: ts.groupby([by('year'), by('month'), by('day')]).mean()
2000  1  1    0.512422
         2    0.447235
         3    0.290151
         4   -0.227240
         5    0.078815
         6    0.396150
         7   -0.507316

But i get an error if do the same using decimal values instead of floats:

[5]: rnd = [Decimal(x) for x in rnd]       

[6]: ts = TimeSeries(rnd, index=rng, dtype=Decimal)

[7]: ts.groupby([by('year'), by('month'), by('day')]).mean()  #Crash!

Traceback (most recent call last):
File "C:\Users\TM\Documents\Python\tm.py", line 100, in <module>
print ts.groupby([by('year'), by('month'), by('day')]).mean()
File "C:\Python27\lib\site-packages\pandas\core\groupby.py", line 293, in mean
return self._cython_agg_general('mean')
File "C:\Python27\lib\site-packages\pandas\core\groupby.py", line 365, in _cython_agg_general
raise GroupByError('No numeric types to aggregate')
pandas.core.groupby.GroupByError: No numeric types to aggregate

The error message is “GroupByError(‘No numeric types to aggregate’)”. Is there any chance to use the standard aggregations like sum, mean, and quantileon on the TimeSeries or DataFrame containing Decimal values?

Why doens’t it work and is there a chance to have an equally fast alternative if it is not possible?

EDIT: I just realized that most of the other functions (min, max, median, etc.) work fine but not the mean function that i desperately need :-(.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T16:38:28+00:00Added an answer on June 7, 2026 at 4:38 pm
    import numpy as np
    ts.groupby([by('year'), by('month'), by('day')]).apply(np.mean)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using postgresql and python and I need to store data group by week
I have id values for products that I need store. Right now they are
I need to store a list of 1 million key-value pairs in python. The
I'm new to python/django. I need to store an arbitrary number of fields in
In my Python app I need to share a key/value store among a few
I'm using the sqlite3 module in Python 2.6.4 to store a datetime in a
I am coding a psychology experiment in Python. I need to store user information
I need to store Python structures made of lists / dictionaries, tuples into a
I am using Google App Engine Python. I would like to store a simple
I need to store configurations (key/value) for a Python application and I am searching

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.