10
10
11
11
12
12
class BitemporalStore (object ):
13
- """ A versioned pandas DataFrame store. (currently only supports single index df)
13
+ """ A versioned pandas DataFrame store.
14
14
15
15
As the name hinted, this holds versions of DataFrame by maintaining an extra 'insert time' index internally.
16
16
"""
@@ -22,8 +22,8 @@ def __init__(self, version_store, observe_column='observed_dt'):
22
22
version_store : `VersionStore`
23
23
The version store that keeps the underlying data frames
24
24
observe_column : `str`
25
- Column name for the datetime index that represents the insertion time of a row of data. This column is
26
- internal to this store.
25
+ Column name for the datetime index that represents the insertion time of a row of data. Unless you intent to
26
+ read raw data out, this column is internal to this store.
27
27
"""
28
28
self ._store = version_store
29
29
self .observe_column = observe_column
@@ -48,16 +48,17 @@ def read(self, symbol, as_of=None, raw=False, **kwargs):
48
48
BitemporalItem namedtuple which contains a .data and .metadata element
49
49
"""
50
50
item = self ._store .read (symbol , ** kwargs )
51
+ last_updated = max (item .data .index .get_level_values (self .observe_column ))
51
52
if raw :
52
53
return BitemporalItem (symbol = symbol , library = self ._store ._arctic_lib .get_name (), data = item .data ,
53
54
metadata = item .metadata ,
54
- last_updated = max ( item . data . index , key = lambda x : x [ 1 ]) )
55
+ last_updated = last_updated )
55
56
else :
56
57
index_names = list (item .data .index .names )
57
58
index_names .remove (self .observe_column )
58
59
return BitemporalItem (symbol = symbol , library = self ._store ._arctic_lib .get_name (),
59
60
data = groupby_asof (item .data , as_of = as_of , dt_col = index_names , asof_col = self .observe_column ),
60
- metadata = item .metadata , last_updated = max ( item . data . index , key = lambda x : x [ 1 ]) )
61
+ metadata = item .metadata , last_updated = last_updated )
61
62
62
63
def update (self , symbol , data , metadata = None , upsert = True , as_of = None , ** kwargs ):
63
64
""" Append 'data' under the specified 'symbol' name to this library.
0 commit comments