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
1
vote
1 answer

Resample 10D but until end of months

I would like to resample a DataFrame with frequences of 10D but cutting the last decade always at the end of the month. ES: print(df)  data index 2010-01-01 145.08 2010-01-02 143.69 2010-01-03 101.06 2010-01-04 57.63 2010-01-05 …
1
vote
0 answers

DateFormatter pandas is plotting wrong dates after resampling DF Hourly

I'm trying to resample my df hourly and plot the data. However, when I resample hourly DateFormatter is plotting wrong dates and also wrong intervals. If I resample the data daily it works fine. Any idea how to solve this issue. Below you can find…
1
vote
0 answers

Leap year and grouper function

I am trying to resample my df, however using the grouper function several values are being left out in the resampling process: I have some hierarchical data from 2003 to 2020 which bottoms out into time series data which looks something like…
tillwss
  • 25
  • 5
1
vote
1 answer

Resampling with percentiles

I have a data frame with some numerical values and a date-timestamp. What I would like to do is aggregate the data into monthly intervals outputting a max percentile value for each month. What I have been doing so far is just using: df =…
Denver Dang
  • 2,433
  • 3
  • 38
  • 68
1
vote
1 answer

resample per week on monday

i want to sum two columns independently aggregated weekly(on Monday) sum by id and date. . df = pd.DataFrame({'id':['x2', 'x2', 'x1', 'x1', 'x1'], 'date':['2021-01-03','2021-01-09', '2021-01-02', '2021-01-01', '2021-01-01'], …
direction
  • 37
  • 4
1
vote
1 answer

Group by Month but only grab totals for true values in column with Pandas

I think this one is simple but I am missing how to get the data out I want. I have two fields in a dataframe called ClosedDate and Is_Article_Linked. I want to group this by ClosedDate's Month and then tally only only when Is_Article_Linked is true…
jAC
  • 3,155
  • 3
  • 18
  • 29
1
vote
1 answer

resampling a pandas dataframe from almost-weekly to daily

What's the most succinct way to resample this dataframe: >>> uneven = pd.DataFrame({'a': [0, 12, 19]}, index=pd.DatetimeIndex(['2020-12-08', '2020-12-20', '2020-12-27'])) >>> print(uneven) a 2020-12-08 0 2020-12-20 12 2020-12-27 …
Chris Withers
  • 10,837
  • 4
  • 33
  • 51
1
vote
0 answers

Pandas resample, groupby, size leads to inconsistent outputs

I have 2 dataframes df1 and df2, that are identical in structure: I ran the following command on each of the dataframes: df_grouped = df1.set_index("timestamp") # with df2 as well df_grouped =…
1
vote
1 answer

Groupby and resample at 1min frequency using forward fill in Python

I want to resample data column using forward fill ffill at the frequency of 1min while grouping df by id column: df: id timestamp data 1 1 2017-01-02 13:14:53.040 10.0 2 1 2017-01-02 16:04:43.240 …
nilsinelabore
  • 4,143
  • 17
  • 65
  • 122
1
vote
1 answer

Resample a dataframe, interpolate NaNs and return a dataframe

I have a dataframe df that contains data in periods of 3 hours: index , values 2003-01-01 00:00:00, 2.0 2003-01-01 03:00:00, 1.8 2003-01-01 06:00:00, 1.4 2003-01-01 09:00:00, 1.1 .... I want to resample the data to…
NeStack
  • 1,739
  • 1
  • 20
  • 40
1
vote
1 answer

Pandas: Is it possible to down-sample categorical column?

Let's have a DataFrame log such this one: >>> log state date_time 2020-01-01 00:00:00 0 2020-01-01 00:01:00 0 2020-01-01 00:02:00 0 2020-01-01 00:03:00 …
rad
  • 157
  • 1
  • 9
1
vote
1 answer

How to resample dates into 1 minute bars?

Say I have a pandas.DataFrame like: val 2020-01-01 12 2020-04-15 38 2020-05-03 19 How can I create a pandas.DataFrame like: val 2020-01-01 00:00:00 12 2020-01-01 00:01:00 12 ... 2020-01-01 23:58:00 …
user1367204
  • 4,549
  • 10
  • 49
  • 78
1
vote
2 answers

Pandas dataframe with datetime index resample at every nth day of month

Imagine the ohlc data indexed in DateTime. I am going to resample this dataframe on every nth day of the month. for example: . . . 2020-09-24 1.0990 1.1000 1.0982 1.0991 2020-09-25 1.1018 1.1025 1.0964 1.0995 2020-09-26 1.1011 1.1020 …
1
vote
1 answer

Resample Daily to Weekly Data

there are many posts on this subject. I went through them and I couldn't find the answer to my question: I am working on a pandas time series DataFrame. The DataFrame data is in Daily time-frame and I am aggregating it to Weekly time-frame, via the…
Bonsaye
  • 11
  • 4
1
vote
1 answer

Pandas resample only when makes sense

I have a time series that is very irregular. The difference in time, between two records can be 1s or 10 days. I want to resample the data every 1h, but only when the sequential records are less than 1h. How to approach this, without making too many…