Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
Vorhersage der Verkehrslage CVH
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Luca Sander
Vorhersage der Verkehrslage CVH
Commits
c956342e
Commit
c956342e
authored
4 years ago
by
Christoph Olberding
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
e03885a1
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Imputer/fill_missing.py
+52
-0
52 additions, 0 deletions
Imputer/fill_missing.py
with
52 additions
and
0 deletions
Imputer/fill_missing.py
0 → 100644
+
52
−
0
View file @
c956342e
# -*- coding: utf-8 -*-
"""
Created on Fri Feb 26 12:57:45 2021
@author: Christoph
"""
import
pandas
as
pd
import
numpy
as
np
data
=
pd
.
read_csv
(
'
data.csv
'
)
data
=
data
.
iloc
[:,
1
:]
timeinterval
=
[
0
]
minutes
=
[
0
]
indexes
=
[]
time
=
0
minute
=
0
for
h
in
range
(
108
):
h
=
h
+
1
if
(
h
<
13
or
(
h
>
48
and
h
<
63
)
or
h
>
98
):
time
=
time
+
(
30
*
60
)
minute
=
minute
+
30
if
((
h
>
12
and
h
<
49
)
or
(
h
>
62
and
h
<
99
)):
time
=
time
+
(
5
*
60
)
minute
=
minute
+
5
timeinterval
.
append
(
time
)
minutes
.
append
(
minute
)
indexes
.
append
(
h
)
timeinterval
=
np
.
asarray
(
timeinterval
)
minutes
=
np
.
asarray
(
minutes
)
indexes
=
np
.
asarray
(
indexes
)
for
h
in
range
(
np
.
asarray
(
timeinterval
).
shape
[
0
]
-
1
):
data
.
loc
[(
data
[
'
time
'
]
>
timeinterval
[
h
])
&
(
data
[
'
time
'
]
<=
timeinterval
[
h
+
1
]),
'
time
'
]
=
indexes
[
h
]
#data.loc[(data['time']>timeinterval[h]) & (data['time']<=timeinterval[h+1]), 'time'] = indexes[h]
d
=
data
.
copy
()
for
e
in
data
[
'
day_index
'
].
unique
():
# für alle verschiedenen tages_indexe
day_data
=
data
.
loc
[
data
[
'
day_index
'
]
==
e
]
# nur die einzelnen Tage
for
h
in
indexes
:
#für alle zeit_indexe der tage
for
k
in
day_data
[
'
Streckenvorhersage.ZielortID
'
].
unique
():
# für alle verschiedenen Zielorte
day_data_location
=
day_data
.
loc
[
day_data
[
'
Streckenvorhersage.ZielortID
'
]
==
k
]
# auteilung der tageswerte nach zielort
exists
=
False
;
for
l
in
day_data_location
[
'
time
'
].
unique
():
#für alle verschiedenen EXISTENTEN zeiten im Tag
if
(
h
==
l
):
exists
=
True
# wenn die Zeit existiert
if
(
exists
==
False
):
new_row
=
{
'
Streckenvorhersage.ZielortID
'
:
k
,
'
Streckenvorhersage.StartortID
'
:
1
,
'
Streckenvorhersage.Dauer
'
:
0
,
'
time
'
:
h
,
'
day_index
'
:
e
}
data
=
data
.
append
(
new_row
,
ignore_index
=
True
)
data
.
to_csv
(
'
data_unfilled.csv
'
)
\ No newline at end of file
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