-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API/ENH: create Interval class #8625
Comments
Sounds good to me. As a reminder: here is the Let's consider whether you should be able to control whether the level and right margins are closed/open separately or if you should only be able to say |
you could also do
|
Idea: Then...
could subclass and create ...but individually they would repr to |
One follow up thought: if we support |
Why this verbose repr? In repr of a dataframe (as index or values), I would expect that I only get the "short" repr... |
The problem is ambiguity with list and tuple, at least as long as the array has dtype=object. On Tue, Oct 28, 2014 at 2:56 AM, Jan Schulz notifications@github.com
|
Could clear up the ambiguity with dash ( or even double dash ). Nobody should confuse "(0 - 2)" with a tuple. Nor would "[0 - 2]" be confused with a list. |
Fixes pandas-dev#7640, pandas-dev#8625 This is a work in progress, but it's far enough along that I'd love to get some feedback. TODOs (more called out in the code): - [ ] documentation + docstrings - [ ] finish the index methods: - [ ] `get_loc` - [ ] `get_indexer` - [ ] `slice_locs` - [ ] comparison operations - [ ] fix `is_monotonic` (pending pandas-dev#8680) - [ ] ensure sorting works - [ ] arithmetic operations (not essential for MVP) - [ ] cythonize the bottlenecks: - [ ] `from_breaks` - [ ] `_data` - [ ] `Interval`? - [ ] `MultiIndex` - [ ] `Categorical`/`cut` - [ ] serialization - [ ] lots more tests CC @jreback @cpcloud @immerrr
Rough draft implementation up for review in #8707. Turns out We could also have a |
+1 for |
Here's another design question: how should comparison operations work with intervals? My initial thought was to support all comparisons operations, but when I attempted to write it, I realized that it's not obvious to me what the result of So, my current proposal is that we do not actually want to support support most comparisons with intervals. Instead, we should encourage users to write things like |
sure though you will need to provide an ordering in used for IntervalIndex eg imagine spitting these though it's sort of trivial: i = IntervalIndex(...) |
So after testing out this alternative, I have now waffled back to defining comparison operations -- otherwise we can't get sorting to work, even in cases of non-overlapping intervals. I would like set operations like union to be able to sort, at least in unambiguous cases, and I don't see any other obvious way to do this. @jreback I'm not sure I understand your point about take. |
closes pandas-dev#7640 closes pandas-dev#8625
closes pandas-dev#7640 closes pandas-dev#8625
closes pandas-dev#7640 closes pandas-dev#8625
closes pandas-dev#7640 closes pandas-dev#8625
closes pandas-dev#7640 closes pandas-dev#8625
closes pandas-dev#7640 closes pandas-dev#8625
closes pandas-dev#7640 closes pandas-dev#8625
closes pandas-dev#7640 closes pandas-dev#8625
closes pandas-dev#7640 closes pandas-dev#8625
closes pandas-dev#7640 closes pandas-dev#8625
closes pandas-dev#7640 closes pandas-dev#8625
closes pandas-dev#7640 closes pandas-dev#8625
closes pandas-dev#7640 closes pandas-dev#8625
closes pandas-dev#7640 closes pandas-dev#8625
closes pandas-dev#7640 closes pandas-dev#8625
closes pandas-dev#7640 closes pandas-dev#8625
closes pandas-dev#7640 closes pandas-dev#8625
closes pandas-dev#7640 closes pandas-dev#8625
closes pandas-dev#7640 closes pandas-dev#8625
closes pandas-dev#7640 closes pandas-dev#8625
closes pandas-dev#7640 closes pandas-dev#8625
closes pandas-dev#7640 closes pandas-dev#8625
closes pandas-dev#7640 closes pandas-dev#8625
closes pandas-dev#7640 closes pandas-dev#8625
closes pandas-dev#7640 closes pandas-dev#8625
xref #8595
something like:
Interval(left=(-1.5,'open),right=(0,'closed'))
reprs to
(-1.5,0]
can be used immediately in the index values for
pd.cut
and such (as an object index)evenutally can form the basis for
IntervalIndex
cc @shoyer
cc @JanSchulz
cc @rosnfeld
The text was updated successfully, but these errors were encountered: