Giter VIP home page Giter VIP logo

Comments (6)

schlunsen avatar schlunsen commented on June 2, 2024 3

Currently something like this will do the trick

Metric.
timescale.filter(device=device).filter(time__range=range).values('temperature')
.time_bucket_gapfill('time', '1 day', range[0], range[1], datapoints=1).annotate(Avg('temperature'))
.annotate(locf=Func(F('temperature'), function="locf")).order_by('time')

from django-timescaledb.

DoGab avatar DoGab commented on June 2, 2024 1

@schlunsen Thank you for the Hint. I didn't find the correct library to include.

It worked great! I have not tested it with data that are gapped but for now the query already works!

from django-timescaledb.

DoGab avatar DoGab commented on June 2, 2024

This didn't work for me. I tried to run this in a Django shell on Python 3.8.6 and get the following error:

Metrics.timescale.filter(time__range=ranges).time_bucket_gapfill('time', '1 hour', ranges[0], ranges[1], datapoints=30).annotate(Avg('loss')).annotate(locf=Func(F('loss'), function="locf"))
Traceback (most recent call last):
  File "<console>", line 1, in <module>
NameError: name 'Func' is not defined

Any idea?

from django-timescaledb.

schlunsen avatar schlunsen commented on June 2, 2024
from django.db.models import Func

from django-timescaledb.

schlunsen avatar schlunsen commented on June 2, 2024

@DoGab As I remember the query above isn't quite there yet, but it's a long time ago since I've played with it.

Really looking forward to hear if you can use it or how to do it :)

from django-timescaledb.

jacobsayer avatar jacobsayer commented on June 2, 2024

Docs are now at https://docs.timescale.com/api/latest/hyperfunctions/gapfilling-interpolation/locf/

from django-timescaledb.

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.