Comments (6)
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.
@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.
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.
from django.db.models import Func
from django-timescaledb.
@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.
Docs are now at https://docs.timescale.com/api/latest/hyperfunctions/gapfilling-interpolation/locf/
from django-timescaledb.
Related Issues (20)
- Roadmap Proposal HOT 3
- FR: Add support for time_bucket offset and origin parameters HOT 2
- Failure in `time_bucket()` invocation on TimescaleQuerySet HOT 6
- FR: LTTB feature implementation
- Cannot drop constraint because other objects depend on it
- Getting psycopg2.DatabaseError: cannot create a unique index without the column "time" (used in partitioning) HOT 3
- FR: Support for time_bucket_ng
- Add partitioning_column
- rename variable in sql_add_hypertable string
- Add auto_now_add for time field? HOT 1
- time_bucket_gapfill does not support running without datapoints param. HOT 1
- Custom Admin to plot time-series
- Is it absolutely necessary to name the field "time" ? HOT 2
- Implement interpolate() functionality
- Error with compression and django pytests
- Incorrect function location
- TimeBucket does not allow for extra arguments allowed by timescaledb HOT 1
- Settings not found in python manage.py migrate HOT 1
- pkey name overflow happened if table name length is more than 58 symbols
- primary key / unique behavior and index creation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-timescaledb.