I’d like to calculate a lagged rolling average on a complicated time-series dataset. Consider the toy example as follows: This results in the following DataFrame: Now I’d like to add a column representing the average weight per fruit for the previous 7 days: wgt_per_frt_prev_7d. It should be defined as the sum of all the fruit weights divided by the sum
Tag: time-series
Extrapolating time series data into the future by repeating/scaling existing values
I have hourly data on electricity consumption for a specific day. I would like to use this data to “predict” the hourly electricity consumption for the following days. The value for the following day should be the value from the same hour the day before, multiplied by a scaling factor f (e.g. 2). The dataframe df that I have looks
Pivot matrix to time-series – Python
I’ve got a dataframe with date as first column and time as the name of the other columns. Date 13:00 14:00 15:00 16:00 … 2022-01-01 B R M M … 2022-01-02 B B B M … 2022-01-03 R B B M … How could I transform that matrix into a datetime time-series? My objective its something like this: Date Data
Strange results when scaling data using scikit learn
I have an input dataset that has 4 time series with 288 values for 80 days. So the actual shape is (80,4,288). I would like to cluster differnt days. I have 80 days and all of them have 4 time series: outside temperature, solar radiation, electrical demand, electricity prices. What I want is to group similar days with regard to
Downsampling time series data in pandas
I have timeseries data that looks like this: I would like to downsample my data from 15-minute frequencies to 1-hour frequencies. So, the first 4 rows above would be summed under 00:00 timestamp, then next 4 rows would be combined under 01:00. Is there an efficient way to make this happen? Answer Look at pandas.DataFrame.resample would result in All you
Combining weeks 52 and 0 with Python Datetime
I have a Pandas DataFrame with daily data that I’m trying to group by week number to sum some columns, and I notice that when years do not begin on Sunday, the data for the week spanning the end of one year and the beginning of the next do not cleanly sum, instead being broken into two groups. My code
Error with Pipeline for fourier featurizer
When I run above code. I get following error: TypeError: Last step of Pipeline should be of type BaseARIMA. ‘FourierFeaturizer(k=1, m=14)’ I don’t wish to use BaseARIMA. Just wish to use FourierFeaturizer is it possible? Answer Yes, it’s possible. Each FourierFeaturizer has a fit_transform method, which returns the y var and new exogenous variables. By concatenating this return value, you
Pandas Aggregate Daily Data to Monthly Timeseries
I have a time series that looks like this (below) And I want to resample it monthly, so it has 2019-10 is equal to the average of all the values of october, November is the average of all the PTS values for November, etc. However, when i use the pd.resample(‘M’).mean() method, if the final day for each month does not
Add averages to existing plot with pandas.DataFrame
I have a pandas data-frame of the form and I want to plot the last 7 days together with the average over the weekdays. I can create / plot the average by using and I can create / plot the last 7 days by using but I fail to combine them to a single plot since the average uses weekday
Is there any function to get multiple timeseries with .get and create a dataframe in Pandas?
I get multiple time series data in series format with datetimeindex, which I want to resample and convert to a dataframe with multiple columns with each column representing each time series. I am using separate functions to create the dataframe, for example, .get(), .resample(), pd.concat(). Since it is not following the DRY principle (Don’t Repeat Yourself) and I can be