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
0 answers

pandas resample - issue with epoch and frequency

I'd like to get a time series with a fixed set of dates in the index. I thought that resample with freq and epoch='origin' will do the trick. It seems that I'm using this method in a wrong way. Here's an example that shows that epoch='origin' does…
Grzegorz Rut
  • 205
  • 1
  • 2
  • 8
0
votes
1 answer

Regrouping and resampling days/months from different years

My data looks like this: Date Value 2011-01-01 09:00 1 2011-01-01 10:00 2 2011-02-18 09:00 3 ... 2017-01-28 07:00 4 What I need is the average for each month (January, February.. etc) over the years so output should…
boozi
  • 468
  • 1
  • 3
  • 16
0
votes
0 answers

Want to add new column to a pandas dataframe after resampling the api tick data

I have a program that convert api live tick data to a 15 Sec time Dataframe. But in the new dataframe some old columns are missing which is very much necessary from my further work. How can fetch those old columns to my new dataframe. I want to add…
0
votes
0 answers

Pandas: a must be greater than 0 unless no samples are taken

I am trying to resample the rebalanced data set 'churn_train' by 20%, or n = 158 records, to have 'True' 'Churn' column values. I am receiving an error message. The data set is not empty as I determined the shape and value counts of it. How do I…
c200402
  • 153
  • 1
  • 10
0
votes
2 answers

How to prevent resample -> aggregate from dropping columns?

Code df = pd.DataFrame( data = {'A': [1, 1, 2], 'B': [None, None, None]}, index = pd.DatetimeIndex([ '1990-01-01 00:00:00', '1990-01-01 12:00:00', '1990-01-02 12:00:00' …
actual_panda
  • 1,178
  • 9
  • 27
0
votes
1 answer

Pandas replace daily observations by monthly mean

Suppose, I have a pandas Series with daily observations: pd_series = pd.Series(np.random.rand(26281), index = pd.date_range('2022-01-01', '2024-12-31', freq = 'H')) pd_series 2022-01-01 00:00:00 0.933746 2022-01-01 01:00:00 0.588907 2022-01-01…
W. Walter
  • 337
  • 1
  • 10
0
votes
1 answer

Resample a dataframe with different aggregate functions

I have a data frame like the below, which has a 'Stats' column containing different statistical values(avg, count, min, max) for every 1-sec timestamp. Timestamps Location Service Status…
sherin_a27
  • 153
  • 8
0
votes
1 answer

When I do pd.read_csv('FileName.csv', index_col=[0], parse_dates = [0]) it's different from pd.read_csv('FileName.csv'), when I do .dtypes(), why?

When I do pd.read_csv('FileName.csv'), I get the time column separate along with the rest of the data as shown: When I do pd.read_csv('FileName.csv', , index_col=[0], parse_dates = [0]), knowing time in my data is index 0,I get this: I checked the…
Moody
  • 35
  • 1
  • 8
0
votes
1 answer

Resample datetime - Error: cannot reindex a non-unique index with a method or limit

Would you help me with the following error: ValueError: cannot reindex a non-unique index with a method or limit Let's say I have a dataframe df datetime A B C 2020-07-02 23:00:01 50 nan nan 2020-07-02 23:00:02 …
Tessa
  • 53
  • 6
0
votes
1 answer

Resampled data not matching in Pandas

Not able to get the same results with resampled data. For example: import yfinance as yf import pandas as pd df = yf.download('f', interval = '1mo') df = df[~df.index.duplicated(keep='last')] # df = df.resample('CM').mean() df['pct'] =…
Slartibartfast
  • 1,058
  • 4
  • 26
  • 60
0
votes
1 answer

Resample a dataframe with n day window

I know I can resample daily data, by month, like this: df = data.resample('M') But how do I resample by an arbitrary length, say 180? df = data.resample('Days', 180) # six months # I am just guessing here
Ivan
  • 7,448
  • 14
  • 69
  • 134
0
votes
1 answer

IndexingError when using custom func through apply on resampled object

I'm trying to deploy a custom function using apply on a resampled object. The tricky part in the function is that it loops across each timestamp of the passed dataframe and performs operations based on values of other columns for that timestamp. …
matsuo_basho
  • 2,833
  • 8
  • 26
  • 47
0
votes
0 answers

regarding controlling the setup of index column

I have a data frame, data_plot looks like the following, After operating the data_plot as follows data_plot['Time'] = pd.to_datetime(data_plot['Time']) df = data_plot.resample('M', on='Time').sum() I got df as follows, the Time column has become…
user785099
  • 5,323
  • 10
  • 44
  • 62
0
votes
1 answer

Pandas Resample OHCL

index close 2022-02-21 3 2022-02-22 1 2022-02-23 5 2022-02-24 5 2022-02-25 7 2022-03-02 4 2022-03-03 2 2022-03-04 1 My output should be: index close 2022-02-21 7 2022-03-02 1 I have tried df.resample('W-MON',…
p.magalhaes
  • 7,595
  • 10
  • 53
  • 108
0
votes
0 answers

Python-Pandas type error when attempting to resample

I have a temperature and solar radiation timeseries saved as a csv file. For some reason when I resample "sRad", there is a type error that states it can only concatenate str (not "int") to str. But I do not have this error when I resampled…
Yogi
  • 45
  • 6