Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 468221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:39:37+00:00 2026-05-12T23:39:37+00:00

Let’s you have a science experiment called Weather and it records general information about

  • 0

Let’s you have a science experiment called Weather and it records general information about the weather, one of which is recording the humidity every minute. After say 10 hours, you’ll have 600 database values stored.

Weather.objects.filter().exclude(time__lt = commence).exclude(time__gt = cease)

This would create a filter for the Weather table, between the commence and cease times.

Let’s say the time criteria is equal to -4 hours from present, therefore it would return the last 4 hours worth of data which is equal to 300 values. How would I ask for an interval of 10? Meaning, from these 300 values, how would I receive the 10th one of each, so 10, 20, 30, 40 … 280, 290, 300… which would mean 30 values are being returned from the filter.

EDIT:

Would it be possible to ask for an interval of say 10 seconds? As opposed to each individual 10th value..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T23:39:37+00:00Added an answer on May 12, 2026 at 11:39 pm

    SQL doesn’t have a way to ask for every tenth, so ORMs won’t typically give you a way to express that need. You could do that work in Python:

    samples = list(Weather.objects.filter().exclude(time__lt=commence).exclude(time__gt=cease))
    for s10 in samples[::10]:
        # do something with every tenth...
    

    This will pull all the samples from the database in one query, then only use 10% of them. You could also pull only the ones you need, one to a query:

    sample_count = 600 # Somehow determine how many samples are in your time window.
    samples = Weather.objects.filter().exclude(time__lt=commence).exclude(time__gt=cease)
    for s_num in range(0, sample_count, 10):
        s = samples[s_num]
        # Now you have one sample in s.
    

    To elaborate: range takes three arguments, start, stop, and step. For example:

    >>> range(0, 100, 10)
    [0, 10, 20, 30, 40, 50, 60, 70, 80, 90]
    

    In the second example, the range expression is used to create the index values of the samples we want. Then samples[s_num] evaluates the QuerySet to get just that one value from the database.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say you have a class called Customer, which contains the following fields: UserName
Let's say I have a C++ Visual Studio 2010 solution with 2 projects: one
Let's say I have this string which I want to put in a multidimensional
Let's say I have a dataset, which can be neatly classified using weka's J48
Let's say I have an image called hello.png with dimensions 200x100 . I create
Let's say I have some view called My View. I know I can create
Let's consider the following scenario: a function which can generate code colors from white
Let's say i have two tables in db: Car and Part. Car owns arbitrialy
Let's assume we have the following structure: index.php config.inc.php \ lib \ lib \
Let’s say I have a number like 0x448 . In binary this is 0100

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.