Python Forum
What data structure I need
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What data structure I need
#3
Thanks for the reply. I have googled it and found the rolling window although taking the .mean(), .sum() or .min() it is not what I want.
I would like to take the data set back from each rolling window. This will be representing data sets sampling that started at a random starting point.

What I also did was to write the code myself that select indexes and gets the data. It was not so easy since I am quite new but I managed to do it. It works with data periods as well.

I share the code as well and I hope it might help someone in the future.

What I miss now is how the parts of the data sets that I pick to save on a column of a new data frame and also name that column with a sequence number.

I highlight in bold below in my code the part where the data needs to be a new column in a data set. Can you help me with that?

Thanks
Alex

Code:
# There are two variable important. WindowsDuration (Duration of collected measurements
# and step, how many milliseconds the next window should shift. The step variable allow the picked 
# datasets to overlap

# set the duration of the window. For example 15 seconds to pick measurements
# Unit should be set in milliseconds
windowDuration=500

# Unit should be in milliseconds
# Next Data Collected will be starting 100ms later than the previous one
step=3000

#Initial values
# start is the time start of the specific window
# end where window ends
# these two values will be shifting by step
start=data_test.index[0]
end=data_test.index[0]+pd.Timedelta(milliseconds=windowDuration)
while start<data_test.index[-1]:
    date_mask=(data_test.index > start) & (data_test.index < end)
    dates = data_test.index[date_mask]
    print(data_test.loc[dates]) # This line picks the data.I want to store that in a new separate column.  Also name the column

    print(start)
    print(end)
    start=start+pd.Timedelta(milliseconds=step)
    end=end+pd.Timedelta(milliseconds=step)
Reply


Messages In This Thread
What data structure I need - by dervast - Apr-04-2019, 05:22 PM
RE: What data structure I need - by scidam - Apr-06-2019, 10:56 AM
RE: What data structure I need - by dervast - Apr-06-2019, 03:45 PM
RE: What data structure I need - by scidam - Apr-07-2019, 11:50 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Data structure question standenman 1 676 Jun-04-2023, 11:51 AM
Last Post: jefsummers
  Is there a better data structure than classes for a set of employes? Schlangenversteher 5 2,660 Feb-26-2020, 11:43 AM
Last Post: buran
  Data saving structure JosefFilosopio 0 2,147 May-04-2019, 10:48 AM
Last Post: JosefFilosopio
  Replacing values for specific columns in Panda data structure Padowan 1 14,701 Nov-27-2017, 08:21 PM
Last Post: Padowan

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020