Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RSE 23 Group Assignment Shervud Pitawanik Franz
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
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Niklas Franz
RSE 23 Group Assignment Shervud Pitawanik Franz
Commits
7bdb14cf
Commit
7bdb14cf
authored
1 year ago
by
Sortofamudkip
Browse files
Options
Downloads
Patches
Plain Diff
basic preprocess_dataset() and get_sorted_column()
parent
5129400f
No related branches found
No related tags found
1 merge request
!5
Resolve "Basic Dataset class"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Dataset.py
+35
-5
35 additions, 5 deletions
src/Dataset.py
with
35 additions
and
5 deletions
src/Dataset.py
+
35
−
5
View file @
7bdb14cf
...
...
@@ -3,12 +3,30 @@ import pandas as pd
class
Dataset
:
def
__init__
(
self
,
dataset_filename
:
str
)
->
None
:
raw_data
set
=
pd
.
read_csv
(
dataset_filename
,
encoding
=
"
windows-1254
"
)
self
.
data
set
=
self
.
preprocess_dataset
(
raw_data
set
)
raw_data
frame
=
pd
.
read_csv
(
dataset_filename
,
encoding
=
"
windows-1254
"
)
self
.
data
frame
=
self
.
preprocess_dataset
(
raw_data
frame
)
def
preprocess_dataset
(
self
,
raw_dataframe
):
# preprocessing goes here
return
raw_dataframe
def
preprocess_dataset
(
self
,
raw_dataframe
:
pd
.
DataFrame
)
->
pd
.
DataFrame
:
"""
preprocess dataframe immediately after loading it.
Args:
raw_dataframe (pd.DataFrame):
raw dataframe as read from pd.read_csv().
Returns:
pd.DataFrame: resulting preprocessed dataframe.
"""
dataframe
=
raw_dataframe
.
drop
([
"
League
"
],
axis
=
"
columns
"
)
# more preprocessing goes here
return
dataframe
def
get_dataframe
(
self
)
->
pd
.
DataFrame
:
"""
A getter function for the dataframe.
Returns:
pd.DataFrame: the dataset.
"""
return
self
.
dataframe
def
draw_histogram
(
self
):
raise
NotImplementedError
...
...
@@ -18,3 +36,15 @@ class Dataset:
def
get_plottable_columns
(
self
)
->
list
:
raise
NotImplementedError
def
get_sorted_column
(
self
,
colname
:
str
,
ascending
=
True
)
->
pd
.
Series
:
"""
Returns a single column, sorted either ascending or descending.
Args:
colname (str): the column name (see get_dataset_columns()).
ascending (bool, optional): Sorting order. Defaults to True.
Returns:
pd.Series: The sorted column.
"""
return
self
.
dataframe
[
colname
].
sort_values
(
ascending
=
ascending
)
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