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
e06aa5a0
Commit
e06aa5a0
authored
5 years ago
by
Bert Palm
🎇
Browse files
Options
Downloads
Patches
Plain Diff
creation with named series and columns fix
parent
0b51b177
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
+11
-5
11 additions, 5 deletions
dios/dios.py
with
11 additions
and
5 deletions
dios/dios.py
+
11
−
5
View file @
e06aa5a0
...
...
@@ -97,7 +97,7 @@ class DictOfSeries:
self
.
_data
=
pd
.
Series
(
dtype
=
'
O
'
,
index
=
index
.
unique
())
if
data
is
not
None
:
self
.
_init_insert_data
(
data
,
columns
)
self
.
_init_insert_data
(
data
)
# self._data contain nans at locations, where no
# data was present, but a column-name was given
...
...
@@ -116,23 +116,29 @@ class DictOfSeries:
self
.
_data
.
name
=
'
_data
'
self
.
_data
.
index
.
name
=
'
columns
'
def
_init_insert_data
(
self
,
data
,
columns
):
def
_init_insert_data
(
self
,
data
):
"""
Insert items of a iterable in self
"""
data
=
list
(
data
)
if
_is_iterator
(
data
)
else
data
cols_empty
=
self
.
columns
.
empty
if
isinstance
(
data
,
dict
)
or
_is_dios_like
(
data
):
for
k
in
data
:
if
col
umns
is
None
or
k
in
self
.
columns
:
if
col
s_empty
or
k
in
self
.
columns
:
self
.
_insert
(
k
,
data
[
k
])
elif
isinstance
(
data
,
pd
.
Series
):
self
.
_insert
(
data
.
name
or
0
,
data
)
name
=
data
.
name
or
0
if
not
cols_empty
:
# overwrite by columns
if
data
.
name
is
None
or
data
.
name
not
in
self
.
columns
:
name
=
self
.
columns
[
0
]
self
.
_insert
(
name
,
data
)
elif
_is_list_like
(
data
):
data
=
data
if
_is_nested_list_like
(
data
)
else
[
data
]
if
self
.
columns
.
empty
:
if
cols_
empty
:
self
.
_data
=
pd
.
Series
(
dtype
=
'
O
'
,
index
=
pd
.
RangeIndex
(
len
(
data
)))
elif
len
(
data
)
!=
len
(
self
.
columns
):
...
...
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