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
0
votes
3 answers
How to resample a Pandas DataFrame at a lower frequency and stop it creating NaN's?
I have a Pandas Dataframe with a DateTime index. It has closing prices of some stocks sampled at the 1-minute interval. I want to resample this dataframe and get it at the 5-minute interval, as if it had been collected in that way. For example:
…

Raul Guarini Riva
- 651
- 1
- 10
- 20
0
votes
2 answers
Mean of values Monthly in Dataframe with date as column
Thanks for investing time to help me out :)
I have DataFrame (df_NSE_Price_) like below:
Company Name ID 2000-01-03 00:00:00 2000-01-04 00:00:00 ....
Reliance Industries Ltd. 100325 50.810 54.
Tata Consultancy…

Ritika Mehta
- 3
- 2
0
votes
0 answers
What is the difference between bins when using groupby apply vs resample apply?
This is somewhat of a broad topic, but I will try to pare it to some specific questions.
I have noticed a difference between resample and groupby that I am curious to learn about. Here is some hourly time series data:
In[]:
import pandas as pd
dr…

Tom
- 8,310
- 2
- 16
- 36
0
votes
1 answer
Pandas resampling from daily to weekly adds an extra week? Is this normal?
I have a dataframe with daily transaction amounts. Date is index ds and transaction amount is column y
ds y
2017-08-16 10.0
2017-10-26 21.7
2017-11-04 5.0
2017-11-13 10.0
2017-11-27 14.0
The data only goes up to…

SCool
- 3,104
- 4
- 21
- 49
-1
votes
1 answer
Resample Problem - timing out the series in resample
Resample Problem:
At the example above, the timeseries dataframe initialize at 09:00, but resample 120T, initialize arbitrarily at 08:00!
Why? Workarounds? Thanks
import pandas as pd
import numpy as np
num_rows = 480
start_date =…

Denier Pardon
- 1
- 1
-1
votes
1 answer
How to count the number of occurence daily for each element in a dataframe
Being working with a KPIs dataframe where I've a set of KPIs for different element and each KPI having a value hourly, e.g below.
The CSV text used to create the dataframe cand be found here : https://textsaver.flap.tv/lists/4ta4
Main Dataframe…

DarKing
- 25
- 6
-1
votes
1 answer
why are there Series in the pandas.DataFrame.resample loop?
I'm using pandas.DataFrame.resample on the data set below:
data snapshot
And I applied my own function, which is defined as:
def btc_resample(df):
if len(df) > 0:
print(type(df))
print(df)
print(df['close'])
…
-1
votes
1 answer
Doing calculations on higher frequency data in lower frequency bins in Pandas
I have some data in a pandas dataframe that has entries at the per-second level over the course of a few hours. Entries are indexed by datetime format as TIMESTAMP. I would like to group all data within each minute and do some calculations and…

havingaball
- 378
- 2
- 11
-1
votes
1 answer
Pandas resample fill NaN
I have this df:
Timestamp List Power Energy Status
0 2020-01-01 01:05:50 [5, 5, 5] 7000 15000 online
1 2020-01-01 01:06:20 [6, 6, 6] 7500 16000 online
2 2020-01-01 01:08:30 [0, 0, 0] …

Vini
- 125
- 1
- 8
-1
votes
1 answer
Pandas DataFrame Resample to Months when DatetimeIndex is last day of year
I've got a DataFrame with DatetimeIndex labeled as the last day of the year (e.j. 2020-12-31, 2021-12-31, etc). I need to resample in order to expand the dataframe into months (e.j. 2020-01-31, 2020-02-29, etc). When I use the resample function it…

Javier Lorenzini
- 23
- 1
- 4
-1
votes
1 answer
How to resample a csv so it can perfectly align with my other csv
I am working on another aspect of my project but using a csv I downloaded from Mesowest for my experiment.
The new code is
df_pirates_all = pd.read_csv(
…

stratusshow
- 25
- 9
-2
votes
1 answer
resampling date to calculate mean speed for each Driver on each 1 min than to count mean(speed)< 23 km/h
i want add column to my dataframe to count for each driver mean(speed) < 23
this is my code to calculate mean(speed) on each 1 min and groupby driver
rawData.groupby('DriverId').resample("1T", on='time').SPEED.mean()
the result is :
DriverId …

yyou123
- 7
- 4
-3
votes
1 answer
Create monthly resampled Pandas DataFrame based on dates
I am struggling trying convert a dataframe containing multiple datetime columns into a version with a daterange.
A smaller example would look somewhat like this:
So from:
key date_upgrade1 date_upgrade2
0 key1 2020-07-31 2020-08-31
1 key2…

Goliath
- 1
- 4