0

I am working on a dataset about crypto currency and i want to calculate slope based on different range of data in different time range

from scipy.stats import linregress
slope, intercept, r_value, p_value, std_err = linregress(X, y) 

X is price of BTC in all time and y is the timestamp.

I want to calculate the slope in range of 7 days and 21 days. How should I do it? I don't know the exact amount of days every time and I want to make 7 or 21 series back to back and if it is less than 7 or 21 days, it should calculate with the fewer amount of days.

desertnaut
  • 57,590
  • 26
  • 140
  • 166
  • 1
    Your question is missing a reproducible example (input + expected output) – mozway Aug 24 '22 at 09:19
  • `pandas` should have function to get data in some `range of dates`. It may also use `range of dates` in `rolling window` which can be useful for calculating values. – furas Aug 24 '22 at 11:16
  • [python - Pandas: rolling mean by time interval - Stack Overflow](https://stackoverflow.com/questions/15771472/pandas-rolling-mean-by-time-interval) – furas Aug 24 '22 at 11:17
  • i can't access each row of a rolling object – shayanTH78 Aug 25 '22 at 06:23

0 Answers0