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
1 answer
pandas DataFrame groupby/freq with value range
Is there any method in python pandas to slice price range a DataFrame, not only time range, like groupby('D')?
I need price range from this DataFrame, when price range is 5, and I want to other columns start/end/min/max of…

bandito
- 23
- 4
1
vote
2 answers
Inconsistent output for pandas groupby-resample with missing values in first time bin
I am finding an inconsistent output with pandas groupby-resample behavior.
Take this dataframe, in which category A has samples on the first and second day and category B has a sample only on the second day:
df1 =…

Jen
- 146
- 6
1
vote
1 answer
Pandas: assign datetime resample index back into original dataframe
Say I want to groupby/resample by week. How can I assign the resample index back into the original dataframe like so?
index date
0 1/1/22
1 1/2/22
2 1/3/22
3 1/4/22
4 1/5/22
5 1/6/22
6 1/7/22
7 1/8/22
8 1/9/22
9 …

Daniel Chang
- 21
- 2
1
vote
1 answer
Finding daily balance using pandas?
I have a data frame like this...
Customer
Date
Balance
Adam
01/01/2022
10
Adam
01/01/2022
20
Adam
03/01/2022
30
Molly
01/01/2022
40
Molly
01/01/2022
50
Molly
03/01/2022
60
I want to find daily day-end balance for each customer.…

Firoj Kawser Jubayer
- 45
- 5
1
vote
2 answers
Hourly Average of csv data of 15 minutes interval
My data in csv files is 15 minutes average and I want to hourly Average. When I used below code, it is showing error. 'how' unrecognised argument.
import pandas as pd
df =…

Narasimha Murthy V
- 15
- 6
1
vote
1 answer
apply resample function on pandas groupby without using for loop
I have an DataFrame like this:
item_id facility_id timestamp min_inv current_inv demand
0 12 1185 2022-01-11 00:00:00 2.0 3.0 1
1 12 1185 2022-01-11 01:00:00 2.0 …

mufassir
- 406
- 5
- 16
1
vote
2 answers
How to resample a dataframe ONLY when time range is too long?
I have a simple DataFrame like this:
timestamp
Power
29/08/2021 02:30:16
155
29/08/2021 02:45:19
151
29/08/2021 03:00:14
155
29/08/2021 03:30:12
152
29/08/2021 04:00:12
149
29/08/2021 04:15:09
152
29/08/2021 …

Lorenzo Siboni
- 37
- 2
1
vote
0 answers
Pandas resample OHLC data to weekly with custom week start/end datetime
I have standard 1m ohlc DataFrame like this:
2017-01-02 02:29:00 1.23452 1.23467 1.23452 1.23467
2017-01-02 02:30:00 1.23464 1.23467 1.23464 1.23465
2017-01-02 02:31:00 1.23452 1.23465 1.23444 1.23444
2017-01-02 02:32:00 1.23465 1.23465 1.23447…

Piotr Jaszczyk
- 15
- 3
1
vote
2 answers
Pandas dataframe group by 10 min intervals with different actions on other columns
I have a pandas dataframe which includes a timestamp and 71 other columns, something like this:
timestamp |close_price|highest_price|volume| ...
2018-09-29 00:00:20 |1809 |1811 | ... |
…

Stanisla Vavrika
- 25
- 5
1
vote
1 answer
Pandas resample to weekly while last index is the end of that month
I got the following dataframe containing daily data and I would like to resample it to weekly data.
Name Target Sales
Datetime
2021-12-01 Amy 1000 26000
2021-12-02 Amy 1000 0
...
2021-12-30 Amy 1000 0
2021-12-31 Amy …

Hang
- 197
- 1
- 11
1
vote
1 answer
Resample 15 min data month profile into an average day profile
I have a dataframe that consists of 15 min data of each day for an entire month. Where DateTime column is a timestamp data type and the dataframe looks like this:
DateTime, Temperature, Moisture, Accumulated precipitation
1/01/2022 00:00, 23, 50,…

Maria Fernanda
- 143
- 2
- 8
1
vote
1 answer
Pandas upsample and nearest interpolation give only NaNs
I have a dataframe (df, time as index and 1 column 'Pt0') that I want to upsample and interpolate with "nearest neighbor" method.
I have 2 issues:
When I compute df = df.upsample('1D'), I get an object core.resample.DatetimeIndexResampler which…

Nihilum
- 549
- 3
- 11
1
vote
1 answer
Pandas Resampling biweekly between a specific week range
I have an 8-year timeseries with daily values where I would like to resample biweekly. However, I only need biweekly values from week 18 to week 30 of each year (i.e. W18, W20, W22, ..., W30). This method would sometimes give me the 'odd' biweekly…

Yogi
- 45
- 6
1
vote
1 answer
timestamp binning mechanics when resampling
I'm not quite clear on how bin-membership in DataFrame.resample is determined.
Example/actual output:
>>> df = pd.DataFrame(index=pd.date_range(start='2021-04-21 01:00:00', end='2021-04-28 01:00', freq='1d'), data=[1]*8)
>>> df
…

actual_panda
- 1,178
- 9
- 27
1
vote
1 answer
Resample a time-series data at the end of the month and at the end of the day
I have a timeseries data with the following format.
DateShort (%d/%m/%Y)
TimeFrom
TimeTo
Value
1/1/2018
0:00
1:00
6414
1/1/2018
1:00
2:00
6153
...
...
...
...
1/1/2018
23:00
0:00
6317
2/1/2018
0:00
1:00
6046
...
...
...
...
I…

yoonghm
- 4,198
- 1
- 32
- 48