Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dios
Manage
Activity
Members
Labels
Plan
Issues
11
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RDM
dios
Commits
3d68fa56
Commit
3d68fa56
authored
5 years ago
by
Bert Palm
🎇
Browse files
Options
Downloads
Patches
Plain Diff
todos from group review
parent
0bc1cc7c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Readme.md
+1
-1
1 addition, 1 deletion
Readme.md
dios/dios.py
+12
-3
12 additions, 3 deletions
dios/dios.py
with
13 additions
and
4 deletions
Readme.md
+
1
−
1
View file @
3d68fa56
...
...
@@ -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)
This diff is collapsed.
Click to expand it.
dios/dios.py
+
12
−
3
View file @
3d68fa56
...
...
@@ -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
]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment