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
e7a19f90
Commit
e7a19f90
authored
4 years ago
by
Bert Palm
🎇
Browse files
Options
Downloads
Patches
Plain Diff
exposed cast policy as property
parent
1655868d
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
+15
-8
15 additions, 8 deletions
dios/dios.py
with
15 additions
and
8 deletions
dios/dios.py
+
15
−
8
View file @
e7a19f90
...
...
@@ -37,7 +37,7 @@ from typing import Union, Any
class
DictOfSeries
:
f
"""
A data frame where every column has its own index.
"""
A data frame where every column has its own index.
DictOfSeries is a collection of pd.Series
'
s which aim to be as close as possible similar to
pd.DataFrame. The advantage over pd.DataFrame is, that every `column` has its own row-index,
...
...
@@ -62,16 +62,17 @@ class DictOfSeries:
if None, the index-type is inferred each time a series is inserted
or deleted.
cast_policy : str
{
_CAST_POLICIES
}
cast_policy : str
Policy to use for down-casting an itype.
"""
def
__init__
(
self
,
data
=
None
,
columns
=
None
,
index
=
None
,
itype
=
None
,
cast_policy
=
'
save
'
,
fastpath
=
False
):
self
.
cast_policy
=
cast_policy
# we are called internally
if
fastpath
:
self
.
_itype
=
itype
or
ObjItype
self
.
_policy
=
cast_policy
if
data
is
not
None
:
self
.
_data
=
data
else
:
...
...
@@ -94,10 +95,6 @@ class DictOfSeries:
if
itype
is
not
None
:
self
.
_itype
=
get_itype
(
itype
)
if
cast_policy
not
in
_CAST_POLICIES
:
raise
ValueError
(
f
"
downcast_policy must be one of
{
_CAST_POLICIES
}
"
)
self
.
_policy
=
cast_policy
cols
=
pd
.
Index
([]
if
columns
is
None
else
columns
)
if
not
cols
.
is_unique
:
raise
ValueError
(
"
columns must be unique
"
)
...
...
@@ -252,6 +249,16 @@ class DictOfSeries:
raise
ValueError
(
method
)
return
res
if
res
.
is_unique
else
res
.
unique
()
@property
def
cast_policy
(
self
):
return
self
.
_policy
@cast_policy.setter
def
cast_policy
(
self
,
policy
):
if
policy
not
in
_CAST_POLICIES
:
raise
ValueError
(
f
"
policy must be one of
{
_CAST_POLICIES
}
"
)
self
.
_policy
=
policy
@property
def
itype
(
self
):
if
self
.
_itype
==
'
INFER
'
:
...
...
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