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
Tags
0.5
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:
...
@@ -460,53 +460,38 @@ class DictOfSeries:
mem
+=
self
[
k
].
memory_usage
(
index
=
index
,
deep
=
deep
)
mem
+=
self
[
k
].
memory_usage
(
index
=
index
,
deep
=
deep
)
return
mem
return
mem
def
foreach
(
self
,
f
,
*
args
,
**
kwargs
):
def
apply
(
self
,
func
,
axis
=
0
,
raw
=
False
,
args
=
(),
**
kwds
):
self
.
pipe
(
f
,
*
args
,
**
kwargs
)
if
axis
in
[
1
,
'
columns
'
]:
raise
NotImplementedError
def
pipe
(
self
,
f
,
*
args
,
**
kwargs
):
"""
Call a pd.Series function on all series in the DictOfSeries
:param f: pd.Series function to apply on all Series
elif
axis
in
[
0
,
'
index
'
]:
:param args: args for the function
pass
:param kwargs: kwargs for the function
else
:
:return:
raise
ValueError
(
axis
)
"""
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.
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
):
need_dios
=
False
# fixme...
new
=
[]
if
inplace
:
for
c
in
self
.
columns
:
# self[k] may return a copy, so we need to get
s
=
func
(
self
[
c
].
values
if
raw
else
self
[
c
],
*
args
,
**
kwds
)
# the item from the dict, by our mother class.
s
=
s
.
squeeze
()
if
isinstance
(
s
,
pd
.
Series
)
else
s
return
self
.
_data
[
k
]
new
.
append
(
s
)
else
:
try
:
return
self
.
_data
.
loc
[
k
].
copy
()
if
len
(
s
)
>
1
:
need_dios
=
True
for
k
in
self
.
columns
:
except
TypeError
:
v
=
f
(
getobj
(
k
,
inplace
),
*
args
,
**
kwargs
)
pass
if
inplace
:
continue
if
isinstance
(
v
,
pd
.
Series
):
newd
[
k
]
=
v
need_dios
=
True
else
:
newd
[
k
]
=
pd
.
Series
(
data
=
v
)
news
[
k
]
=
v
if
inplace
:
return
None
if
need_dios
:
if
need_dios
:
return
newd
.
squeeze
()
dios
=
self
.
copy_empty
()
if
len
(
news
)
==
0
:
for
i
,
c
in
enumerate
(
self
.
columns
):
return
None
dios
[
c
]
=
pd
.
Series
(
new
[
i
])
return
news
.
squeeze
()
new
=
dios
else
:
new
=
pd
.
Series
(
data
=
new
,
index
=
self
.
columns
)
return
new
def
_op1
(
self
,
op
):
def
_op1
(
self
,
op
):
new
=
self
.
copy_empty
()
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