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

Trouble resampling pandas timeseries from 1min to 5min data

I have a 1 minute interval intraday stock data which looks like this: import yfinance as yf import pandas as pd n = yf.download('^nsei', period= '5d', interval= '1m') I am trying to resample it to '5m' data like this: n =…
Raj Nair
  • 85
  • 1
  • 6
1
vote
1 answer

pandas OHLC aggregation resample with time of OHLC

I am converting 1 minute candle to 5 minute candle as below: df = df.resample("5min").agg({ 'stock_name': 'first', 'tr_open': 'first', 'tr_high': 'max', 'tr_low': 'min', 'tr_close': 'last' }) For some reason, I need the time when OHLC values…
Sumanth Lingappa
  • 464
  • 1
  • 6
  • 15
1
vote
2 answers

aggregate and distribute time series data

I have some time series data in a pandas data frame like this: begin end mw_values 2021-09-14 11:16:00 2021-09-14 11:27:11 0 2021-09-14 11:27:11 2021-09-14 11:30:00 100 2021-09-14 11:30:00 2021-09-14 11:33:59 1200 2021-09-14…
1
vote
1 answer

OHLC of Multiple Scrips Using Pandas Resample function

I have ticks data of 2 scrips (scrip_names are abc and xyz). Since the ticks data is at a "second" level, I want to convert this to OHLC (Open, High, Low, Close) at 1 Minute level. When the ticks data contains only 1 scrip, I use the following code…
lenmet
  • 33
  • 1
  • 7
1
vote
1 answer

pandas possible bug with groupby and resample

I am a newbie in pandas and seeking advice if this is a possible bug? Dataframe with non unique datetime index. Col1 is a group variable, col2 is values. i want to resample the hourly values to years and grouping by the group variable. i do this…
1
vote
1 answer

How do I resample to 5 min correctly

I am trying to resample 1 min bars to 5 min but I am getting incorrect results. 1 min data: I am using this to resample: df2.resample("5min").agg({'open':'first', 'high':'max', 'low:'min', …
ManInMoon
  • 6,795
  • 15
  • 70
  • 133
1
vote
1 answer

Fill gaps in time series pandas dataframe in specific time intervall

I already asked a related question filling gaps in time series Fill Gaps in time series pandas dataframe and Akshay Sehgal was kind enough to give a good a detailed answer! However I found another problem with my data. Tha following code now works…
Chris Bauer
  • 63
  • 1
  • 6
1
vote
1 answer

How to resample pandas Dataframe time series data from 8hz to 16hz?

I have time series data in pandas Dataframe with a 8hz sampling rate, i.e. 8 samples per second. I need to convert it to 16 hz data i.e. 16 samples per second. the index is in first column, in the format yyyy-mm-dd hh:mm:ss.ssssss. I am unable to…
user5349
  • 123
  • 7
1
vote
1 answer

December/January Seasonal Mean

I am attempting to calculate the seasonal means for the winter months of DJF and DJ. I first tried to use Xarray's .groupby function: ds.groupby('time.month').mean('time') Then I realized that instead of grouping by the previous years' December…
1
vote
0 answers

resample dataset with one irregular datetime

I have a dataframe like the following. I wanted to check the values for each 15minutes. But I see that there is a time at 09:05:51. How can I resample the dataframe for 15minutes? hour_min value 06:30:00 0.0 06:45:00 …
GeoBeez
  • 920
  • 2
  • 12
  • 20
1
vote
1 answer

Failing to resample daily data to weekly and can't apply logic

I'm trying to use the following code to convert daily OHLCV data to weekly: #resample so that Open is the first monday price, High and low are the weeks min and max and close is the last sunday price and volume is the sum (can be customized - pandas…
user14009897
1
vote
1 answer

Keep column when resampling hourly to daily data in pandas

I have a dataset of hourly weather observations in this format: df = pd.DataFrame({ 'date': ['2019-01-01 09:30:00', '2019-01-01 10:00', '2019-01-02 04:30:00','2019-01-02 05:00:00','2019-07-04 02:00:00'], 'windSpeedHigh':…
1
vote
2 answers

Copying and appending rows to a dataframe with increment to timestamp column by a minute

Here is the dataframe I have: df = pd.DataFrame([[pd.Timestamp(2017, 1, 1, 12, 32, 0), 2, 3], [pd.Timestamp(2017, 1, 2, 12, 32, 0), 4, 9]], columns=['time', 'feature1', 'feature2']) For every timestamp value found in…
Sushanth
  • 2,224
  • 13
  • 29
1
vote
1 answer

Conditional count per day from pandas dataframe

I have a dataset with a reading (Tank Level) every minute from a piece of equipment and want to create a new dataset (dataframe) with a count of the number of samples per day and the number of readings above a set value. Noxious Tank…
ChemEnger
  • 131
  • 12