Is there way to use resample.ohlc() in pandas python without losing the in between values?

Viewed 39

When I resample 1 second ticks to 1 minute I am getting 1 minute ohlc but without the in between ticks. To replay the candlestick formation I need to pass ohlc to dash in plotly but the open needs be the same for 1 minute with the hlc varying. If I try resampling to 1S it is giving ohlc but the highs & the lows & the open true for 1 second.

data_price_1m= df['Price'].astype(float).resample('1min').ohlc()
data_price_1m

                       open    high     low   close
Date_Time                                          
2022-05-25 09:20:00   96.60   97.05   95.15   96.55

2022-05-25 09:21:00   96.90   96.90   93.05   93.25

2022-05-25 09:22:00   93.40   93.40   87.20   89.00

2022-05-25 09:23:00   88.75   92.55   88.75   91.60

2022-05-25 09:24:00   91.95   91.95   88.85   89.05
data_price = df['Price'].astype(float).resample('1S').ohlc()
data_price

                       open    high     low   close
Date_Time                                          
2022-05-25 09:20:15   96.60   96.60   96.60   96.60

2022-05-25 09:20:16   96.50   96.50   96.50   96.50

2022-05-25 09:20:17   96.15   96.15   96.15   96.15

2022-05-25 09:20:18   96.15   96.15   96.15   96.15

2022-05-25 09:20:19   96.50   96.50   96.50   96.50

I am trying to get 1 min resampled values with open staying constant for 1 min & other values changing with any loss of data.

0 Answers
Related