Skip to content

Commit 2b05530

Browse files
committed
Add missing _where_index.py
1 parent df0f5d1 commit 2b05530

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class WhereIndex(list):
2+
"""Primarily serves as a list-like object that is returned with where-like
3+
operations:
4+
5+
where_index = dm[dm.col == 1]
6+
7+
However, for compariblity with dataframe, this list-like object should also
8+
be able to provide access to columns, like so:
9+
10+
dm[dm.col == 1]['col'] = 2
11+
"""
12+
def __init__(self, dm, values):
13+
self._dm = dm
14+
super().__init__(values)
15+
16+
def __getitem__(self, key):
17+
if not isinstance(key, int):
18+
return self._dm[key]
19+
return key

0 commit comments

Comments
 (0)