Relating to up- or down-sampling time series data in the Python package pandas, specifically the methods pandas.DataFrame.resample() and pandas.Series.resample().
Questions tagged [pandas-resample]
314 questions
1
vote
0 answers
Accessing values in Multi-Index dataframe with datetimes
I have a problem trying to access values in a custom dataframe:
My original dataframe is:
print(df)
Data1 Data2 Data3
IMX01 2022-08-12 22:00:00 400.00 500.00 600.00
IMX01 2022-08-15 22:00:00 …

iXrst
- 45
- 7
1
vote
1 answer
Calculate the rolling average every two weeks for the same day and hour in a DataFrame
I have a Dataframe like the following:
df = pd.DataFrame()
df['datetime'] = pd.date_range(start='2023-1-2', end='2023-1-29', freq='15min')
df['week'] = df['datetime'].apply(lambda x: int(x.isocalendar()[1]))
df['day_of_week'] =…

Pythoneer
- 143
- 8
1
vote
1 answer
Convert quarterly target to monthly target using resample, but it only gives me targets from Jan until October. The last two months are missing
My goal is to convert a quarterly target to a monthly target.
Below is my code where I specify the number of meetings a sales person has per quarter.
And using resample method I then convert the quarterly target to monthly target. However, the…

John K Francisco
- 13
- 3
1
vote
1 answer
Pandas resample aggregation, intra month periods?
I'm trying to aggregate some data across periods using resampling and so far have something like this:
Data:
val1 val2 val3 ...
date
2022-01-29 0.01 0.08 0.03
2022-01-30 0.04 -0.07 0.02
2022-01-31 0.09 -0.01 0.01
2022-02-01…

user1267983
- 93
- 1
- 9
1
vote
1 answer
How to resample a column based on the maximum value of another column?
Say, I have a surface wind dataset with an irregular temporal step, looking like below. The actual dataset has many other columns and thousands of rows.
Time, Speed, Direction
2023-1-1 01:00:00, 6, 90
2023-1-1 02:00:00, 6, 70
2023-1-1 03:00:00, 9,…

peteron30
- 69
- 7
1
vote
1 answer
Pandas: calculate the morning averaged values or afternoon averaged values
I got a dataframe like this:
gpi_data[['sig','hourtime']]
Out[28]:
sig hourtime
datetime_doy
2007-01-02 -8.963545 2007-01-02 09:20:11.249998
2007-01-03 -8.671357…

Xu Shan
- 175
- 3
- 11
1
vote
1 answer
Python: resample on a rolling basis
I have a DataFrame as follows:
data = [[99330,12,122],
[1123,1230,1287],
[123,101,812739],
[1143,12301230,252],
[234,342,4546],
[2445,3453,3457],
[7897,8657,5675],
[46,5675,453],
[76,484,3735],
[363,93,4568],
…

MathMan 99
- 665
- 1
- 7
- 19
1
vote
1 answer
Also ffill last value when resampling in pandas
I want to resample a dataframe and ffill values, see code below. However, the last value isn't forward filled.
df=pd.DataFrame(index=pd.date_range(start='1/1/2022',periods=5,freq='h'),data=range(0,5))
print(df.resample('15T').ffill())
results in:
…

Python404
- 13
- 3
1
vote
1 answer
How can you generate running resampled cumulative to date output for pandas timeseries data?
I am trying to generate the cumulative sum (or other cumulative function) of data in a pandas timeseries that is resampled. This is different from generating simply the cumulative sum of the data at each resample point in that I also want to output…

agftrading
- 784
- 3
- 8
- 21
1
vote
1 answer
Similar time submissions for tests
I have a dataframe for each of my online students shaped like this:
df=pd.DataFrame(columns=["Class","Student","Challenge","Time"])
I create a temporary df for each of the challenges like this:
for ch in challenges:
…

Daniel
- 77
- 3
- 20
1
vote
2 answers
C# Tick by tick stock data to Ohlc candles resample on different timeframe
I want to convert tick by tick data to 1, 5,10 minutes, 1 hour, 2 hours time frame based on time frame. Data looks like below every second data.
var source = new List()
{
new TickData{ Timestamp =…

Venkat B
- 73
- 4
1
vote
1 answer
Grouping by date range (timedelta) with Pandas
This question was asked before, but I want to extend on it. Because I do not have enough experience points I could not comment on the question so I am reposting the link below followed by my comments:
Grouping by date range with pandas
I believe…

Mario111
- 35
- 1
- 10
1
vote
0 answers
How to resample OHLC data with multiple stocks in index?
I haven't been able to find anything too similar to this I have OHLC data pulled from y-finance for multiple stocks. This results in a multi-index of columns of OHLC data and stock names
Python Script
'''
import requests
import pandas as pd
import…

Jon 310
- 11
- 2
1
vote
1 answer
Pandas resample with multiindex start- and enddate
Suppose I have a multi-index Pandas data frame with two index levels: month_begin and month_end
import pandas as pd
multi_index = pd.MultiIndex.from_tuples([("2022-03-01", "2022-03-31"),
("2022-04-01",…

W. Walter
- 337
- 1
- 10
1
vote
1 answer
Dask: groupby-resample with different aggregating rules
I am working with panel data (i.e., a panel of IDs and time periods) in Dask and wish to resample the frequency from microseconds to 30 seconds. Sample data looks like this:
size price ID
datetime …

AYA
- 21
- 6