GithubHelp home page GithubHelp logo

Last n minutes of a TimeSeries about pond HOT 5 OPEN

esnet avatar esnet commented on June 11, 2024
Last n minutes of a TimeSeries

from pond.

Comments (5)

pjm17971 avatar pjm17971 commented on June 11, 2024 1

No, there's not. But that seems reasonable to add. I'm assuming what you're interesting in is more like timeseries.last("15m") -> new TimeSeries than TimeRange.last("15m") -> a TimeRange?

from pond.

patrick-lewandowski avatar patrick-lewandowski commented on June 11, 2024 1

@pjm17971 Yes, something along the lines of timeseries.last("15m") would work very well! Not a priority, but nice to have feature.

from pond.

pjm17971 avatar pjm17971 commented on June 11, 2024 1

@cathal-killeen: Thanks for the offer to work on this. This one is a little tricky, because of the typescript port (#65). In particular, instead of periods (or durations) being specified as just a string, e.g. "1h" they will be a period("1d"). That constructor actually then work with either a ms duration, a string like above, a moment.duration or a moment.duration style object (as you described).

        const m = moment.duration(24, "hours");
        const p = period(m);
        expect(+p).toBe(86400000);

      // OR

        const p = period({
            seconds: 2,
            minutes: 2,
            hours: 2,
            days: 2,
            weeks: 2,
            months: 2,
            years: 2
        });
        expect(+p).toBe(69732122000);

That said, I haven't implemented this specific item. I'll ping you here when there's a branch here that you could implement that on top of without it being difficult to port over to typescript in the near future. There's a collection implementation in Typescript, but no TimeSeries on top of that yet.

It's pretty simple, because you can substract +period from the end time of the timeseries and use that time with bisect or atTime to get the index, and then slice to the end.

from pond.

patrick-lewandowski avatar patrick-lewandowski commented on June 11, 2024

This is the current way I am doing it now:

new TimeRange(moment(trafficSeries.end()).subtract(15, 'minutes'), moment(trafficSeries.end()))

Was just wondering if there is a built in method.

from pond.

cathal-killeen avatar cathal-killeen commented on June 11, 2024

Has anyone been working on this @pjm17971? I would be interested in such a feature and would love to implement it. Ideally, I think the method API should follow the various Moment duration formats. Arbitrary durations could then easily be requested, such as timeseries.last({ minutes: 15, seconds: 30 })

from pond.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.