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
c33b1084
Commit
c33b1084
authored
4 years ago
by
Bert Palm
🎇
Browse files
Options
Downloads
Patches
Plain Diff
added missing basic dict methods
parent
92e23268
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dios/dios.py
+47
-0
47 additions, 0 deletions
dios/dios.py
with
47 additions
and
0 deletions
dios/dios.py
+
47
−
0
View file @
c33b1084
...
...
@@ -729,6 +729,53 @@ class DictOfSeries:
__or__
=
ftools
.
partialmethod
(
_op2
,
op
.
or_
)
__xor__
=
ftools
.
partialmethod
(
_op2
,
op
.
xor
)
# dict-like methods
def
clear
(
self
):
d
=
self
.
_data
self
.
_data
=
pd
.
Series
(
dtype
=
d
.
dtype
,
index
=
type
(
d
.
index
)([]))
def
get
(
self
,
key
,
default
=
None
):
return
self
.
_data
.
get
(
key
,
default
)
def
items
(
self
):
return
self
.
_data
.
items
()
def
keys
(
self
):
return
self
.
columns
def
pop
(
self
,
*
args
):
# We support a default value, like dict, in contrary to pandas.
# Therefore we need to handle args manually, because dict-style pop()
# differ between a single arg and a tuple-arg, with arg and default,
# where the second arg can be anything, including None. If the key is
# not present, and a single arg is given, a KeyError is raised, but
# with a given default value, it is returned instead.
if
len
(
args
)
==
0
:
raise
TypeError
(
"
pop expected at least 1 arguments, got 0
"
)
if
len
(
args
)
>
2
:
raise
TypeError
(
f
"
pop expected at most 2 arguments, got
{
len
(
args
)
}
"
)
key
,
*
rest
=
args
if
key
in
self
.
columns
:
return
self
.
_data
.
pop
(
key
)
elif
rest
:
return
rest
.
pop
()
raise
KeyError
(
key
)
def
popitem
(
self
):
last
=
self
.
columns
[
-
1
]
return
last
,
self
.
_data
.
pop
(
last
)
def
setdefault
(
self
,
key
,
default
=
None
):
if
key
not
in
self
.
columns
:
self
.
_insert
(
key
,
default
)
return
self
.
_data
[
key
]
def
update
(
self
,
other
):
if
not
_is_dios_like
(
other
):
other
=
to_dios
(
other
)
self
.
aloc
[
other
,
...]
=
other
def
_empty_repr
(
di
):
return
f
"
Empty DictOfSeries
\n
"
\
...
...
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