question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ENH: Arithmetic operations on intervals

See original GitHub issue

Is your feature request related to a problem?

I would like to be able to do arithmetic operations on intervals:

  • a + b: pd.Interval(3, 6) + pd.Interval(5, 7) == pd.Interval(3, 7)
  • a - b: pd.Interval(3, 6) - pd.Interval(5, 7) == pd.Interval(3, 5)
  • [a, b].union() / np.sum([a, b]):
    intervals = pd.arrays.IntervalArray.from_tuples([(0, 1), (1, 3), (2, 4), (5, 7)])
    intervals.sum() == pd.arrays.IntervalArray.from_tuples([(0, 4), (5, 7)])
    

API breaking implications

None AFAIK, since those methods are not implemented yet

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
venaturumcommented, Oct 9, 2021

@Hoeze I’ve taken the above concepts with staircase and created a new package “piso” for set operations over pandas.Interval, pandas.arrays.IntervalArray and pandas.IntervalIndex.

https://piso.readthedocs.io

It’s currently available through pypi. Will continue to expand the functionality over the coming weeks.

2reactions
venaturumcommented, Sep 18, 2021

@Hoeze I developed a package called staircase which allows a lot of manipulations with intervals and is designed to be closely aligned with pandas. You may find it handy? www.staircase.dev

Read more comments on GitHub >

github_iconTop Results From Across the Web

4.7 Interval arithmetic
Interval techniques, primarily interval Newton's methods combined with bisection to ensure convergence, have been the focus of significant attention, see for ...
Read more >
(PDF) Interval Arithmetic: from Principles to Implementation
The main idea is that, given a function f (x) and representing x as an interval with a lower and upper bound, the...
Read more >
Interval Ranges of Fuzzy Sets Induced by Arithmetic ... - MDPI
Based on the use of an interval range, he introduced the arithmetic operations of fuzzy sets in R by using gradual sets and...
Read more >
Interval type should support intersection, union & overlaps ...
We have the Interval type in pandas, which is extremely useful, however the standard interval arithmetic operations are missing from the pandas ...
Read more >
Interval arithmetic - Wikipedia
Interval arithmetic is a mathematical technique used to put bounds on rounding errors and measurement errors in mathematical computation.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found