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
13614dbc
Commit
13614dbc
authored
4 years ago
by
Bert Palm
🎇
Browse files
Options
Downloads
Patches
Plain Diff
implemented axis=1 for squeeze, all and any
parent
d5a80af4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dios/dios.py
+25
-14
25 additions, 14 deletions
dios/dios.py
with
25 additions
and
14 deletions
dios/dios.py
+
25
−
14
View file @
13614dbc
...
...
@@ -423,11 +423,20 @@ class DictOfSeries:
except
Exception
:
return
False
def
_reduce_horizontal
(
self
,
function
,
initializer_value
):
res
=
pd
.
Series
(
data
=
initializer_value
,
index
=
self
.
index_of
(
'
all
'
))
for
d
in
self
.
_data
:
base
=
res
.
loc
[
d
.
index
]
if
len
(
base
)
>
0
:
res
.
loc
[
d
.
index
]
=
function
(
base
,
d
)
return
res
def
all
(
self
,
axis
=
0
):
if
axis
in
[
0
,
'
index
'
]:
return
self
.
_data
.
apply
(
all
)
elif
axis
in
[
1
,
'
columns
'
]:
raise
NotImplementedError
func
=
lambda
s1
,
s2
:
s1
.
astype
(
bool
)
&
s2
.
astype
(
bool
)
return
self
.
_reduce_horizontal
(
func
,
True
)
elif
axis
is
None
:
return
self
.
_data
.
apply
(
all
).
all
()
raise
ValueError
(
axis
)
...
...
@@ -436,23 +445,27 @@ class DictOfSeries:
if
axis
in
[
0
,
'
index
'
]:
return
self
.
_data
.
apply
(
any
)
elif
axis
in
[
1
,
'
columns
'
]:
raise
NotImplementedError
func
=
lambda
s1
,
s2
:
s1
.
astype
(
bool
)
|
s2
.
astype
(
bool
)
return
self
.
_reduce_horizontal
(
func
,
False
)
elif
axis
is
None
:
return
self
.
_data
.
apply
(
any
).
any
()
raise
ValueError
(
axis
)
def
squeeze
(
self
,
axis
=
None
):
if
axis
in
[
0
,
'
index
'
]:
raise
NotImplementedError
if
len
(
self
)
>
1
:
if
(
self
.
lengths
==
1
).
all
():
return
self
.
_data
.
apply
(
pd
.
Series
.
squeeze
)
return
self
elif
axis
in
[
1
,
'
columns
'
]:
if
len
(
self
)
==
1
:
return
self
.
_data
.
squeeze
()
return
self
if
axis
in
[
1
,
'
columns
'
]:
return
self
.
_data
.
squeeze
()
elif
axis
is
None
:
return
self
.
_data
.
squeeze
().
squeeze
()
if
len
(
self
)
==
1
:
return
self
.
_data
.
squeeze
().
squeeze
()
if
(
self
.
lengths
==
1
).
all
():
return
self
.
_data
.
apply
(
pd
.
Series
.
squeeze
).
squeeze
()
return
self
raise
ValueError
(
axis
)
@property
...
...
@@ -590,10 +603,8 @@ class DictOfSeries:
for
c
in
self
.
columns
:
s
=
func
(
self
.
_data
.
at
[
c
].
values
if
raw
else
self
.
_data
.
at
[
c
],
*
args
,
**
kwds
)
new
.
append
(
s
)
try
:
need_dios
=
True
if
not
_is_scalar
(
s
)
else
need_dios
except
TypeError
:
pass
if
not
_is_scalar
(
s
):
need_dios
=
True
if
need_dios
:
data
=
pd
.
Series
(
dtype
=
'
O
'
,
index
=
self
.
columns
)
...
...
This diff is collapsed.
Click to expand it.
Bert Palm
🎇
@palmb
mentioned in issue
#21 (closed)
·
4 years ago
mentioned in issue
#21 (closed)
mentioned in issue #21
Toggle commit list
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