Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Leipzig Machine Learning Group
conML
python
Commits
77e00eb7
Commit
77e00eb7
authored
5 years ago
by
dmt
Browse files
Options
Downloads
Patches
Plain Diff
Get overlapping data samples through joins.
parent
7c2a71c3
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cml/ports/source_adapters.py
+27
-1
27 additions, 1 deletion
cml/ports/source_adapters.py
with
27 additions
and
1 deletion
cml/ports/source_adapters.py
+
27
−
1
View file @
77e00eb7
...
@@ -63,6 +63,10 @@ class PandasBlock:
...
@@ -63,6 +63,10 @@ class PandasBlock:
def
__len__
(
self
):
def
__len__
(
self
):
return
self
.
__data_block
.
shape
[
0
]
return
self
.
__data_block
.
shape
[
0
]
@property
def
data_block
(
self
):
return
self
.
__data_block
def
has_nan
(
self
):
def
has_nan
(
self
):
return
self
.
__data_block
.
isna
().
any
()[
0
]
return
self
.
__data_block
.
isna
().
any
()[
0
]
...
@@ -188,6 +192,28 @@ class PandasBlock:
...
@@ -188,6 +192,28 @@ class PandasBlock:
self
.
__data_block
.
drop
(
remove_columns
,
axis
=
1
,
inplace
=
True
)
self
.
__data_block
.
drop
(
remove_columns
,
axis
=
1
,
inplace
=
True
)
def
get_overlapping
(
self
,
block
,
on
=
None
):
if
len
(
block
)
<
len
(
self
):
biggest
=
block
block
=
self
else
:
biggest
=
self
block
=
block
join
=
biggest
.
data_block
.
join
(
block
.
data_block
.
set_index
(
"
T
"
),
on
=
"
T
"
,
lsuffix
=
"
_other
"
,
how
=
"
inner
"
)
for
column
in
join
.
columns
:
if
column
not
in
(
"
T
"
,
"
Z
"
,
"
Z_other
"
):
join
.
drop
(
column
,
axis
=
1
,
inplace
=
True
)
join
=
join
[[
"
Z
"
,
"
Z_other
"
,
"
T
"
]]
# TODO (dmt): Make purpose and origin a tuple.
print
(
len
(
join
))
return
PandasBlock
(
join
,
self
.
purpose
,
self
.
origin
)
class
PandasAdapter
:
class
PandasAdapter
:
def
__init__
(
self
,
data_frame
):
def
__init__
(
self
,
data_frame
):
...
@@ -199,7 +225,7 @@ class PandasAdapter:
...
@@ -199,7 +225,7 @@ class PandasAdapter:
return
block
return
block
@classmethod
@classmethod
def
read_csv
_data
(
cls
,
path
):
def
read_csv
(
cls
,
path
):
data_frame
=
pd
.
read_csv
(
path
,
index_col
=
False
)
data_frame
=
pd
.
read_csv
(
path
,
index_col
=
False
)
return
PandasAdapter
(
data_frame
)
return
PandasAdapter
(
data_frame
)
...
...
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