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
1a061136
Commit
1a061136
authored
5 years ago
by
Bert Palm
🎇
Browse files
Options
Downloads
Patches
Plain Diff
apply
parent
029aef2e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2
Develop
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dios/dios.py
+27
-42
27 additions, 42 deletions
dios/dios.py
with
27 additions
and
42 deletions
dios/dios.py
+
27
−
42
View file @
1a061136
...
...
@@ -460,53 +460,38 @@ class DictOfSeries:
mem
+=
self
[
k
].
memory_usage
(
index
=
index
,
deep
=
deep
)
return
mem
def
foreach
(
self
,
f
,
*
args
,
**
kwargs
):
self
.
pipe
(
f
,
*
args
,
**
kwargs
)
def
pipe
(
self
,
f
,
*
args
,
**
kwargs
):
"""
Call a pd.Series function on all series in the DictOfSeries
def
apply
(
self
,
func
,
axis
=
0
,
raw
=
False
,
args
=
(),
**
kwds
):
if
axis
in
[
1
,
'
columns
'
]:
raise
NotImplementedError
:param f: pd.Series function to apply on all Series
:param args: args for the function
:param kwargs: kwargs for the function
:return:
"""
news
=
pd
.
Series
()
newd
=
self
.
copy_empty
()
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.
elif
axis
in
[
0
,
'
index
'
]:
pass
else
:
raise
ValueError
(
axis
)
inplace
=
kwargs
.
get
(
'
inplace
'
,
False
)
or
kwargs
.
get
(
'
copy
'
,
False
)
# we cannot use self._data.apply(func=func, args=args, **kwds)
# because this may return a df
def
getobj
(
k
,
inplace
):
# fixme...
if
inplace
:
# self[k] may return a copy, so we need to get
# the item from the dict, by our mother class.
return
self
.
_data
[
k
]
else
:
return
self
.
_data
.
loc
[
k
].
copy
()
for
k
in
self
.
columns
:
v
=
f
(
getobj
(
k
,
inplace
),
*
args
,
**
kwargs
)
if
inplace
:
continue
if
isinstance
(
v
,
pd
.
Series
):
newd
[
k
]
=
v
need_dios
=
True
else
:
newd
[
k
]
=
pd
.
Series
(
data
=
v
)
news
[
k
]
=
v
need_dios
=
False
new
=
[]
for
c
in
self
.
columns
:
s
=
func
(
self
[
c
].
values
if
raw
else
self
[
c
],
*
args
,
**
kwds
)
s
=
s
.
squeeze
()
if
isinstance
(
s
,
pd
.
Series
)
else
s
new
.
append
(
s
)
try
:
if
len
(
s
)
>
1
:
need_dios
=
True
except
TypeError
:
pass
if
inplace
:
return
None
if
need_dios
:
return
newd
.
squeeze
()
if
len
(
news
)
==
0
:
return
None
return
news
.
squeeze
()
dios
=
self
.
copy_empty
()
for
i
,
c
in
enumerate
(
self
.
columns
):
dios
[
c
]
=
pd
.
Series
(
new
[
i
])
new
=
dios
else
:
new
=
pd
.
Series
(
data
=
new
,
index
=
self
.
columns
)
return
new
def
_op1
(
self
,
op
):
new
=
self
.
copy_empty
()
...
...
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