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 8141679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:35:32+00:00 2026-06-06T12:35:32+00:00

I need a data structure which can handle the following: date_from (datetime) date_to (datetime)

  • 0

I need a data structure which can handle the following:

date_from (datetime)
date_to (datetime)
value (float)

…and I need to be able to ‘query’ this data structure based on a datetime (e.g. in pseudocode: SELECT * FROM data_structure WHERE a_datetime >= date_from AND a_datetime <= date_to;).

If there isn’t a result from this ‘query’, I would need to be able to insert a new value into the data structure.

What’s the best way of doing this? (I’m a bit stuck at the moment)

  • 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-06-06T12:35:35+00:00Added an answer on June 6, 2026 at 12:35 pm

    Have a look at this SortedCollection Recipe. It uses the bisect module and lets you created a keyed collection. E.g.:

    >>> from SortedCollection import SortedCollection
    >>> from operator import itemgetter
    >>> s = SortedCollection(key=itemgetter(0))
    >>> s.insert((1,2,'a'))
    >>> s.insert((10,20,'b'))
    >>> s.insert((20,30,'c'))
    >>> s.find_le(10)
    (10, 20, 'b')
    

    May help you create your cache of time period information, the bisect approach should let you access your date-keyed information efficiently.

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

Sidebar

Related Questions

I need a data structure which will support the following operations in a performant
I am planning to work in TRIE data structure for which I need a
I need to have data structure, each element in which is accessible by pair
I am beginner in C++, I need to know which data structure to store
I need to design a data structure that supports the following operations: search element
I need to write a data structure that can return a different Price for
Is there an R data structure into which I can store a number of
I am in need of a Javascript data structure which will allow me to
I need a data structure in which I want to store information about which
I need a data structure that acts like a SortedDictionary<int, double> but is sorted

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.