Questions tagged [pandas-resample]

Relating to up- or down-sampling time series data in the Python package pandas, specifically the methods pandas.DataFrame.resample() and pandas.Series.resample().

314 questions
0
votes
1 answer

How do I resample and value_count at the same time in pandas?

I have a data frame with fields for type of cat and a timestamp. I can see all value counts of my field like this: df["cat_type"].value_counts() Calico 2870 Tabby 102 Tortoise_shell 51 Name: cat_type, dtype: int64 And I can see…
Mittenchops
  • 18,633
  • 33
  • 128
  • 246
0
votes
1 answer

Datetime dataframe need to be grouped by station ID and then use resampling method for each station ID

I have a data frame in Datetime format which looks as follows: def read_station_data( fileName ): '''Read the contents of the soil moisture data file into a Pandas DataFrame where the index is the observation date. Return the dataframe. …
0
votes
1 answer

resample 5 minutes only by past

Problem How to create column that resamples 5 minutes in pandas but only till current certain row, so either last 5 minutes from current observation, or 5 minutes interval but if I am at minute 3 to resample last 5 or last 3, point being not to…
romrom123
  • 15
  • 6
0
votes
1 answer

Pandas resample daily to weekly data

I want to divide the daily data into 5 groups. Each starts from a different day with a fixed frequency of 5 business days. It's something like all the Monday put together and all the Tuesday put together. I use the resample function. df1 =…
Lei Hao
  • 708
  • 1
  • 7
  • 21
0
votes
1 answer

What's the meaning of Python error message `KeyError: 'The grouper name created_at is not found'`?

I'm trying to take a series of tweets and group them into 1 hour intervals based on when the tweets were created, and sum the likes the tweets got for each 1 hour interval. The tweets have been converted to a pandas dataframe, eg: df.head(1) …
dsx
  • 167
  • 1
  • 12
0
votes
1 answer

how to create monthly and season 24 hours average table using pandas

I have a dataframe with 2 columns: Date and LMP and there are totals of 8760 rows. This is the dummy dataframe: import pandas as pd import numpy as np df = pd.DataFrame({'Date': pd.date_range('2023-01-01 00:00', '2023-12-31 23:00', freq='1H'),…
Vesper
  • 795
  • 1
  • 9
  • 21
0
votes
0 answers

Deal with equivalent index after resampling from daily to weekly

I got the following dataset with daily data: Name Target Sales Datetime 2021-06-01 Amy 9615.4 11800 2021-06-02 Amy 9615.4 0 ... 2021-06-30 Amy 9615.4 197.5 2021-07-01 Amy 9259.3 20672 2021-07-02 Amy 9259.3 …
Hang
  • 197
  • 1
  • 11
0
votes
0 answers

Pandas: reset index up after reampling to the nearest 15 minutes

When we apply resampling with frequency 15min, it creates a dataframe where its index has been rounded down to the nearest 15 minutes, for example: df.resample('15min')['col1'].sum() time value 2022-01-31 09:00:00+00:00 …
sci9
  • 700
  • 1
  • 7
  • 21
0
votes
1 answer

Python: resample dataframe and sum

I have the following dataframe: df=pd.DataFrame(index=[0,1]) df['timestamp'] = ['2022-01-01 20:10:00', '2022-01-01 20:50:00'] df['currency'] = ['USD', 'USD'] df['operation'] = ['deposit', 'deposit'] df['amount'] = [0.1, 0.4] df: …
MathMan 99
  • 665
  • 1
  • 7
  • 19
0
votes
1 answer

Pandas resample business days and ffill not filling

I have the following test data frame: data date 2021-03-01 3968513.99 2021-03-02 5909640.34 2021-03-03 6452578.11 2021-03-04 7260439.94 2021-03-05 6659379.74 2021-03-08 6693275.88 2021-03-09 …
Simon Nicholls
  • 635
  • 1
  • 9
  • 31
0
votes
1 answer

Grouping and sum the value for every 5min / resampling the data for 5min with string values

I want to sum the value of each gender for every 5 min timestamp. Main Table:- Time Gender value 10:01 Male 5 10:02 Female 1 10:03 Male 5 10:04 Male 5 10:05 Female 1 10:06 Female 1 10:07 Male 5 10:08 Male …
0
votes
1 answer

merging quarterly and monthly data while doing ffill on multiindex

I am trying to merge a quarterly series and a monthly series, and in the process essentially "downsampling" the quarterly series. Both dataframes contain a DATE column, BANK, and the remaining columns are various values either in a monthly or…
0
votes
1 answer

Pandas resample to return NaN when all values are NaN

I'm using resample to sum my data into hourly blocks. When all input data for the hour is NaN, resample is producing a value of 0 instead of NaN. My raw data is this: infile Out[206]: Date_time Rainfall 0 2019-02-02 14:18:00 …
georussell
  • 302
  • 1
  • 10
0
votes
0 answers

pandas: how to group by time intervals of varying length?

I know that it is possible to group your data by time intervals of the same length by using the function resample. But how can I group by time intervals of custom length (i.e. irregular time intervals)? Here is an example: Say we have a dataframe…
ixaixim
  • 83
  • 8
0
votes
1 answer

How to resample a df with multiple columns

I have a minute data for multiple requests. I would like to resample it to hourly and groupby the request so that i can get the total number of requests per hour this is how the data looks like | RequestDate | Request | Count | | 2021-11-24…
va0pjvbnd
  • 3
  • 3