Skip to content
Snippets Groups Projects
Commit 3d68fa56 authored by Bert Palm's avatar Bert Palm 🎇
Browse files

todos from group review

parent 0bc1cc7c
No related branches found
No related tags found
No related merge requests found
......@@ -8,4 +8,4 @@ Features
* `dios[var]` where `var` can be a list, slice, string
* `dios[ts,var]` where `ts` can be a slice (`ts:ts`) a single timestamp, or anything pd.Series will eat
* `+,-,*,/,//,%` and `==,!=,>,>=,<=,<` and `~,&,|,^` and `is, in` implemented
* run **any** method from pd.Series on dios with `dios.pipe(pd.Series.method)` or `dios.foreach()` (simple alias)
* harm_choice **any** method from pd.Series on dios with `dios.pipe(pd.Series.method)` or `dios.foreach()` (simple alias)
......@@ -13,14 +13,15 @@ dios_options = dict(
# 0: accept all
# 1: accept if at least one key is is in both DioS
# 2: accept if all keys of the src-DioS in the dest-DioS
# 3: accept if both dios have the exact same __keys
dios_to_dios_method=0
# 3: accept if both dios have the exact same keys
dios_to_dios_method=3
)
class DictOfSeries(OrderedDict):
def __init__(self, *args, **kwargs):
# todo as property ?
self.__keys = []
super().__init__(*args, **kwargs)
......@@ -129,7 +130,7 @@ class DictOfSeries(OrderedDict):
super().__getitem__(k)[indexer] = val[k]
return
else:
err = "not all __keys from src-DioS are in the dest-DioS, "
err = "not all keys from src-DioS are in the dest-DioS, "
err += "consider changing dios.option['dios_to_dios_method']"
raise ValueError(err)
......@@ -153,6 +154,7 @@ class DictOfSeries(OrderedDict):
for k in keygen:
val = super().__getitem__(k)[indexer]
# if indexer select nothing or a scalar we up-cast it for __setitem__
# todo use Series ?
val = val if isinstance(val, pd.Series) else [val]
new[k] = val
return new.squeeze()
......@@ -318,10 +320,13 @@ class DictOfSeries(OrderedDict):
need_dios = False
# return a copy nevertheless, but also run inplace if inplace=True or
# if the function not has this option, but work inplace.
# todo: copy-kwarg
inplace = kwargs.get('inplace', False)
def getobj(k, inplace):
if inplace:
# todo make understandable / use .copy()
return super(DictOfSeries, self).__getitem__(k)
else:
return self[k]
......@@ -351,7 +356,11 @@ if __name__ == '__main__':
dios.squeeze()
print(dios)
dd = dios + dios
dios.pipe(pd.Series.squeeze)
print()
print(dd)
# dios.dropna(inplace=True)
# print(dios)
ts = None
dios['var']
dios['var', ts:ts]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment