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 8258959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:43:40+00:00 2026-06-08T02:43:40+00:00

I have a times series with temperature and radiation in a pandas dataframe .

  • 0

I have a times series with temperature and radiation in a pandas dataframe. The time resolution is 1 minute in regular steps.

import datetime
import pandas as pd
import numpy as np

date_times = pd.date_range(datetime.datetime(2012, 4, 5, 8, 0),
                           datetime.datetime(2012, 4, 5, 12, 0),
                           freq='1min')
tamb = np.random.sample(date_times.size) * 10.0
radiation = np.random.sample(date_times.size) * 10.0
frame = pd.DataFrame(data={'tamb': tamb, 'radiation': radiation},
                     index=date_times)
frame
<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 241 entries, 2012-04-05 08:00:00 to 2012-04-05 12:00:00
Freq: T
Data columns:
radiation    241  non-null values
tamb         241  non-null values
dtypes: float64(2)

How can I down-sample this dataframe to a resolution of one hour, computing the hourly mean for the temperature and the hourly sum for radiation?

  • 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-08T02:43:42+00:00Added an answer on June 8, 2026 at 2:43 am

    With pandas 0.18 the resample API changed (see the docs).
    So for pandas >= 0.18 the answer is:

    In [31]: frame.resample('1H').agg({'radiation': np.sum, 'tamb': np.mean})
    Out[31]: 
                             tamb   radiation
    2012-04-05 08:00:00  5.161235  279.507182
    2012-04-05 09:00:00  4.968145  290.941073
    2012-04-05 10:00:00  4.478531  317.678285
    2012-04-05 11:00:00  4.706206  335.258633
    2012-04-05 12:00:00  2.457873    8.655838
    

    Old Answer:

    I am answering my question to reflect the time series related changes in pandas >= 0.8 (all other answers are outdated).

    Using pandas >= 0.8 the answer is:

    In [30]: frame.resample('1H', how={'radiation': np.sum, 'tamb': np.mean})
    Out[30]: 
                             tamb   radiation
    2012-04-05 08:00:00  5.161235  279.507182
    2012-04-05 09:00:00  4.968145  290.941073
    2012-04-05 10:00:00  4.478531  317.678285
    2012-04-05 11:00:00  4.706206  335.258633
    2012-04-05 12:00:00  2.457873    8.655838
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a time series of temperature profiles that I want to interpolate, I
I have a periodic time series, of air temperature over several years, and I
I have two time series of data, one which is water temperature and the
I have a big time series full in one dataframe and a list of
I have a Pandas Series sampled at irregular times (roughly 5 s, but always
I have a time series like this which consists of past 4 months (Feb,
I have a time series: dDate=seq(as.POSIXct(2012/1/1), as.POSIXct(2012/1/10), day) dDate [1] 2012-01-01 PST 2012-01-02 PST
I have various time-series I'd like to correlate and present as either a csv-file
I have a time series of two indexes, with each row representing the closing
I want to have a time series of 2x2 complex matrices,Ot, and I then

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.