From 2b82db75ac4686611d6b4607c647a734a7e0616e Mon Sep 17 00:00:00 2001
From: Tellem <76844312+TellemHD@users.noreply.github.com>
Date: Fri, 21 Jun 2024 11:55:52 +0200
Subject: [PATCH] feat: reorders parameters of RangeScaler and makes them
keyword-only (#847)
Closes #809
### Summary of Changes
- reorders parameters of RangeScaler and makes them keyword-only
- updates a Tutorial in the Documentation
---------
Co-authored-by: megalinter-bot <129584137+megalinter-bot@users.noreply.github.com>
---
docs/tutorials/data_processing.ipynb | 774 +++++++++++++-----
.../tabular/transformation/_range_scaler.py | 8 +-
2 files changed, 586 insertions(+), 196 deletions(-)
diff --git a/docs/tutorials/data_processing.ipynb b/docs/tutorials/data_processing.ipynb
index eb32d7caf..e5803137f 100644
--- a/docs/tutorials/data_processing.ipynb
+++ b/docs/tutorials/data_processing.ipynb
@@ -2,6 +2,9 @@
"cells": [
{
"cell_type": "markdown",
+ "metadata": {
+ "collapsed": false
+ },
"source": [
"# Data Processing\n",
"\n",
@@ -13,480 +16,873 @@
" All operations on a Table
return a new Table
. The original Table
will not be changed.\n",
"
\n",
""
- ],
- "metadata": {
- "collapsed": false
- }
+ ]
},
{
"cell_type": "markdown",
+ "metadata": {
+ "collapsed": false
+ },
"source": [
"### Create & Load data\n",
"\n",
"1. Load your data into a `Table`:"
- ],
- "metadata": {
- "collapsed": false
- }
+ ]
},
{
"cell_type": "code",
- "source": [
- "from safeds.data.tabular.containers import Table\n",
- "\n",
- "titanic = Table.from_csv_file(\"data/titanic.csv\")"
- ],
+ "execution_count": 1,
"metadata": {
- "collapsed": false,
"ExecuteTime": {
"end_time": "2024-05-24T11:02:33.418025600Z",
"start_time": "2024-05-24T11:02:33.358365Z"
- }
+ },
+ "collapsed": false
},
"outputs": [],
- "execution_count": 1
+ "source": [
+ "from safeds.data.tabular.containers import Table\n",
+ "\n",
+ "titanic = Table.from_csv_file(\"data/titanic.csv\")"
+ ]
},
{
"cell_type": "markdown",
- "source": [
- "2. Create a `Table` containing only the first 10 rows:"
- ],
"metadata": {
"collapsed": false
- }
+ },
+ "source": [
+ "2. Create a `Table` containing only the first 10 rows:"
+ ]
},
{
"cell_type": "code",
- "source": [
- "titanic_slice = titanic.slice_rows(length=10)\n",
- "\n",
- "titanic_slice # just to show the output"
- ],
+ "execution_count": 2,
"metadata": {
- "collapsed": false,
"ExecuteTime": {
"end_time": "2024-05-24T11:02:33.426370200Z",
"start_time": "2024-05-24T11:02:33.419030500Z"
- }
+ },
+ "collapsed": false
},
"outputs": [
{
"data": {
- "text/plain": "+-----+----------------------+--------+----------+---+----------+-------+---------------+----------+\n| id | name | sex | age | … | fare | cabin | port_embarked | survived |\n| --- | --- | --- | --- | | --- | --- | --- | --- |\n| i64 | str | str | f64 | | f64 | str | str | i64 |\n+==================================================================================================+\n| 0 | Abbing, Mr. Anthony | male | 42.00000 | … | 7.55000 | null | Southampton | 0 |\n| 1 | Abbott, Master. | male | 13.00000 | … | 20.25000 | null | Southampton | 0 |\n| | Eugene Joseph | | | | | | | |\n| 2 | Abbott, Mr. Rossmore | male | 16.00000 | … | 20.25000 | null | Southampton | 0 |\n| | Edward | | | | | | | |\n| 3 | Abbott, Mrs. Stanton | female | 35.00000 | … | 20.25000 | null | Southampton | 1 |\n| | (Rosa Hun… | | | | | | | |\n| 4 | Abelseth, Miss. | female | 16.00000 | … | 7.65000 | null | Southampton | 1 |\n| | Karen Marie | | | | | | | |\n| 5 | Abelseth, Mr. Olaus | male | 25.00000 | … | 7.65000 | F G63 | Southampton | 1 |\n| | Jorgensen | | | | | | | |\n| 6 | Abelson, Mr. Samuel | male | 30.00000 | … | 24.00000 | null | Cherbourg | 0 |\n| 7 | Abelson, Mrs. Samuel | female | 28.00000 | … | 24.00000 | null | Cherbourg | 1 |\n| | (Hannah W… | | | | | | | |\n| 8 | Abrahamsson, Mr. | male | 20.00000 | … | 7.92500 | null | Southampton | 1 |\n| | Abraham Augus… | | | | | | | |\n| 9 | Abrahim, Mrs. Joseph | female | 18.00000 | … | 7.22920 | null | Cherbourg | 1 |\n| | (Sophie H… | | | | | | | |\n+-----+----------------------+--------+----------+---+----------+-------+---------------+----------+",
- "text/html": "\n
shape: (10, 12)id | name | sex | age | siblings_spouses | parents_children | ticket | travel_class | fare | cabin | port_embarked | survived |
---|
i64 | str | str | f64 | i64 | i64 | str | i64 | f64 | str | str | i64 |
0 | "Abbing, Mr. Anthony" | "male" | 42.0 | 0 | 0 | "C.A. 5547" | 3 | 7.55 | null | "Southampton" | 0 |
1 | "Abbott, Master. Eugene Joseph" | "male" | 13.0 | 0 | 2 | "C.A. 2673" | 3 | 20.25 | null | "Southampton" | 0 |
2 | "Abbott, Mr. Rossmore Edward" | "male" | 16.0 | 1 | 1 | "C.A. 2673" | 3 | 20.25 | null | "Southampton" | 0 |
3 | "Abbott, Mrs. Stanton (Rosa Hun… | "female" | 35.0 | 1 | 1 | "C.A. 2673" | 3 | 20.25 | null | "Southampton" | 1 |
4 | "Abelseth, Miss. Karen Marie" | "female" | 16.0 | 0 | 0 | "348125" | 3 | 7.65 | null | "Southampton" | 1 |
5 | "Abelseth, Mr. Olaus Jorgensen" | "male" | 25.0 | 0 | 0 | "348122" | 3 | 7.65 | "F G63" | "Southampton" | 1 |
6 | "Abelson, Mr. Samuel" | "male" | 30.0 | 1 | 0 | "P/PP 3381" | 2 | 24.0 | null | "Cherbourg" | 0 |
7 | "Abelson, Mrs. Samuel (Hannah W… | "female" | 28.0 | 1 | 0 | "P/PP 3381" | 2 | 24.0 | null | "Cherbourg" | 1 |
8 | "Abrahamsson, Mr. Abraham Augus… | "male" | 20.0 | 0 | 0 | "SOTON/O2 3101284" | 3 | 7.925 | null | "Southampton" | 1 |
9 | "Abrahim, Mrs. Joseph (Sophie H… | "female" | 18.0 | 0 | 0 | "2657" | 3 | 7.2292 | null | "Cherbourg" | 1 |
"
+ "text/html": [
+ "\n",
+ "
shape: (10, 12)id | name | sex | age | siblings_spouses | parents_children | ticket | travel_class | fare | cabin | port_embarked | survived |
---|
i64 | str | str | f64 | i64 | i64 | str | i64 | f64 | str | str | i64 |
0 | "Abbing, Mr. Anthony" | "male" | 42.0 | 0 | 0 | "C.A. 5547" | 3 | 7.55 | null | "Southampton" | 0 |
1 | "Abbott, Master. Eugene Joseph" | "male" | 13.0 | 0 | 2 | "C.A. 2673" | 3 | 20.25 | null | "Southampton" | 0 |
2 | "Abbott, Mr. Rossmore Edward" | "male" | 16.0 | 1 | 1 | "C.A. 2673" | 3 | 20.25 | null | "Southampton" | 0 |
3 | "Abbott, Mrs. Stanton (Rosa Hun… | "female" | 35.0 | 1 | 1 | "C.A. 2673" | 3 | 20.25 | null | "Southampton" | 1 |
4 | "Abelseth, Miss. Karen Marie" | "female" | 16.0 | 0 | 0 | "348125" | 3 | 7.65 | null | "Southampton" | 1 |
5 | "Abelseth, Mr. Olaus Jorgensen" | "male" | 25.0 | 0 | 0 | "348122" | 3 | 7.65 | "F G63" | "Southampton" | 1 |
6 | "Abelson, Mr. Samuel" | "male" | 30.0 | 1 | 0 | "P/PP 3381" | 2 | 24.0 | null | "Cherbourg" | 0 |
7 | "Abelson, Mrs. Samuel (Hannah W… | "female" | 28.0 | 1 | 0 | "P/PP 3381" | 2 | 24.0 | null | "Cherbourg" | 1 |
8 | "Abrahamsson, Mr. Abraham Augus… | "male" | 20.0 | 0 | 0 | "SOTON/O2 3101284" | 3 | 7.925 | null | "Southampton" | 1 |
9 | "Abrahim, Mrs. Joseph (Sophie H… | "female" | 18.0 | 0 | 0 | "2657" | 3 | 7.2292 | null | "Cherbourg" | 1 |
"
+ ],
+ "text/plain": [
+ "+-----+----------------------+--------+----------+---+----------+-------+---------------+----------+\n",
+ "| id | name | sex | age | … | fare | cabin | port_embarked | survived |\n",
+ "| --- | --- | --- | --- | | --- | --- | --- | --- |\n",
+ "| i64 | str | str | f64 | | f64 | str | str | i64 |\n",
+ "+==================================================================================================+\n",
+ "| 0 | Abbing, Mr. Anthony | male | 42.00000 | … | 7.55000 | null | Southampton | 0 |\n",
+ "| 1 | Abbott, Master. | male | 13.00000 | … | 20.25000 | null | Southampton | 0 |\n",
+ "| | Eugene Joseph | | | | | | | |\n",
+ "| 2 | Abbott, Mr. Rossmore | male | 16.00000 | … | 20.25000 | null | Southampton | 0 |\n",
+ "| | Edward | | | | | | | |\n",
+ "| 3 | Abbott, Mrs. Stanton | female | 35.00000 | … | 20.25000 | null | Southampton | 1 |\n",
+ "| | (Rosa Hun… | | | | | | | |\n",
+ "| 4 | Abelseth, Miss. | female | 16.00000 | … | 7.65000 | null | Southampton | 1 |\n",
+ "| | Karen Marie | | | | | | | |\n",
+ "| 5 | Abelseth, Mr. Olaus | male | 25.00000 | … | 7.65000 | F G63 | Southampton | 1 |\n",
+ "| | Jorgensen | | | | | | | |\n",
+ "| 6 | Abelson, Mr. Samuel | male | 30.00000 | … | 24.00000 | null | Cherbourg | 0 |\n",
+ "| 7 | Abelson, Mrs. Samuel | female | 28.00000 | … | 24.00000 | null | Cherbourg | 1 |\n",
+ "| | (Hannah W… | | | | | | | |\n",
+ "| 8 | Abrahamsson, Mr. | male | 20.00000 | … | 7.92500 | null | Southampton | 1 |\n",
+ "| | Abraham Augus… | | | | | | | |\n",
+ "| 9 | Abrahim, Mrs. Joseph | female | 18.00000 | … | 7.22920 | null | Cherbourg | 1 |\n",
+ "| | (Sophie H… | | | | | | | |\n",
+ "+-----+----------------------+--------+----------+---+----------+-------+---------------+----------+"
+ ]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
- "execution_count": 2
+ "source": [
+ "titanic_slice = titanic.slice_rows(length=10)\n",
+ "\n",
+ "titanic_slice # just to show the output"
+ ]
},
{
"cell_type": "markdown",
- "source": [
- "3. Extract a `Column` from your `Table`:"
- ],
"metadata": {
"collapsed": false
- }
+ },
+ "source": [
+ "3. Extract a `Column` from your `Table`:"
+ ]
},
{
"cell_type": "code",
- "source": [
- "titanic_slice.get_column(\"name\")"
- ],
+ "execution_count": 3,
"metadata": {
- "collapsed": false,
"ExecuteTime": {
"end_time": "2024-05-24T11:02:33.431877400Z",
"start_time": "2024-05-24T11:02:33.426370200Z"
- }
+ },
+ "collapsed": false
},
"outputs": [
{
"data": {
- "text/plain": "+---------------------------------+\n| name |\n| --- |\n| str |\n+=================================+\n| Abbing, Mr. Anthony |\n| Abbott, Master. Eugene Joseph |\n| Abbott, Mr. Rossmore Edward |\n| Abbott, Mrs. Stanton (Rosa Hun… |\n| Abelseth, Miss. Karen Marie |\n| Abelseth, Mr. Olaus Jorgensen |\n| Abelson, Mr. Samuel |\n| Abelson, Mrs. Samuel (Hannah W… |\n| Abrahamsson, Mr. Abraham Augus… |\n| Abrahim, Mrs. Joseph (Sophie H… |\n+---------------------------------+",
- "text/html": "\n
shape: (10,)name |
---|
str |
"Abbing, Mr. Anthony" |
"Abbott, Master. Eugene Joseph" |
"Abbott, Mr. Rossmore Edward" |
"Abbott, Mrs. Stanton (Rosa Hun… |
"Abelseth, Miss. Karen Marie" |
"Abelseth, Mr. Olaus Jorgensen" |
"Abelson, Mr. Samuel" |
"Abelson, Mrs. Samuel (Hannah W… |
"Abrahamsson, Mr. Abraham Augus… |
"Abrahim, Mrs. Joseph (Sophie H… |
"
+ "text/html": [
+ "\n",
+ "
shape: (10,)name |
---|
str |
"Abbing, Mr. Anthony" |
"Abbott, Master. Eugene Joseph" |
"Abbott, Mr. Rossmore Edward" |
"Abbott, Mrs. Stanton (Rosa Hun… |
"Abelseth, Miss. Karen Marie" |
"Abelseth, Mr. Olaus Jorgensen" |
"Abelson, Mr. Samuel" |
"Abelson, Mrs. Samuel (Hannah W… |
"Abrahamsson, Mr. Abraham Augus… |
"Abrahim, Mrs. Joseph (Sophie H… |
"
+ ],
+ "text/plain": [
+ "+---------------------------------+\n",
+ "| name |\n",
+ "| --- |\n",
+ "| str |\n",
+ "+=================================+\n",
+ "| Abbing, Mr. Anthony |\n",
+ "| Abbott, Master. Eugene Joseph |\n",
+ "| Abbott, Mr. Rossmore Edward |\n",
+ "| Abbott, Mrs. Stanton (Rosa Hun… |\n",
+ "| Abelseth, Miss. Karen Marie |\n",
+ "| Abelseth, Mr. Olaus Jorgensen |\n",
+ "| Abelson, Mr. Samuel |\n",
+ "| Abelson, Mrs. Samuel (Hannah W… |\n",
+ "| Abrahamsson, Mr. Abraham Augus… |\n",
+ "| Abrahim, Mrs. Joseph (Sophie H… |\n",
+ "+---------------------------------+"
+ ]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
- "execution_count": 3
+ "source": [
+ "titanic_slice.get_column(\"name\")"
+ ]
},
{
"cell_type": "markdown",
- "source": [
- "4. Combine a list of `Column`s to a `Table` (make sure the `Column`s have the same amount of rows):"
- ],
"metadata": {
"collapsed": false
- }
+ },
+ "source": [
+ "4. Combine a list of `Column`s to a `Table` (make sure the `Column`s have the same amount of rows):"
+ ]
},
{
"cell_type": "code",
- "source": [
- "Table.from_columns([\n",
- " titanic_slice.get_column(\"name\"),\n",
- " titanic_slice.get_column(\"age\")\n",
- "])"
- ],
+ "execution_count": 4,
"metadata": {
- "collapsed": false,
"ExecuteTime": {
"end_time": "2024-05-24T11:02:33.436929600Z",
"start_time": "2024-05-24T11:02:33.430880700Z"
- }
+ },
+ "collapsed": false
},
"outputs": [
{
"data": {
- "text/plain": "+---------------------------------+----------+\n| name | age |\n| --- | --- |\n| str | f64 |\n+============================================+\n| Abbing, Mr. Anthony | 42.00000 |\n| Abbott, Master. Eugene Joseph | 13.00000 |\n| Abbott, Mr. Rossmore Edward | 16.00000 |\n| Abbott, Mrs. Stanton (Rosa Hun… | 35.00000 |\n| Abelseth, Miss. Karen Marie | 16.00000 |\n| Abelseth, Mr. Olaus Jorgensen | 25.00000 |\n| Abelson, Mr. Samuel | 30.00000 |\n| Abelson, Mrs. Samuel (Hannah W… | 28.00000 |\n| Abrahamsson, Mr. Abraham Augus… | 20.00000 |\n| Abrahim, Mrs. Joseph (Sophie H… | 18.00000 |\n+---------------------------------+----------+",
- "text/html": "\n
shape: (10, 2)name | age |
---|
str | f64 |
"Abbing, Mr. Anthony" | 42.0 |
"Abbott, Master. Eugene Joseph" | 13.0 |
"Abbott, Mr. Rossmore Edward" | 16.0 |
"Abbott, Mrs. Stanton (Rosa Hun… | 35.0 |
"Abelseth, Miss. Karen Marie" | 16.0 |
"Abelseth, Mr. Olaus Jorgensen" | 25.0 |
"Abelson, Mr. Samuel" | 30.0 |
"Abelson, Mrs. Samuel (Hannah W… | 28.0 |
"Abrahamsson, Mr. Abraham Augus… | 20.0 |
"Abrahim, Mrs. Joseph (Sophie H… | 18.0 |
"
+ "text/html": [
+ "\n",
+ "
shape: (10, 2)name | age |
---|
str | f64 |
"Abbing, Mr. Anthony" | 42.0 |
"Abbott, Master. Eugene Joseph" | 13.0 |
"Abbott, Mr. Rossmore Edward" | 16.0 |
"Abbott, Mrs. Stanton (Rosa Hun… | 35.0 |
"Abelseth, Miss. Karen Marie" | 16.0 |
"Abelseth, Mr. Olaus Jorgensen" | 25.0 |
"Abelson, Mr. Samuel" | 30.0 |
"Abelson, Mrs. Samuel (Hannah W… | 28.0 |
"Abrahamsson, Mr. Abraham Augus… | 20.0 |
"Abrahim, Mrs. Joseph (Sophie H… | 18.0 |
"
+ ],
+ "text/plain": [
+ "+---------------------------------+----------+\n",
+ "| name | age |\n",
+ "| --- | --- |\n",
+ "| str | f64 |\n",
+ "+============================================+\n",
+ "| Abbing, Mr. Anthony | 42.00000 |\n",
+ "| Abbott, Master. Eugene Joseph | 13.00000 |\n",
+ "| Abbott, Mr. Rossmore Edward | 16.00000 |\n",
+ "| Abbott, Mrs. Stanton (Rosa Hun… | 35.00000 |\n",
+ "| Abelseth, Miss. Karen Marie | 16.00000 |\n",
+ "| Abelseth, Mr. Olaus Jorgensen | 25.00000 |\n",
+ "| Abelson, Mr. Samuel | 30.00000 |\n",
+ "| Abelson, Mrs. Samuel (Hannah W… | 28.00000 |\n",
+ "| Abrahamsson, Mr. Abraham Augus… | 20.00000 |\n",
+ "| Abrahim, Mrs. Joseph (Sophie H… | 18.00000 |\n",
+ "+---------------------------------+----------+"
+ ]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
- "execution_count": 4
+ "source": [
+ "Table.from_columns([\n",
+ " titanic_slice.get_column(\"name\"),\n",
+ " titanic_slice.get_column(\"age\")\n",
+ "])"
+ ]
},
{
"cell_type": "markdown",
- "source": [
- "5. Drop columns from a `Table`:"
- ],
"metadata": {
"collapsed": false
- }
+ },
+ "source": [
+ "5. Drop columns from a `Table`:"
+ ]
},
{
"cell_type": "code",
- "source": [
- "titanic_slice.remove_columns([\n",
- " \"id\",\n",
- " \"name\",\n",
- " \"ticket\",\n",
- " \"cabin\",\n",
- " \"port_embarked\",\n",
- " \"survived\"\n",
- "])"
- ],
+ "execution_count": 5,
"metadata": {
- "collapsed": false,
"ExecuteTime": {
"end_time": "2024-05-24T11:02:33.457085600Z",
"start_time": "2024-05-24T11:02:33.436929600Z"
- }
+ },
+ "collapsed": false
},
"outputs": [
{
"data": {
- "text/plain": "+--------+----------+------------------+------------------+--------------+----------+\n| sex | age | siblings_spouses | parents_children | travel_class | fare |\n| --- | --- | --- | --- | --- | --- |\n| str | f64 | i64 | i64 | i64 | f64 |\n+===================================================================================+\n| male | 42.00000 | 0 | 0 | 3 | 7.55000 |\n| male | 13.00000 | 0 | 2 | 3 | 20.25000 |\n| male | 16.00000 | 1 | 1 | 3 | 20.25000 |\n| female | 35.00000 | 1 | 1 | 3 | 20.25000 |\n| female | 16.00000 | 0 | 0 | 3 | 7.65000 |\n| male | 25.00000 | 0 | 0 | 3 | 7.65000 |\n| male | 30.00000 | 1 | 0 | 2 | 24.00000 |\n| female | 28.00000 | 1 | 0 | 2 | 24.00000 |\n| male | 20.00000 | 0 | 0 | 3 | 7.92500 |\n| female | 18.00000 | 0 | 0 | 3 | 7.22920 |\n+--------+----------+------------------+------------------+--------------+----------+",
- "text/html": "\n
shape: (10, 6)sex | age | siblings_spouses | parents_children | travel_class | fare |
---|
str | f64 | i64 | i64 | i64 | f64 |
"male" | 42.0 | 0 | 0 | 3 | 7.55 |
"male" | 13.0 | 0 | 2 | 3 | 20.25 |
"male" | 16.0 | 1 | 1 | 3 | 20.25 |
"female" | 35.0 | 1 | 1 | 3 | 20.25 |
"female" | 16.0 | 0 | 0 | 3 | 7.65 |
"male" | 25.0 | 0 | 0 | 3 | 7.65 |
"male" | 30.0 | 1 | 0 | 2 | 24.0 |
"female" | 28.0 | 1 | 0 | 2 | 24.0 |
"male" | 20.0 | 0 | 0 | 3 | 7.925 |
"female" | 18.0 | 0 | 0 | 3 | 7.2292 |
"
+ "text/html": [
+ "\n",
+ "
shape: (10, 6)sex | age | siblings_spouses | parents_children | travel_class | fare |
---|
str | f64 | i64 | i64 | i64 | f64 |
"male" | 42.0 | 0 | 0 | 3 | 7.55 |
"male" | 13.0 | 0 | 2 | 3 | 20.25 |
"male" | 16.0 | 1 | 1 | 3 | 20.25 |
"female" | 35.0 | 1 | 1 | 3 | 20.25 |
"female" | 16.0 | 0 | 0 | 3 | 7.65 |
"male" | 25.0 | 0 | 0 | 3 | 7.65 |
"male" | 30.0 | 1 | 0 | 2 | 24.0 |
"female" | 28.0 | 1 | 0 | 2 | 24.0 |
"male" | 20.0 | 0 | 0 | 3 | 7.925 |
"female" | 18.0 | 0 | 0 | 3 | 7.2292 |
"
+ ],
+ "text/plain": [
+ "+--------+----------+------------------+------------------+--------------+----------+\n",
+ "| sex | age | siblings_spouses | parents_children | travel_class | fare |\n",
+ "| --- | --- | --- | --- | --- | --- |\n",
+ "| str | f64 | i64 | i64 | i64 | f64 |\n",
+ "+===================================================================================+\n",
+ "| male | 42.00000 | 0 | 0 | 3 | 7.55000 |\n",
+ "| male | 13.00000 | 0 | 2 | 3 | 20.25000 |\n",
+ "| male | 16.00000 | 1 | 1 | 3 | 20.25000 |\n",
+ "| female | 35.00000 | 1 | 1 | 3 | 20.25000 |\n",
+ "| female | 16.00000 | 0 | 0 | 3 | 7.65000 |\n",
+ "| male | 25.00000 | 0 | 0 | 3 | 7.65000 |\n",
+ "| male | 30.00000 | 1 | 0 | 2 | 24.00000 |\n",
+ "| female | 28.00000 | 1 | 0 | 2 | 24.00000 |\n",
+ "| male | 20.00000 | 0 | 0 | 3 | 7.92500 |\n",
+ "| female | 18.00000 | 0 | 0 | 3 | 7.22920 |\n",
+ "+--------+----------+------------------+------------------+--------------+----------+"
+ ]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
- "execution_count": 5
+ "source": [
+ "titanic_slice.remove_columns([\n",
+ " \"id\",\n",
+ " \"name\",\n",
+ " \"ticket\",\n",
+ " \"cabin\",\n",
+ " \"port_embarked\",\n",
+ " \"survived\"\n",
+ "])"
+ ]
},
{
"cell_type": "markdown",
- "source": [
- "6. Keep only specified columns of a `Table`:"
- ],
"metadata": {
"collapsed": false
- }
+ },
+ "source": [
+ "6. Keep only specified columns of a `Table`:"
+ ]
},
{
"cell_type": "code",
- "source": [
- "titanic_slice.remove_columns_except([\"name\", \"survived\"])"
- ],
+ "execution_count": 6,
"metadata": {
- "collapsed": false,
"ExecuteTime": {
"end_time": "2024-05-24T11:02:33.458084900Z",
"start_time": "2024-05-24T11:02:33.441438800Z"
- }
+ },
+ "collapsed": false
},
"outputs": [
{
"data": {
- "text/plain": "+---------------------------------+----------+\n| name | survived |\n| --- | --- |\n| str | i64 |\n+============================================+\n| Abbing, Mr. Anthony | 0 |\n| Abbott, Master. Eugene Joseph | 0 |\n| Abbott, Mr. Rossmore Edward | 0 |\n| Abbott, Mrs. Stanton (Rosa Hun… | 1 |\n| Abelseth, Miss. Karen Marie | 1 |\n| Abelseth, Mr. Olaus Jorgensen | 1 |\n| Abelson, Mr. Samuel | 0 |\n| Abelson, Mrs. Samuel (Hannah W… | 1 |\n| Abrahamsson, Mr. Abraham Augus… | 1 |\n| Abrahim, Mrs. Joseph (Sophie H… | 1 |\n+---------------------------------+----------+",
- "text/html": "\n
shape: (10, 2)name | survived |
---|
str | i64 |
"Abbing, Mr. Anthony" | 0 |
"Abbott, Master. Eugene Joseph" | 0 |
"Abbott, Mr. Rossmore Edward" | 0 |
"Abbott, Mrs. Stanton (Rosa Hun… | 1 |
"Abelseth, Miss. Karen Marie" | 1 |
"Abelseth, Mr. Olaus Jorgensen" | 1 |
"Abelson, Mr. Samuel" | 0 |
"Abelson, Mrs. Samuel (Hannah W… | 1 |
"Abrahamsson, Mr. Abraham Augus… | 1 |
"Abrahim, Mrs. Joseph (Sophie H… | 1 |
"
+ "text/html": [
+ "\n",
+ "
shape: (10, 2)name | survived |
---|
str | i64 |
"Abbing, Mr. Anthony" | 0 |
"Abbott, Master. Eugene Joseph" | 0 |
"Abbott, Mr. Rossmore Edward" | 0 |
"Abbott, Mrs. Stanton (Rosa Hun… | 1 |
"Abelseth, Miss. Karen Marie" | 1 |
"Abelseth, Mr. Olaus Jorgensen" | 1 |
"Abelson, Mr. Samuel" | 0 |
"Abelson, Mrs. Samuel (Hannah W… | 1 |
"Abrahamsson, Mr. Abraham Augus… | 1 |
"Abrahim, Mrs. Joseph (Sophie H… | 1 |
"
+ ],
+ "text/plain": [
+ "+---------------------------------+----------+\n",
+ "| name | survived |\n",
+ "| --- | --- |\n",
+ "| str | i64 |\n",
+ "+============================================+\n",
+ "| Abbing, Mr. Anthony | 0 |\n",
+ "| Abbott, Master. Eugene Joseph | 0 |\n",
+ "| Abbott, Mr. Rossmore Edward | 0 |\n",
+ "| Abbott, Mrs. Stanton (Rosa Hun… | 1 |\n",
+ "| Abelseth, Miss. Karen Marie | 1 |\n",
+ "| Abelseth, Mr. Olaus Jorgensen | 1 |\n",
+ "| Abelson, Mr. Samuel | 0 |\n",
+ "| Abelson, Mrs. Samuel (Hannah W… | 1 |\n",
+ "| Abrahamsson, Mr. Abraham Augus… | 1 |\n",
+ "| Abrahim, Mrs. Joseph (Sophie H… | 1 |\n",
+ "+---------------------------------+----------+"
+ ]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
- "execution_count": 6
+ "source": [
+ "titanic_slice.remove_columns_except([\"name\", \"survived\"])"
+ ]
},
{
"cell_type": "markdown",
+ "metadata": {
+ "collapsed": false
+ },
"source": [
"## Process data\n",
"\n",
"1. Filter rows with a given query:"
- ],
- "metadata": {
- "collapsed": false
- }
+ ]
},
{
"cell_type": "code",
- "source": [
- "titanic.remove_rows(\n",
- " lambda row: row.get_value(\"age\") < 1\n",
- ")"
- ],
+ "execution_count": 7,
"metadata": {
- "collapsed": false,
"ExecuteTime": {
"end_time": "2024-05-24T11:02:33.502602800Z",
"start_time": "2024-05-24T11:02:33.446034800Z"
- }
+ },
+ "collapsed": false
},
"outputs": [
{
"data": {
- "text/plain": "+------+---------------------+--------+----------+---+----------+-------+---------------+----------+\n| id | name | sex | age | … | fare | cabin | port_embarked | survived |\n| --- | --- | --- | --- | | --- | --- | --- | --- |\n| i64 | str | str | f64 | | f64 | str | str | i64 |\n+==================================================================================================+\n| 0 | Abbing, Mr. Anthony | male | 42.00000 | … | 7.55000 | null | Southampton | 0 |\n| 1 | Abbott, Master. | male | 13.00000 | … | 20.25000 | null | Southampton | 0 |\n| | Eugene Joseph | | | | | | | |\n| 2 | Abbott, Mr. | male | 16.00000 | … | 20.25000 | null | Southampton | 0 |\n| | Rossmore Edward | | | | | | | |\n| 3 | Abbott, Mrs. | female | 35.00000 | … | 20.25000 | null | Southampton | 1 |\n| | Stanton (Rosa Hun… | | | | | | | |\n| 4 | Abelseth, Miss. | female | 16.00000 | … | 7.65000 | null | Southampton | 1 |\n| | Karen Marie | | | | | | | |\n| … | … | … | … | … | … | … | … | … |\n| 1303 | Yrois, Miss. | female | 24.00000 | … | 13.00000 | null | Southampton | 0 |\n| | Henriette ('Mrs H… | | | | | | | |\n| 1304 | Zabour, Miss. | female | 14.50000 | … | 14.45420 | null | Cherbourg | 0 |\n| | Hileni | | | | | | | |\n| 1306 | Zakarian, Mr. | male | 26.50000 | … | 7.22500 | null | Cherbourg | 0 |\n| | Mapriededer | | | | | | | |\n| 1307 | Zakarian, Mr. Ortin | male | 27.00000 | … | 7.22500 | null | Cherbourg | 0 |\n| 1308 | Zimmerman, Mr. Leo | male | 29.00000 | … | 7.87500 | null | Southampton | 0 |\n+------+---------------------+--------+----------+---+----------+-------+---------------+----------+",
- "text/html": "\n
shape: (1_034, 12)id | name | sex | age | siblings_spouses | parents_children | ticket | travel_class | fare | cabin | port_embarked | survived |
---|
i64 | str | str | f64 | i64 | i64 | str | i64 | f64 | str | str | i64 |
0 | "Abbing, Mr. Anthony" | "male" | 42.0 | 0 | 0 | "C.A. 5547" | 3 | 7.55 | null | "Southampton" | 0 |
1 | "Abbott, Master. Eugene Joseph" | "male" | 13.0 | 0 | 2 | "C.A. 2673" | 3 | 20.25 | null | "Southampton" | 0 |
2 | "Abbott, Mr. Rossmore Edward" | "male" | 16.0 | 1 | 1 | "C.A. 2673" | 3 | 20.25 | null | "Southampton" | 0 |
3 | "Abbott, Mrs. Stanton (Rosa Hun… | "female" | 35.0 | 1 | 1 | "C.A. 2673" | 3 | 20.25 | null | "Southampton" | 1 |
4 | "Abelseth, Miss. Karen Marie" | "female" | 16.0 | 0 | 0 | "348125" | 3 | 7.65 | null | "Southampton" | 1 |
… | … | … | … | … | … | … | … | … | … | … | … |
1303 | "Yrois, Miss. Henriette ('Mrs H… | "female" | 24.0 | 0 | 0 | "248747" | 2 | 13.0 | null | "Southampton" | 0 |
1304 | "Zabour, Miss. Hileni" | "female" | 14.5 | 1 | 0 | "2665" | 3 | 14.4542 | null | "Cherbourg" | 0 |
1306 | "Zakarian, Mr. Mapriededer" | "male" | 26.5 | 0 | 0 | "2656" | 3 | 7.225 | null | "Cherbourg" | 0 |
1307 | "Zakarian, Mr. Ortin" | "male" | 27.0 | 0 | 0 | "2670" | 3 | 7.225 | null | "Cherbourg" | 0 |
1308 | "Zimmerman, Mr. Leo" | "male" | 29.0 | 0 | 0 | "315082" | 3 | 7.875 | null | "Southampton" | 0 |
"
+ "text/html": [
+ "\n",
+ "
shape: (1_034, 12)id | name | sex | age | siblings_spouses | parents_children | ticket | travel_class | fare | cabin | port_embarked | survived |
---|
i64 | str | str | f64 | i64 | i64 | str | i64 | f64 | str | str | i64 |
0 | "Abbing, Mr. Anthony" | "male" | 42.0 | 0 | 0 | "C.A. 5547" | 3 | 7.55 | null | "Southampton" | 0 |
1 | "Abbott, Master. Eugene Joseph" | "male" | 13.0 | 0 | 2 | "C.A. 2673" | 3 | 20.25 | null | "Southampton" | 0 |
2 | "Abbott, Mr. Rossmore Edward" | "male" | 16.0 | 1 | 1 | "C.A. 2673" | 3 | 20.25 | null | "Southampton" | 0 |
3 | "Abbott, Mrs. Stanton (Rosa Hun… | "female" | 35.0 | 1 | 1 | "C.A. 2673" | 3 | 20.25 | null | "Southampton" | 1 |
4 | "Abelseth, Miss. Karen Marie" | "female" | 16.0 | 0 | 0 | "348125" | 3 | 7.65 | null | "Southampton" | 1 |
… | … | … | … | … | … | … | … | … | … | … | … |
1303 | "Yrois, Miss. Henriette ('Mrs H… | "female" | 24.0 | 0 | 0 | "248747" | 2 | 13.0 | null | "Southampton" | 0 |
1304 | "Zabour, Miss. Hileni" | "female" | 14.5 | 1 | 0 | "2665" | 3 | 14.4542 | null | "Cherbourg" | 0 |
1306 | "Zakarian, Mr. Mapriededer" | "male" | 26.5 | 0 | 0 | "2656" | 3 | 7.225 | null | "Cherbourg" | 0 |
1307 | "Zakarian, Mr. Ortin" | "male" | 27.0 | 0 | 0 | "2670" | 3 | 7.225 | null | "Cherbourg" | 0 |
1308 | "Zimmerman, Mr. Leo" | "male" | 29.0 | 0 | 0 | "315082" | 3 | 7.875 | null | "Southampton" | 0 |
"
+ ],
+ "text/plain": [
+ "+------+---------------------+--------+----------+---+----------+-------+---------------+----------+\n",
+ "| id | name | sex | age | … | fare | cabin | port_embarked | survived |\n",
+ "| --- | --- | --- | --- | | --- | --- | --- | --- |\n",
+ "| i64 | str | str | f64 | | f64 | str | str | i64 |\n",
+ "+==================================================================================================+\n",
+ "| 0 | Abbing, Mr. Anthony | male | 42.00000 | … | 7.55000 | null | Southampton | 0 |\n",
+ "| 1 | Abbott, Master. | male | 13.00000 | … | 20.25000 | null | Southampton | 0 |\n",
+ "| | Eugene Joseph | | | | | | | |\n",
+ "| 2 | Abbott, Mr. | male | 16.00000 | … | 20.25000 | null | Southampton | 0 |\n",
+ "| | Rossmore Edward | | | | | | | |\n",
+ "| 3 | Abbott, Mrs. | female | 35.00000 | … | 20.25000 | null | Southampton | 1 |\n",
+ "| | Stanton (Rosa Hun… | | | | | | | |\n",
+ "| 4 | Abelseth, Miss. | female | 16.00000 | … | 7.65000 | null | Southampton | 1 |\n",
+ "| | Karen Marie | | | | | | | |\n",
+ "| … | … | … | … | … | … | … | … | … |\n",
+ "| 1303 | Yrois, Miss. | female | 24.00000 | … | 13.00000 | null | Southampton | 0 |\n",
+ "| | Henriette ('Mrs H… | | | | | | | |\n",
+ "| 1304 | Zabour, Miss. | female | 14.50000 | … | 14.45420 | null | Cherbourg | 0 |\n",
+ "| | Hileni | | | | | | | |\n",
+ "| 1306 | Zakarian, Mr. | male | 26.50000 | … | 7.22500 | null | Cherbourg | 0 |\n",
+ "| | Mapriededer | | | | | | | |\n",
+ "| 1307 | Zakarian, Mr. Ortin | male | 27.00000 | … | 7.22500 | null | Cherbourg | 0 |\n",
+ "| 1308 | Zimmerman, Mr. Leo | male | 29.00000 | … | 7.87500 | null | Southampton | 0 |\n",
+ "+------+---------------------+--------+----------+---+----------+-------+---------------+----------+"
+ ]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
- "execution_count": 7
+ "source": [
+ "titanic.remove_rows(\n",
+ " lambda row: row.get_value(\"age\") < 1\n",
+ ")"
+ ]
},
{
"cell_type": "markdown",
+ "metadata": {
+ "collapsed": false
+ },
"source": [
"## Transform table\n",
"1. Transform table using `Imputer`. `Imputer`s replace missing values with other values (e.g. a constant, the mean or the median of the column etc.) depending on the chosen startegy, for example, the following `Imputer` will replace missing values in the given columns of the table with the constant 0:"
- ],
- "metadata": {
- "collapsed": false
- }
+ ]
},
{
"cell_type": "code",
- "source": [
- "from safeds.data.tabular.transformation import SimpleImputer\n",
- "\n",
- "imputer = SimpleImputer(SimpleImputer.Strategy.constant(0), column_names=[\"age\", \"fare\", \"cabin\", \"port_embarked\"]).fit(titanic)\n",
- "imputer.transform(titanic_slice)"
- ],
+ "execution_count": 8,
"metadata": {
- "collapsed": false,
"ExecuteTime": {
"end_time": "2024-05-24T11:02:33.520628800Z",
"start_time": "2024-05-24T11:02:33.453086900Z"
- }
+ },
+ "collapsed": false
},
"outputs": [
{
"data": {
- "text/plain": "+-----+----------------------+--------+----------+---+----------+-------+---------------+----------+\n| id | name | sex | age | … | fare | cabin | port_embarked | survived |\n| --- | --- | --- | --- | | --- | --- | --- | --- |\n| i64 | str | str | f64 | | f64 | str | str | i64 |\n+==================================================================================================+\n| 0 | Abbing, Mr. Anthony | male | 42.00000 | … | 7.55000 | 0 | Southampton | 0 |\n| 1 | Abbott, Master. | male | 13.00000 | … | 20.25000 | 0 | Southampton | 0 |\n| | Eugene Joseph | | | | | | | |\n| 2 | Abbott, Mr. Rossmore | male | 16.00000 | … | 20.25000 | 0 | Southampton | 0 |\n| | Edward | | | | | | | |\n| 3 | Abbott, Mrs. Stanton | female | 35.00000 | … | 20.25000 | 0 | Southampton | 1 |\n| | (Rosa Hun… | | | | | | | |\n| 4 | Abelseth, Miss. | female | 16.00000 | … | 7.65000 | 0 | Southampton | 1 |\n| | Karen Marie | | | | | | | |\n| 5 | Abelseth, Mr. Olaus | male | 25.00000 | … | 7.65000 | F G63 | Southampton | 1 |\n| | Jorgensen | | | | | | | |\n| 6 | Abelson, Mr. Samuel | male | 30.00000 | … | 24.00000 | 0 | Cherbourg | 0 |\n| 7 | Abelson, Mrs. Samuel | female | 28.00000 | … | 24.00000 | 0 | Cherbourg | 1 |\n| | (Hannah W… | | | | | | | |\n| 8 | Abrahamsson, Mr. | male | 20.00000 | … | 7.92500 | 0 | Southampton | 1 |\n| | Abraham Augus… | | | | | | | |\n| 9 | Abrahim, Mrs. Joseph | female | 18.00000 | … | 7.22920 | 0 | Cherbourg | 1 |\n| | (Sophie H… | | | | | | | |\n+-----+----------------------+--------+----------+---+----------+-------+---------------+----------+",
- "text/html": "\n
shape: (10, 12)id | name | sex | age | siblings_spouses | parents_children | ticket | travel_class | fare | cabin | port_embarked | survived |
---|
i64 | str | str | f64 | i64 | i64 | str | i64 | f64 | str | str | i64 |
0 | "Abbing, Mr. Anthony" | "male" | 42.0 | 0 | 0 | "C.A. 5547" | 3 | 7.55 | "0" | "Southampton" | 0 |
1 | "Abbott, Master. Eugene Joseph" | "male" | 13.0 | 0 | 2 | "C.A. 2673" | 3 | 20.25 | "0" | "Southampton" | 0 |
2 | "Abbott, Mr. Rossmore Edward" | "male" | 16.0 | 1 | 1 | "C.A. 2673" | 3 | 20.25 | "0" | "Southampton" | 0 |
3 | "Abbott, Mrs. Stanton (Rosa Hun… | "female" | 35.0 | 1 | 1 | "C.A. 2673" | 3 | 20.25 | "0" | "Southampton" | 1 |
4 | "Abelseth, Miss. Karen Marie" | "female" | 16.0 | 0 | 0 | "348125" | 3 | 7.65 | "0" | "Southampton" | 1 |
5 | "Abelseth, Mr. Olaus Jorgensen" | "male" | 25.0 | 0 | 0 | "348122" | 3 | 7.65 | "F G63" | "Southampton" | 1 |
6 | "Abelson, Mr. Samuel" | "male" | 30.0 | 1 | 0 | "P/PP 3381" | 2 | 24.0 | "0" | "Cherbourg" | 0 |
7 | "Abelson, Mrs. Samuel (Hannah W… | "female" | 28.0 | 1 | 0 | "P/PP 3381" | 2 | 24.0 | "0" | "Cherbourg" | 1 |
8 | "Abrahamsson, Mr. Abraham Augus… | "male" | 20.0 | 0 | 0 | "SOTON/O2 3101284" | 3 | 7.925 | "0" | "Southampton" | 1 |
9 | "Abrahim, Mrs. Joseph (Sophie H… | "female" | 18.0 | 0 | 0 | "2657" | 3 | 7.2292 | "0" | "Cherbourg" | 1 |
"
+ "text/html": [
+ "\n",
+ "
shape: (10, 12)id | name | sex | age | siblings_spouses | parents_children | ticket | travel_class | fare | cabin | port_embarked | survived |
---|
i64 | str | str | f64 | i64 | i64 | str | i64 | f64 | str | str | i64 |
0 | "Abbing, Mr. Anthony" | "male" | 42.0 | 0 | 0 | "C.A. 5547" | 3 | 7.55 | "0" | "Southampton" | 0 |
1 | "Abbott, Master. Eugene Joseph" | "male" | 13.0 | 0 | 2 | "C.A. 2673" | 3 | 20.25 | "0" | "Southampton" | 0 |
2 | "Abbott, Mr. Rossmore Edward" | "male" | 16.0 | 1 | 1 | "C.A. 2673" | 3 | 20.25 | "0" | "Southampton" | 0 |
3 | "Abbott, Mrs. Stanton (Rosa Hun… | "female" | 35.0 | 1 | 1 | "C.A. 2673" | 3 | 20.25 | "0" | "Southampton" | 1 |
4 | "Abelseth, Miss. Karen Marie" | "female" | 16.0 | 0 | 0 | "348125" | 3 | 7.65 | "0" | "Southampton" | 1 |
5 | "Abelseth, Mr. Olaus Jorgensen" | "male" | 25.0 | 0 | 0 | "348122" | 3 | 7.65 | "F G63" | "Southampton" | 1 |
6 | "Abelson, Mr. Samuel" | "male" | 30.0 | 1 | 0 | "P/PP 3381" | 2 | 24.0 | "0" | "Cherbourg" | 0 |
7 | "Abelson, Mrs. Samuel (Hannah W… | "female" | 28.0 | 1 | 0 | "P/PP 3381" | 2 | 24.0 | "0" | "Cherbourg" | 1 |
8 | "Abrahamsson, Mr. Abraham Augus… | "male" | 20.0 | 0 | 0 | "SOTON/O2 3101284" | 3 | 7.925 | "0" | "Southampton" | 1 |
9 | "Abrahim, Mrs. Joseph (Sophie H… | "female" | 18.0 | 0 | 0 | "2657" | 3 | 7.2292 | "0" | "Cherbourg" | 1 |
"
+ ],
+ "text/plain": [
+ "+-----+----------------------+--------+----------+---+----------+-------+---------------+----------+\n",
+ "| id | name | sex | age | … | fare | cabin | port_embarked | survived |\n",
+ "| --- | --- | --- | --- | | --- | --- | --- | --- |\n",
+ "| i64 | str | str | f64 | | f64 | str | str | i64 |\n",
+ "+==================================================================================================+\n",
+ "| 0 | Abbing, Mr. Anthony | male | 42.00000 | … | 7.55000 | 0 | Southampton | 0 |\n",
+ "| 1 | Abbott, Master. | male | 13.00000 | … | 20.25000 | 0 | Southampton | 0 |\n",
+ "| | Eugene Joseph | | | | | | | |\n",
+ "| 2 | Abbott, Mr. Rossmore | male | 16.00000 | … | 20.25000 | 0 | Southampton | 0 |\n",
+ "| | Edward | | | | | | | |\n",
+ "| 3 | Abbott, Mrs. Stanton | female | 35.00000 | … | 20.25000 | 0 | Southampton | 1 |\n",
+ "| | (Rosa Hun… | | | | | | | |\n",
+ "| 4 | Abelseth, Miss. | female | 16.00000 | … | 7.65000 | 0 | Southampton | 1 |\n",
+ "| | Karen Marie | | | | | | | |\n",
+ "| 5 | Abelseth, Mr. Olaus | male | 25.00000 | … | 7.65000 | F G63 | Southampton | 1 |\n",
+ "| | Jorgensen | | | | | | | |\n",
+ "| 6 | Abelson, Mr. Samuel | male | 30.00000 | … | 24.00000 | 0 | Cherbourg | 0 |\n",
+ "| 7 | Abelson, Mrs. Samuel | female | 28.00000 | … | 24.00000 | 0 | Cherbourg | 1 |\n",
+ "| | (Hannah W… | | | | | | | |\n",
+ "| 8 | Abrahamsson, Mr. | male | 20.00000 | … | 7.92500 | 0 | Southampton | 1 |\n",
+ "| | Abraham Augus… | | | | | | | |\n",
+ "| 9 | Abrahim, Mrs. Joseph | female | 18.00000 | … | 7.22920 | 0 | Cherbourg | 1 |\n",
+ "| | (Sophie H… | | | | | | | |\n",
+ "+-----+----------------------+--------+----------+---+----------+-------+---------------+----------+"
+ ]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
- "execution_count": 8
+ "source": [
+ "from safeds.data.tabular.transformation import SimpleImputer\n",
+ "\n",
+ "imputer = SimpleImputer(SimpleImputer.Strategy.constant(0), column_names=[\"age\", \"fare\", \"cabin\", \"port_embarked\"]).fit(titanic)\n",
+ "imputer.transform(titanic_slice)"
+ ]
},
{
"cell_type": "markdown",
- "source": [
- "2. Transform table using `LabelEncoder`, this will encode categorical features in the chosen `Column`s as integers:"
- ],
"metadata": {
"collapsed": false
- }
+ },
+ "source": [
+ "2. Transform table using `LabelEncoder`, this will encode categorical features in the chosen `Column`s as integers:"
+ ]
},
{
"cell_type": "code",
- "source": [
- "from safeds.data.tabular.transformation import LabelEncoder\n",
- "\n",
- "encoder = LabelEncoder(column_names=[\"sex\", \"port_embarked\"]).fit(titanic)\n",
- "encoder.transform(titanic_slice)"
- ],
+ "execution_count": 9,
"metadata": {
- "collapsed": false,
"ExecuteTime": {
"end_time": "2024-05-24T11:02:33.584654300Z",
"start_time": "2024-05-24T11:02:33.461597400Z"
- }
+ },
+ "collapsed": false
},
"outputs": [
{
"data": {
- "text/plain": "+-----+-------------------------+-----+----------+---+----------+-------+---------------+----------+\n| id | name | sex | age | … | fare | cabin | port_embarked | survived |\n| --- | --- | --- | --- | | --- | --- | --- | --- |\n| i64 | str | u32 | f64 | | f64 | str | u32 | i64 |\n+==================================================================================================+\n| 0 | Abbing, Mr. Anthony | 0 | 42.00000 | … | 7.55000 | null | 0 | 0 |\n| 1 | Abbott, Master. Eugene | 0 | 13.00000 | … | 20.25000 | null | 0 | 0 |\n| | Joseph | | | | | | | |\n| 2 | Abbott, Mr. Rossmore | 0 | 16.00000 | … | 20.25000 | null | 0 | 0 |\n| | Edward | | | | | | | |\n| 3 | Abbott, Mrs. Stanton | 1 | 35.00000 | … | 20.25000 | null | 0 | 1 |\n| | (Rosa Hun… | | | | | | | |\n| 4 | Abelseth, Miss. Karen | 1 | 16.00000 | … | 7.65000 | null | 0 | 1 |\n| | Marie | | | | | | | |\n| 5 | Abelseth, Mr. Olaus | 0 | 25.00000 | … | 7.65000 | F G63 | 0 | 1 |\n| | Jorgensen | | | | | | | |\n| 6 | Abelson, Mr. Samuel | 0 | 30.00000 | … | 24.00000 | null | 1 | 0 |\n| 7 | Abelson, Mrs. Samuel | 1 | 28.00000 | … | 24.00000 | null | 1 | 1 |\n| | (Hannah W… | | | | | | | |\n| 8 | Abrahamsson, Mr. | 0 | 20.00000 | … | 7.92500 | null | 0 | 1 |\n| | Abraham Augus… | | | | | | | |\n| 9 | Abrahim, Mrs. Joseph | 1 | 18.00000 | … | 7.22920 | null | 1 | 1 |\n| | (Sophie H… | | | | | | | |\n+-----+-------------------------+-----+----------+---+----------+-------+---------------+----------+",
- "text/html": "\n
shape: (10, 12)id | name | sex | age | siblings_spouses | parents_children | ticket | travel_class | fare | cabin | port_embarked | survived |
---|
i64 | str | u32 | f64 | i64 | i64 | str | i64 | f64 | str | u32 | i64 |
0 | "Abbing, Mr. Anthony" | 0 | 42.0 | 0 | 0 | "C.A. 5547" | 3 | 7.55 | null | 0 | 0 |
1 | "Abbott, Master. Eugene Joseph" | 0 | 13.0 | 0 | 2 | "C.A. 2673" | 3 | 20.25 | null | 0 | 0 |
2 | "Abbott, Mr. Rossmore Edward" | 0 | 16.0 | 1 | 1 | "C.A. 2673" | 3 | 20.25 | null | 0 | 0 |
3 | "Abbott, Mrs. Stanton (Rosa Hun… | 1 | 35.0 | 1 | 1 | "C.A. 2673" | 3 | 20.25 | null | 0 | 1 |
4 | "Abelseth, Miss. Karen Marie" | 1 | 16.0 | 0 | 0 | "348125" | 3 | 7.65 | null | 0 | 1 |
5 | "Abelseth, Mr. Olaus Jorgensen" | 0 | 25.0 | 0 | 0 | "348122" | 3 | 7.65 | "F G63" | 0 | 1 |
6 | "Abelson, Mr. Samuel" | 0 | 30.0 | 1 | 0 | "P/PP 3381" | 2 | 24.0 | null | 1 | 0 |
7 | "Abelson, Mrs. Samuel (Hannah W… | 1 | 28.0 | 1 | 0 | "P/PP 3381" | 2 | 24.0 | null | 1 | 1 |
8 | "Abrahamsson, Mr. Abraham Augus… | 0 | 20.0 | 0 | 0 | "SOTON/O2 3101284" | 3 | 7.925 | null | 0 | 1 |
9 | "Abrahim, Mrs. Joseph (Sophie H… | 1 | 18.0 | 0 | 0 | "2657" | 3 | 7.2292 | null | 1 | 1 |
"
+ "text/html": [
+ "\n",
+ "
shape: (10, 12)id | name | sex | age | siblings_spouses | parents_children | ticket | travel_class | fare | cabin | port_embarked | survived |
---|
i64 | str | u32 | f64 | i64 | i64 | str | i64 | f64 | str | u32 | i64 |
0 | "Abbing, Mr. Anthony" | 0 | 42.0 | 0 | 0 | "C.A. 5547" | 3 | 7.55 | null | 0 | 0 |
1 | "Abbott, Master. Eugene Joseph" | 0 | 13.0 | 0 | 2 | "C.A. 2673" | 3 | 20.25 | null | 0 | 0 |
2 | "Abbott, Mr. Rossmore Edward" | 0 | 16.0 | 1 | 1 | "C.A. 2673" | 3 | 20.25 | null | 0 | 0 |
3 | "Abbott, Mrs. Stanton (Rosa Hun… | 1 | 35.0 | 1 | 1 | "C.A. 2673" | 3 | 20.25 | null | 0 | 1 |
4 | "Abelseth, Miss. Karen Marie" | 1 | 16.0 | 0 | 0 | "348125" | 3 | 7.65 | null | 0 | 1 |
5 | "Abelseth, Mr. Olaus Jorgensen" | 0 | 25.0 | 0 | 0 | "348122" | 3 | 7.65 | "F G63" | 0 | 1 |
6 | "Abelson, Mr. Samuel" | 0 | 30.0 | 1 | 0 | "P/PP 3381" | 2 | 24.0 | null | 1 | 0 |
7 | "Abelson, Mrs. Samuel (Hannah W… | 1 | 28.0 | 1 | 0 | "P/PP 3381" | 2 | 24.0 | null | 1 | 1 |
8 | "Abrahamsson, Mr. Abraham Augus… | 0 | 20.0 | 0 | 0 | "SOTON/O2 3101284" | 3 | 7.925 | null | 0 | 1 |
9 | "Abrahim, Mrs. Joseph (Sophie H… | 1 | 18.0 | 0 | 0 | "2657" | 3 | 7.2292 | null | 1 | 1 |
"
+ ],
+ "text/plain": [
+ "+-----+-------------------------+-----+----------+---+----------+-------+---------------+----------+\n",
+ "| id | name | sex | age | … | fare | cabin | port_embarked | survived |\n",
+ "| --- | --- | --- | --- | | --- | --- | --- | --- |\n",
+ "| i64 | str | u32 | f64 | | f64 | str | u32 | i64 |\n",
+ "+==================================================================================================+\n",
+ "| 0 | Abbing, Mr. Anthony | 0 | 42.00000 | … | 7.55000 | null | 0 | 0 |\n",
+ "| 1 | Abbott, Master. Eugene | 0 | 13.00000 | … | 20.25000 | null | 0 | 0 |\n",
+ "| | Joseph | | | | | | | |\n",
+ "| 2 | Abbott, Mr. Rossmore | 0 | 16.00000 | … | 20.25000 | null | 0 | 0 |\n",
+ "| | Edward | | | | | | | |\n",
+ "| 3 | Abbott, Mrs. Stanton | 1 | 35.00000 | … | 20.25000 | null | 0 | 1 |\n",
+ "| | (Rosa Hun… | | | | | | | |\n",
+ "| 4 | Abelseth, Miss. Karen | 1 | 16.00000 | … | 7.65000 | null | 0 | 1 |\n",
+ "| | Marie | | | | | | | |\n",
+ "| 5 | Abelseth, Mr. Olaus | 0 | 25.00000 | … | 7.65000 | F G63 | 0 | 1 |\n",
+ "| | Jorgensen | | | | | | | |\n",
+ "| 6 | Abelson, Mr. Samuel | 0 | 30.00000 | … | 24.00000 | null | 1 | 0 |\n",
+ "| 7 | Abelson, Mrs. Samuel | 1 | 28.00000 | … | 24.00000 | null | 1 | 1 |\n",
+ "| | (Hannah W… | | | | | | | |\n",
+ "| 8 | Abrahamsson, Mr. | 0 | 20.00000 | … | 7.92500 | null | 0 | 1 |\n",
+ "| | Abraham Augus… | | | | | | | |\n",
+ "| 9 | Abrahim, Mrs. Joseph | 1 | 18.00000 | … | 7.22920 | null | 1 | 1 |\n",
+ "| | (Sophie H… | | | | | | | |\n",
+ "+-----+-------------------------+-----+----------+---+----------+-------+---------------+----------+"
+ ]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
- "execution_count": 9
+ "source": [
+ "from safeds.data.tabular.transformation import LabelEncoder\n",
+ "\n",
+ "encoder = LabelEncoder(column_names=[\"sex\", \"port_embarked\"]).fit(titanic)\n",
+ "encoder.transform(titanic_slice)"
+ ]
},
{
"cell_type": "markdown",
- "source": [
- "3. Transform table using `OneHotEncoder`, this will create new `Column`s based on unique values in each chosen `Column`:\n"
- ],
"metadata": {
"collapsed": false
- }
+ },
+ "source": [
+ "3. Transform table using `OneHotEncoder`, this will create new `Column`s based on unique values in each chosen `Column`:\n"
+ ]
},
{
"cell_type": "code",
- "source": [
- "from safeds.data.tabular.transformation import OneHotEncoder\n",
- "\n",
- "encoder = OneHotEncoder(column_names=[\"sex\", \"port_embarked\"]).fit(titanic)\n",
- "encoder.transform(titanic_slice)"
- ],
+ "execution_count": 10,
"metadata": {
- "collapsed": false,
"ExecuteTime": {
"end_time": "2024-05-24T11:02:33.597162600Z",
"start_time": "2024-05-24T11:02:33.472105400Z"
- }
+ },
+ "collapsed": false
},
"outputs": [
{
"data": {
- "text/plain": "+-----+------------+----------+------------+---+------------+------------+------------+------------+\n| id | name | age | siblings_s | … | sex__femal | port_embar | port_embar | port_embar |\n| --- | --- | --- | pouses | | e | ked__South | ked__Cherb | ked__Queen |\n| i64 | str | f64 | --- | | --- | ampton | ourg | stown |\n| | | | i64 | | u8 | --- | --- | --- |\n| | | | | | | u8 | u8 | u8 |\n+==================================================================================================+\n| 0 | Abbing, | 42.00000 | 0 | … | 0 | 1 | 0 | 0 |\n| | Mr. | | | | | | | |\n| | Anthony | | | | | | | |\n| 1 | Abbott, | 13.00000 | 0 | … | 0 | 1 | 0 | 0 |\n| | Master. | | | | | | | |\n| | Eugene | | | | | | | |\n| | Joseph | | | | | | | |\n| 2 | Abbott, | 16.00000 | 1 | … | 0 | 1 | 0 | 0 |\n| | Mr. | | | | | | | |\n| | Rossmore | | | | | | | |\n| | Edward | | | | | | | |\n| 3 | Abbott, | 35.00000 | 1 | … | 1 | 1 | 0 | 0 |\n| | Mrs. | | | | | | | |\n| | Stanton | | | | | | | |\n| | (Rosa Hun… | | | | | | | |\n| 4 | Abelseth, | 16.00000 | 0 | … | 1 | 1 | 0 | 0 |\n| | Miss. | | | | | | | |\n| | Karen | | | | | | | |\n| | Marie | | | | | | | |\n| 5 | Abelseth, | 25.00000 | 0 | … | 0 | 1 | 0 | 0 |\n| | Mr. Olaus | | | | | | | |\n| | Jorgensen | | | | | | | |\n| 6 | Abelson, | 30.00000 | 1 | … | 0 | 0 | 1 | 0 |\n| | Mr. Samuel | | | | | | | |\n| 7 | Abelson, | 28.00000 | 1 | … | 1 | 0 | 1 | 0 |\n| | Mrs. | | | | | | | |\n| | Samuel | | | | | | | |\n| | (Hannah W… | | | | | | | |\n| 8 | Abrahamsso | 20.00000 | 0 | … | 0 | 1 | 0 | 0 |\n| | n, Mr. | | | | | | | |\n| | Abraham | | | | | | | |\n| | Augus… | | | | | | | |\n| 9 | Abrahim, | 18.00000 | 0 | … | 1 | 0 | 1 | 0 |\n| | Mrs. | | | | | | | |\n| | Joseph | | | | | | | |\n| | (Sophie H… | | | | | | | |\n+-----+------------+----------+------------+---+------------+------------+------------+------------+",
- "text/html": "\n
shape: (10, 15)id | name | age | siblings_spouses | parents_children | ticket | travel_class | fare | cabin | survived | sex__male | sex__female | port_embarked__Southampton | port_embarked__Cherbourg | port_embarked__Queenstown |
---|
i64 | str | f64 | i64 | i64 | str | i64 | f64 | str | i64 | u8 | u8 | u8 | u8 | u8 |
0 | "Abbing, Mr. Anthony" | 42.0 | 0 | 0 | "C.A. 5547" | 3 | 7.55 | null | 0 | 1 | 0 | 1 | 0 | 0 |
1 | "Abbott, Master. Eugene Joseph" | 13.0 | 0 | 2 | "C.A. 2673" | 3 | 20.25 | null | 0 | 1 | 0 | 1 | 0 | 0 |
2 | "Abbott, Mr. Rossmore Edward" | 16.0 | 1 | 1 | "C.A. 2673" | 3 | 20.25 | null | 0 | 1 | 0 | 1 | 0 | 0 |
3 | "Abbott, Mrs. Stanton (Rosa Hun… | 35.0 | 1 | 1 | "C.A. 2673" | 3 | 20.25 | null | 1 | 0 | 1 | 1 | 0 | 0 |
4 | "Abelseth, Miss. Karen Marie" | 16.0 | 0 | 0 | "348125" | 3 | 7.65 | null | 1 | 0 | 1 | 1 | 0 | 0 |
5 | "Abelseth, Mr. Olaus Jorgensen" | 25.0 | 0 | 0 | "348122" | 3 | 7.65 | "F G63" | 1 | 1 | 0 | 1 | 0 | 0 |
6 | "Abelson, Mr. Samuel" | 30.0 | 1 | 0 | "P/PP 3381" | 2 | 24.0 | null | 0 | 1 | 0 | 0 | 1 | 0 |
7 | "Abelson, Mrs. Samuel (Hannah W… | 28.0 | 1 | 0 | "P/PP 3381" | 2 | 24.0 | null | 1 | 0 | 1 | 0 | 1 | 0 |
8 | "Abrahamsson, Mr. Abraham Augus… | 20.0 | 0 | 0 | "SOTON/O2 3101284" | 3 | 7.925 | null | 1 | 1 | 0 | 1 | 0 | 0 |
9 | "Abrahim, Mrs. Joseph (Sophie H… | 18.0 | 0 | 0 | "2657" | 3 | 7.2292 | null | 1 | 0 | 1 | 0 | 1 | 0 |
"
+ "text/html": [
+ "\n",
+ "
shape: (10, 15)id | name | age | siblings_spouses | parents_children | ticket | travel_class | fare | cabin | survived | sex__male | sex__female | port_embarked__Southampton | port_embarked__Cherbourg | port_embarked__Queenstown |
---|
i64 | str | f64 | i64 | i64 | str | i64 | f64 | str | i64 | u8 | u8 | u8 | u8 | u8 |
0 | "Abbing, Mr. Anthony" | 42.0 | 0 | 0 | "C.A. 5547" | 3 | 7.55 | null | 0 | 1 | 0 | 1 | 0 | 0 |
1 | "Abbott, Master. Eugene Joseph" | 13.0 | 0 | 2 | "C.A. 2673" | 3 | 20.25 | null | 0 | 1 | 0 | 1 | 0 | 0 |
2 | "Abbott, Mr. Rossmore Edward" | 16.0 | 1 | 1 | "C.A. 2673" | 3 | 20.25 | null | 0 | 1 | 0 | 1 | 0 | 0 |
3 | "Abbott, Mrs. Stanton (Rosa Hun… | 35.0 | 1 | 1 | "C.A. 2673" | 3 | 20.25 | null | 1 | 0 | 1 | 1 | 0 | 0 |
4 | "Abelseth, Miss. Karen Marie" | 16.0 | 0 | 0 | "348125" | 3 | 7.65 | null | 1 | 0 | 1 | 1 | 0 | 0 |
5 | "Abelseth, Mr. Olaus Jorgensen" | 25.0 | 0 | 0 | "348122" | 3 | 7.65 | "F G63" | 1 | 1 | 0 | 1 | 0 | 0 |
6 | "Abelson, Mr. Samuel" | 30.0 | 1 | 0 | "P/PP 3381" | 2 | 24.0 | null | 0 | 1 | 0 | 0 | 1 | 0 |
7 | "Abelson, Mrs. Samuel (Hannah W… | 28.0 | 1 | 0 | "P/PP 3381" | 2 | 24.0 | null | 1 | 0 | 1 | 0 | 1 | 0 |
8 | "Abrahamsson, Mr. Abraham Augus… | 20.0 | 0 | 0 | "SOTON/O2 3101284" | 3 | 7.925 | null | 1 | 1 | 0 | 1 | 0 | 0 |
9 | "Abrahim, Mrs. Joseph (Sophie H… | 18.0 | 0 | 0 | "2657" | 3 | 7.2292 | null | 1 | 0 | 1 | 0 | 1 | 0 |
"
+ ],
+ "text/plain": [
+ "+-----+------------+----------+------------+---+------------+------------+------------+------------+\n",
+ "| id | name | age | siblings_s | … | sex__femal | port_embar | port_embar | port_embar |\n",
+ "| --- | --- | --- | pouses | | e | ked__South | ked__Cherb | ked__Queen |\n",
+ "| i64 | str | f64 | --- | | --- | ampton | ourg | stown |\n",
+ "| | | | i64 | | u8 | --- | --- | --- |\n",
+ "| | | | | | | u8 | u8 | u8 |\n",
+ "+==================================================================================================+\n",
+ "| 0 | Abbing, | 42.00000 | 0 | … | 0 | 1 | 0 | 0 |\n",
+ "| | Mr. | | | | | | | |\n",
+ "| | Anthony | | | | | | | |\n",
+ "| 1 | Abbott, | 13.00000 | 0 | … | 0 | 1 | 0 | 0 |\n",
+ "| | Master. | | | | | | | |\n",
+ "| | Eugene | | | | | | | |\n",
+ "| | Joseph | | | | | | | |\n",
+ "| 2 | Abbott, | 16.00000 | 1 | … | 0 | 1 | 0 | 0 |\n",
+ "| | Mr. | | | | | | | |\n",
+ "| | Rossmore | | | | | | | |\n",
+ "| | Edward | | | | | | | |\n",
+ "| 3 | Abbott, | 35.00000 | 1 | … | 1 | 1 | 0 | 0 |\n",
+ "| | Mrs. | | | | | | | |\n",
+ "| | Stanton | | | | | | | |\n",
+ "| | (Rosa Hun… | | | | | | | |\n",
+ "| 4 | Abelseth, | 16.00000 | 0 | … | 1 | 1 | 0 | 0 |\n",
+ "| | Miss. | | | | | | | |\n",
+ "| | Karen | | | | | | | |\n",
+ "| | Marie | | | | | | | |\n",
+ "| 5 | Abelseth, | 25.00000 | 0 | … | 0 | 1 | 0 | 0 |\n",
+ "| | Mr. Olaus | | | | | | | |\n",
+ "| | Jorgensen | | | | | | | |\n",
+ "| 6 | Abelson, | 30.00000 | 1 | … | 0 | 0 | 1 | 0 |\n",
+ "| | Mr. Samuel | | | | | | | |\n",
+ "| 7 | Abelson, | 28.00000 | 1 | … | 1 | 0 | 1 | 0 |\n",
+ "| | Mrs. | | | | | | | |\n",
+ "| | Samuel | | | | | | | |\n",
+ "| | (Hannah W… | | | | | | | |\n",
+ "| 8 | Abrahamsso | 20.00000 | 0 | … | 0 | 1 | 0 | 0 |\n",
+ "| | n, Mr. | | | | | | | |\n",
+ "| | Abraham | | | | | | | |\n",
+ "| | Augus… | | | | | | | |\n",
+ "| 9 | Abrahim, | 18.00000 | 0 | … | 1 | 0 | 1 | 0 |\n",
+ "| | Mrs. | | | | | | | |\n",
+ "| | Joseph | | | | | | | |\n",
+ "| | (Sophie H… | | | | | | | |\n",
+ "+-----+------------+----------+------------+---+------------+------------+------------+------------+"
+ ]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
- "execution_count": 10
+ "source": [
+ "from safeds.data.tabular.transformation import OneHotEncoder\n",
+ "\n",
+ "encoder = OneHotEncoder(column_names=[\"sex\", \"port_embarked\"]).fit(titanic)\n",
+ "encoder.transform(titanic_slice)"
+ ]
},
{
"cell_type": "markdown",
- "source": [
- " 4. Transform table using `RangeScaler`, this will scale the values in the chosen `Column`s to a given range:"
- ],
"metadata": {
"collapsed": false
- }
+ },
+ "source": [
+ " 4. Transform table using `RangeScaler`, this will scale the values in the chosen `Column`s to a given range:"
+ ]
},
{
"cell_type": "code",
- "source": [
- "from safeds.data.tabular.transformation import RangeScaler\n",
- "\n",
- "scaler = RangeScaler(0.0, 1.0, column_names=\"age\").fit(titanic)\n",
- "scaler.transform(titanic_slice)"
- ],
+ "execution_count": 11,
"metadata": {
- "collapsed": false,
"ExecuteTime": {
"end_time": "2024-05-24T11:02:33.599165800Z",
"start_time": "2024-05-24T11:02:33.479893800Z"
- }
+ },
+ "collapsed": false
},
"outputs": [
{
"data": {
- "text/plain": "+-----+-----------------------+--------+---------+---+----------+-------+---------------+----------+\n| id | name | sex | age | … | fare | cabin | port_embarked | survived |\n| --- | --- | --- | --- | | --- | --- | --- | --- |\n| i64 | str | str | f64 | | f64 | str | str | i64 |\n+==================================================================================================+\n| 0 | Abbing, Mr. Anthony | male | 0.52401 | … | 7.55000 | null | Southampton | 0 |\n| 1 | Abbott, Master. | male | 0.16075 | … | 20.25000 | null | Southampton | 0 |\n| | Eugene Joseph | | | | | | | |\n| 2 | Abbott, Mr. Rossmore | male | 0.19833 | … | 20.25000 | null | Southampton | 0 |\n| | Edward | | | | | | | |\n| 3 | Abbott, Mrs. Stanton | female | 0.43633 | … | 20.25000 | null | Southampton | 1 |\n| | (Rosa Hun… | | | | | | | |\n| 4 | Abelseth, Miss. Karen | female | 0.19833 | … | 7.65000 | null | Southampton | 1 |\n| | Marie | | | | | | | |\n| 5 | Abelseth, Mr. Olaus | male | 0.31106 | … | 7.65000 | F G63 | Southampton | 1 |\n| | Jorgensen | | | | | | | |\n| 6 | Abelson, Mr. Samuel | male | 0.37369 | … | 24.00000 | null | Cherbourg | 0 |\n| 7 | Abelson, Mrs. Samuel | female | 0.34864 | … | 24.00000 | null | Cherbourg | 1 |\n| | (Hannah W… | | | | | | | |\n| 8 | Abrahamsson, Mr. | male | 0.24843 | … | 7.92500 | null | Southampton | 1 |\n| | Abraham Augus… | | | | | | | |\n| 9 | Abrahim, Mrs. Joseph | female | 0.22338 | … | 7.22920 | null | Cherbourg | 1 |\n| | (Sophie H… | | | | | | | |\n+-----+-----------------------+--------+---------+---+----------+-------+---------------+----------+",
- "text/html": "\n
shape: (10, 12)id | name | sex | age | siblings_spouses | parents_children | ticket | travel_class | fare | cabin | port_embarked | survived |
---|
i64 | str | str | f64 | i64 | i64 | str | i64 | f64 | str | str | i64 |
0 | "Abbing, Mr. Anthony" | "male" | 0.524008 | 0 | 0 | "C.A. 5547" | 3 | 7.55 | null | "Southampton" | 0 |
1 | "Abbott, Master. Eugene Joseph" | "male" | 0.160751 | 0 | 2 | "C.A. 2673" | 3 | 20.25 | null | "Southampton" | 0 |
2 | "Abbott, Mr. Rossmore Edward" | "male" | 0.19833 | 1 | 1 | "C.A. 2673" | 3 | 20.25 | null | "Southampton" | 0 |
3 | "Abbott, Mrs. Stanton (Rosa Hun… | "female" | 0.436325 | 1 | 1 | "C.A. 2673" | 3 | 20.25 | null | "Southampton" | 1 |
4 | "Abelseth, Miss. Karen Marie" | "female" | 0.19833 | 0 | 0 | "348125" | 3 | 7.65 | null | "Southampton" | 1 |
5 | "Abelseth, Mr. Olaus Jorgensen" | "male" | 0.311064 | 0 | 0 | "348122" | 3 | 7.65 | "F G63" | "Southampton" | 1 |
6 | "Abelson, Mr. Samuel" | "male" | 0.373695 | 1 | 0 | "P/PP 3381" | 2 | 24.0 | null | "Cherbourg" | 0 |
7 | "Abelson, Mrs. Samuel (Hannah W… | "female" | 0.348643 | 1 | 0 | "P/PP 3381" | 2 | 24.0 | null | "Cherbourg" | 1 |
8 | "Abrahamsson, Mr. Abraham Augus… | "male" | 0.248434 | 0 | 0 | "SOTON/O2 3101284" | 3 | 7.925 | null | "Southampton" | 1 |
9 | "Abrahim, Mrs. Joseph (Sophie H… | "female" | 0.223382 | 0 | 0 | "2657" | 3 | 7.2292 | null | "Cherbourg" | 1 |
"
+ "text/html": [
+ "\n",
+ "
shape: (10, 12)id | name | sex | age | siblings_spouses | parents_children | ticket | travel_class | fare | cabin | port_embarked | survived |
---|
i64 | str | str | f64 | i64 | i64 | str | i64 | f64 | str | str | i64 |
0 | "Abbing, Mr. Anthony" | "male" | 0.524008 | 0 | 0 | "C.A. 5547" | 3 | 7.55 | null | "Southampton" | 0 |
1 | "Abbott, Master. Eugene Joseph" | "male" | 0.160751 | 0 | 2 | "C.A. 2673" | 3 | 20.25 | null | "Southampton" | 0 |
2 | "Abbott, Mr. Rossmore Edward" | "male" | 0.19833 | 1 | 1 | "C.A. 2673" | 3 | 20.25 | null | "Southampton" | 0 |
3 | "Abbott, Mrs. Stanton (Rosa Hun… | "female" | 0.436325 | 1 | 1 | "C.A. 2673" | 3 | 20.25 | null | "Southampton" | 1 |
4 | "Abelseth, Miss. Karen Marie" | "female" | 0.19833 | 0 | 0 | "348125" | 3 | 7.65 | null | "Southampton" | 1 |
5 | "Abelseth, Mr. Olaus Jorgensen" | "male" | 0.311064 | 0 | 0 | "348122" | 3 | 7.65 | "F G63" | "Southampton" | 1 |
6 | "Abelson, Mr. Samuel" | "male" | 0.373695 | 1 | 0 | "P/PP 3381" | 2 | 24.0 | null | "Cherbourg" | 0 |
7 | "Abelson, Mrs. Samuel (Hannah W… | "female" | 0.348643 | 1 | 0 | "P/PP 3381" | 2 | 24.0 | null | "Cherbourg" | 1 |
8 | "Abrahamsson, Mr. Abraham Augus… | "male" | 0.248434 | 0 | 0 | "SOTON/O2 3101284" | 3 | 7.925 | null | "Southampton" | 1 |
9 | "Abrahim, Mrs. Joseph (Sophie H… | "female" | 0.223382 | 0 | 0 | "2657" | 3 | 7.2292 | null | "Cherbourg" | 1 |
"
+ ],
+ "text/plain": [
+ "+-----+-----------------------+--------+---------+---+----------+-------+---------------+----------+\n",
+ "| id | name | sex | age | … | fare | cabin | port_embarked | survived |\n",
+ "| --- | --- | --- | --- | | --- | --- | --- | --- |\n",
+ "| i64 | str | str | f64 | | f64 | str | str | i64 |\n",
+ "+==================================================================================================+\n",
+ "| 0 | Abbing, Mr. Anthony | male | 0.52401 | … | 7.55000 | null | Southampton | 0 |\n",
+ "| 1 | Abbott, Master. | male | 0.16075 | … | 20.25000 | null | Southampton | 0 |\n",
+ "| | Eugene Joseph | | | | | | | |\n",
+ "| 2 | Abbott, Mr. Rossmore | male | 0.19833 | … | 20.25000 | null | Southampton | 0 |\n",
+ "| | Edward | | | | | | | |\n",
+ "| 3 | Abbott, Mrs. Stanton | female | 0.43633 | … | 20.25000 | null | Southampton | 1 |\n",
+ "| | (Rosa Hun… | | | | | | | |\n",
+ "| 4 | Abelseth, Miss. Karen | female | 0.19833 | … | 7.65000 | null | Southampton | 1 |\n",
+ "| | Marie | | | | | | | |\n",
+ "| 5 | Abelseth, Mr. Olaus | male | 0.31106 | … | 7.65000 | F G63 | Southampton | 1 |\n",
+ "| | Jorgensen | | | | | | | |\n",
+ "| 6 | Abelson, Mr. Samuel | male | 0.37369 | … | 24.00000 | null | Cherbourg | 0 |\n",
+ "| 7 | Abelson, Mrs. Samuel | female | 0.34864 | … | 24.00000 | null | Cherbourg | 1 |\n",
+ "| | (Hannah W… | | | | | | | |\n",
+ "| 8 | Abrahamsson, Mr. | male | 0.24843 | … | 7.92500 | null | Southampton | 1 |\n",
+ "| | Abraham Augus… | | | | | | | |\n",
+ "| 9 | Abrahim, Mrs. Joseph | female | 0.22338 | … | 7.22920 | null | Cherbourg | 1 |\n",
+ "| | (Sophie H… | | | | | | | |\n",
+ "+-----+-----------------------+--------+---------+---+----------+-------+---------------+----------+"
+ ]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
- "execution_count": 11
+ "source": [
+ "from safeds.data.tabular.transformation import RangeScaler\n",
+ "\n",
+ "scaler = RangeScaler(column_names=\"age\", min_=0.0, max_=1.0).fit(titanic)\n",
+ "scaler.transform(titanic_slice)"
+ ]
},
{
"cell_type": "markdown",
- "source": [
- "5. Transform table using `StandardScaler`, this will standardize values of chosen `Column`s:"
- ],
"metadata": {
"collapsed": false
- }
+ },
+ "source": [
+ "5. Transform table using `StandardScaler`, this will standardize values of chosen `Column`s:"
+ ]
},
{
"cell_type": "code",
- "source": [
- "from safeds.data.tabular.transformation import StandardScaler\n",
- "\n",
- "scaler = StandardScaler(column_names=[\"age\", \"travel_class\"]).fit(titanic)\n",
- "scaler.transform(titanic_slice)"
- ],
+ "execution_count": 12,
"metadata": {
- "collapsed": false,
"ExecuteTime": {
"end_time": "2024-05-24T11:02:33.604030100Z",
"start_time": "2024-05-24T11:02:33.486926500Z"
- }
+ },
+ "collapsed": false
},
"outputs": [
{
"data": {
- "text/plain": "+-----+----------------------+--------+----------+---+----------+-------+---------------+----------+\n| id | name | sex | age | … | fare | cabin | port_embarked | survived |\n| --- | --- | --- | --- | | --- | --- | --- | --- |\n| i64 | str | str | f64 | | f64 | str | str | i64 |\n+==================================================================================================+\n| 0 | Abbing, Mr. Anthony | male | 0.84120 | … | 7.55000 | null | Southampton | 0 |\n| 1 | Abbott, Master. | male | -1.17176 | … | 20.25000 | null | Southampton | 0 |\n| | Eugene Joseph | | | | | | | |\n| 2 | Abbott, Mr. Rossmore | male | -0.96353 | … | 20.25000 | null | Southampton | 0 |\n| | Edward | | | | | | | |\n| 3 | Abbott, Mrs. Stanton | female | 0.35531 | … | 20.25000 | null | Southampton | 1 |\n| | (Rosa Hun… | | | | | | | |\n| 4 | Abelseth, Miss. | female | -0.96353 | … | 7.65000 | null | Southampton | 1 |\n| | Karen Marie | | | | | | | |\n| 5 | Abelseth, Mr. Olaus | male | -0.33881 | … | 7.65000 | F G63 | Southampton | 1 |\n| | Jorgensen | | | | | | | |\n| 6 | Abelson, Mr. Samuel | male | 0.00825 | … | 24.00000 | null | Cherbourg | 0 |\n| 7 | Abelson, Mrs. Samuel | female | -0.13057 | … | 24.00000 | null | Cherbourg | 1 |\n| | (Hannah W… | | | | | | | |\n| 8 | Abrahamsson, Mr. | male | -0.68588 | … | 7.92500 | null | Southampton | 1 |\n| | Abraham Augus… | | | | | | | |\n| 9 | Abrahim, Mrs. Joseph | female | -0.82470 | … | 7.22920 | null | Cherbourg | 1 |\n| | (Sophie H… | | | | | | | |\n+-----+----------------------+--------+----------+---+----------+-------+---------------+----------+",
- "text/html": "\n
shape: (10, 12)id | name | sex | age | siblings_spouses | parents_children | ticket | travel_class | fare | cabin | port_embarked | survived |
---|
i64 | str | str | f64 | i64 | i64 | str | f64 | f64 | str | str | i64 |
0 | "Abbing, Mr. Anthony" | "male" | 0.841202 | 0 | 0 | "C.A. 5547" | 0.841916 | 7.55 | null | "Southampton" | 0 |
1 | "Abbott, Master. Eugene Joseph" | "male" | -1.171763 | 0 | 2 | "C.A. 2673" | 0.841916 | 20.25 | null | "Southampton" | 0 |
2 | "Abbott, Mr. Rossmore Edward" | "male" | -0.963526 | 1 | 1 | "C.A. 2673" | 0.841916 | 20.25 | null | "Southampton" | 0 |
3 | "Abbott, Mrs. Stanton (Rosa Hun… | "female" | 0.355314 | 1 | 1 | "C.A. 2673" | 0.841916 | 20.25 | null | "Southampton" | 1 |
4 | "Abelseth, Miss. Karen Marie" | "female" | -0.963526 | 0 | 0 | "348125" | 0.841916 | 7.65 | null | "Southampton" | 1 |
5 | "Abelseth, Mr. Olaus Jorgensen" | "male" | -0.338812 | 0 | 0 | "348122" | 0.841916 | 7.65 | "F G63" | "Southampton" | 1 |
6 | "Abelson, Mr. Samuel" | "male" | 0.008251 | 1 | 0 | "P/PP 3381" | -0.352091 | 24.0 | null | "Cherbourg" | 0 |
7 | "Abelson, Mrs. Samuel (Hannah W… | "female" | -0.130574 | 1 | 0 | "P/PP 3381" | -0.352091 | 24.0 | null | "Cherbourg" | 1 |
8 | "Abrahamsson, Mr. Abraham Augus… | "male" | -0.685875 | 0 | 0 | "SOTON/O2 3101284" | 0.841916 | 7.925 | null | "Southampton" | 1 |
9 | "Abrahim, Mrs. Joseph (Sophie H… | "female" | -0.8247 | 0 | 0 | "2657" | 0.841916 | 7.2292 | null | "Cherbourg" | 1 |
"
+ "text/html": [
+ "\n",
+ "
shape: (10, 12)id | name | sex | age | siblings_spouses | parents_children | ticket | travel_class | fare | cabin | port_embarked | survived |
---|
i64 | str | str | f64 | i64 | i64 | str | f64 | f64 | str | str | i64 |
0 | "Abbing, Mr. Anthony" | "male" | 0.841202 | 0 | 0 | "C.A. 5547" | 0.841916 | 7.55 | null | "Southampton" | 0 |
1 | "Abbott, Master. Eugene Joseph" | "male" | -1.171763 | 0 | 2 | "C.A. 2673" | 0.841916 | 20.25 | null | "Southampton" | 0 |
2 | "Abbott, Mr. Rossmore Edward" | "male" | -0.963526 | 1 | 1 | "C.A. 2673" | 0.841916 | 20.25 | null | "Southampton" | 0 |
3 | "Abbott, Mrs. Stanton (Rosa Hun… | "female" | 0.355314 | 1 | 1 | "C.A. 2673" | 0.841916 | 20.25 | null | "Southampton" | 1 |
4 | "Abelseth, Miss. Karen Marie" | "female" | -0.963526 | 0 | 0 | "348125" | 0.841916 | 7.65 | null | "Southampton" | 1 |
5 | "Abelseth, Mr. Olaus Jorgensen" | "male" | -0.338812 | 0 | 0 | "348122" | 0.841916 | 7.65 | "F G63" | "Southampton" | 1 |
6 | "Abelson, Mr. Samuel" | "male" | 0.008251 | 1 | 0 | "P/PP 3381" | -0.352091 | 24.0 | null | "Cherbourg" | 0 |
7 | "Abelson, Mrs. Samuel (Hannah W… | "female" | -0.130574 | 1 | 0 | "P/PP 3381" | -0.352091 | 24.0 | null | "Cherbourg" | 1 |
8 | "Abrahamsson, Mr. Abraham Augus… | "male" | -0.685875 | 0 | 0 | "SOTON/O2 3101284" | 0.841916 | 7.925 | null | "Southampton" | 1 |
9 | "Abrahim, Mrs. Joseph (Sophie H… | "female" | -0.8247 | 0 | 0 | "2657" | 0.841916 | 7.2292 | null | "Cherbourg" | 1 |
"
+ ],
+ "text/plain": [
+ "+-----+----------------------+--------+----------+---+----------+-------+---------------+----------+\n",
+ "| id | name | sex | age | … | fare | cabin | port_embarked | survived |\n",
+ "| --- | --- | --- | --- | | --- | --- | --- | --- |\n",
+ "| i64 | str | str | f64 | | f64 | str | str | i64 |\n",
+ "+==================================================================================================+\n",
+ "| 0 | Abbing, Mr. Anthony | male | 0.84120 | … | 7.55000 | null | Southampton | 0 |\n",
+ "| 1 | Abbott, Master. | male | -1.17176 | … | 20.25000 | null | Southampton | 0 |\n",
+ "| | Eugene Joseph | | | | | | | |\n",
+ "| 2 | Abbott, Mr. Rossmore | male | -0.96353 | … | 20.25000 | null | Southampton | 0 |\n",
+ "| | Edward | | | | | | | |\n",
+ "| 3 | Abbott, Mrs. Stanton | female | 0.35531 | … | 20.25000 | null | Southampton | 1 |\n",
+ "| | (Rosa Hun… | | | | | | | |\n",
+ "| 4 | Abelseth, Miss. | female | -0.96353 | … | 7.65000 | null | Southampton | 1 |\n",
+ "| | Karen Marie | | | | | | | |\n",
+ "| 5 | Abelseth, Mr. Olaus | male | -0.33881 | … | 7.65000 | F G63 | Southampton | 1 |\n",
+ "| | Jorgensen | | | | | | | |\n",
+ "| 6 | Abelson, Mr. Samuel | male | 0.00825 | … | 24.00000 | null | Cherbourg | 0 |\n",
+ "| 7 | Abelson, Mrs. Samuel | female | -0.13057 | … | 24.00000 | null | Cherbourg | 1 |\n",
+ "| | (Hannah W… | | | | | | | |\n",
+ "| 8 | Abrahamsson, Mr. | male | -0.68588 | … | 7.92500 | null | Southampton | 1 |\n",
+ "| | Abraham Augus… | | | | | | | |\n",
+ "| 9 | Abrahim, Mrs. Joseph | female | -0.82470 | … | 7.22920 | null | Cherbourg | 1 |\n",
+ "| | (Sophie H… | | | | | | | |\n",
+ "+-----+----------------------+--------+----------+---+----------+-------+---------------+----------+"
+ ]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
- "execution_count": 12
+ "source": [
+ "from safeds.data.tabular.transformation import StandardScaler\n",
+ "\n",
+ "scaler = StandardScaler(column_names=[\"age\", \"travel_class\"]).fit(titanic)\n",
+ "scaler.transform(titanic_slice)"
+ ]
},
{
"cell_type": "markdown",
+ "metadata": {
+ "collapsed": false
+ },
"source": [
"## Transform column\n",
"\n",
"1. Transform values of \"parents_children\" `Column` into true or false, depending on whether passenger travelled with parents or children:"
- ],
- "metadata": {
- "collapsed": false
- }
+ ]
},
{
"cell_type": "code",
- "source": [
- "titanic_slice.transform_column(\"parents_children\", lambda cell: cell > 0)"
- ],
+ "execution_count": 13,
"metadata": {
- "collapsed": false,
"ExecuteTime": {
"end_time": "2024-05-24T11:02:33.615541800Z",
"start_time": "2024-05-24T11:02:33.494976800Z"
- }
+ },
+ "collapsed": false
},
"outputs": [
{
"data": {
- "text/plain": "+-----+----------------------+--------+----------+---+----------+-------+---------------+----------+\n| id | name | sex | age | … | fare | cabin | port_embarked | survived |\n| --- | --- | --- | --- | | --- | --- | --- | --- |\n| i64 | str | str | f64 | | f64 | str | str | i64 |\n+==================================================================================================+\n| 0 | Abbing, Mr. Anthony | male | 42.00000 | … | 7.55000 | null | Southampton | 0 |\n| 1 | Abbott, Master. | male | 13.00000 | … | 20.25000 | null | Southampton | 0 |\n| | Eugene Joseph | | | | | | | |\n| 2 | Abbott, Mr. Rossmore | male | 16.00000 | … | 20.25000 | null | Southampton | 0 |\n| | Edward | | | | | | | |\n| 3 | Abbott, Mrs. Stanton | female | 35.00000 | … | 20.25000 | null | Southampton | 1 |\n| | (Rosa Hun… | | | | | | | |\n| 4 | Abelseth, Miss. | female | 16.00000 | … | 7.65000 | null | Southampton | 1 |\n| | Karen Marie | | | | | | | |\n| 5 | Abelseth, Mr. Olaus | male | 25.00000 | … | 7.65000 | F G63 | Southampton | 1 |\n| | Jorgensen | | | | | | | |\n| 6 | Abelson, Mr. Samuel | male | 30.00000 | … | 24.00000 | null | Cherbourg | 0 |\n| 7 | Abelson, Mrs. Samuel | female | 28.00000 | … | 24.00000 | null | Cherbourg | 1 |\n| | (Hannah W… | | | | | | | |\n| 8 | Abrahamsson, Mr. | male | 20.00000 | … | 7.92500 | null | Southampton | 1 |\n| | Abraham Augus… | | | | | | | |\n| 9 | Abrahim, Mrs. Joseph | female | 18.00000 | … | 7.22920 | null | Cherbourg | 1 |\n| | (Sophie H… | | | | | | | |\n+-----+----------------------+--------+----------+---+----------+-------+---------------+----------+",
- "text/html": "\n
shape: (10, 12)id | name | sex | age | siblings_spouses | parents_children | ticket | travel_class | fare | cabin | port_embarked | survived |
---|
i64 | str | str | f64 | i64 | bool | str | i64 | f64 | str | str | i64 |
0 | "Abbing, Mr. Anthony" | "male" | 42.0 | 0 | false | "C.A. 5547" | 3 | 7.55 | null | "Southampton" | 0 |
1 | "Abbott, Master. Eugene Joseph" | "male" | 13.0 | 0 | true | "C.A. 2673" | 3 | 20.25 | null | "Southampton" | 0 |
2 | "Abbott, Mr. Rossmore Edward" | "male" | 16.0 | 1 | true | "C.A. 2673" | 3 | 20.25 | null | "Southampton" | 0 |
3 | "Abbott, Mrs. Stanton (Rosa Hun… | "female" | 35.0 | 1 | true | "C.A. 2673" | 3 | 20.25 | null | "Southampton" | 1 |
4 | "Abelseth, Miss. Karen Marie" | "female" | 16.0 | 0 | false | "348125" | 3 | 7.65 | null | "Southampton" | 1 |
5 | "Abelseth, Mr. Olaus Jorgensen" | "male" | 25.0 | 0 | false | "348122" | 3 | 7.65 | "F G63" | "Southampton" | 1 |
6 | "Abelson, Mr. Samuel" | "male" | 30.0 | 1 | false | "P/PP 3381" | 2 | 24.0 | null | "Cherbourg" | 0 |
7 | "Abelson, Mrs. Samuel (Hannah W… | "female" | 28.0 | 1 | false | "P/PP 3381" | 2 | 24.0 | null | "Cherbourg" | 1 |
8 | "Abrahamsson, Mr. Abraham Augus… | "male" | 20.0 | 0 | false | "SOTON/O2 3101284" | 3 | 7.925 | null | "Southampton" | 1 |
9 | "Abrahim, Mrs. Joseph (Sophie H… | "female" | 18.0 | 0 | false | "2657" | 3 | 7.2292 | null | "Cherbourg" | 1 |
"
+ "text/html": [
+ "\n",
+ "
shape: (10, 12)id | name | sex | age | siblings_spouses | parents_children | ticket | travel_class | fare | cabin | port_embarked | survived |
---|
i64 | str | str | f64 | i64 | bool | str | i64 | f64 | str | str | i64 |
0 | "Abbing, Mr. Anthony" | "male" | 42.0 | 0 | false | "C.A. 5547" | 3 | 7.55 | null | "Southampton" | 0 |
1 | "Abbott, Master. Eugene Joseph" | "male" | 13.0 | 0 | true | "C.A. 2673" | 3 | 20.25 | null | "Southampton" | 0 |
2 | "Abbott, Mr. Rossmore Edward" | "male" | 16.0 | 1 | true | "C.A. 2673" | 3 | 20.25 | null | "Southampton" | 0 |
3 | "Abbott, Mrs. Stanton (Rosa Hun… | "female" | 35.0 | 1 | true | "C.A. 2673" | 3 | 20.25 | null | "Southampton" | 1 |
4 | "Abelseth, Miss. Karen Marie" | "female" | 16.0 | 0 | false | "348125" | 3 | 7.65 | null | "Southampton" | 1 |
5 | "Abelseth, Mr. Olaus Jorgensen" | "male" | 25.0 | 0 | false | "348122" | 3 | 7.65 | "F G63" | "Southampton" | 1 |
6 | "Abelson, Mr. Samuel" | "male" | 30.0 | 1 | false | "P/PP 3381" | 2 | 24.0 | null | "Cherbourg" | 0 |
7 | "Abelson, Mrs. Samuel (Hannah W… | "female" | 28.0 | 1 | false | "P/PP 3381" | 2 | 24.0 | null | "Cherbourg" | 1 |
8 | "Abrahamsson, Mr. Abraham Augus… | "male" | 20.0 | 0 | false | "SOTON/O2 3101284" | 3 | 7.925 | null | "Southampton" | 1 |
9 | "Abrahim, Mrs. Joseph (Sophie H… | "female" | 18.0 | 0 | false | "2657" | 3 | 7.2292 | null | "Cherbourg" | 1 |
"
+ ],
+ "text/plain": [
+ "+-----+----------------------+--------+----------+---+----------+-------+---------------+----------+\n",
+ "| id | name | sex | age | … | fare | cabin | port_embarked | survived |\n",
+ "| --- | --- | --- | --- | | --- | --- | --- | --- |\n",
+ "| i64 | str | str | f64 | | f64 | str | str | i64 |\n",
+ "+==================================================================================================+\n",
+ "| 0 | Abbing, Mr. Anthony | male | 42.00000 | … | 7.55000 | null | Southampton | 0 |\n",
+ "| 1 | Abbott, Master. | male | 13.00000 | … | 20.25000 | null | Southampton | 0 |\n",
+ "| | Eugene Joseph | | | | | | | |\n",
+ "| 2 | Abbott, Mr. Rossmore | male | 16.00000 | … | 20.25000 | null | Southampton | 0 |\n",
+ "| | Edward | | | | | | | |\n",
+ "| 3 | Abbott, Mrs. Stanton | female | 35.00000 | … | 20.25000 | null | Southampton | 1 |\n",
+ "| | (Rosa Hun… | | | | | | | |\n",
+ "| 4 | Abelseth, Miss. | female | 16.00000 | … | 7.65000 | null | Southampton | 1 |\n",
+ "| | Karen Marie | | | | | | | |\n",
+ "| 5 | Abelseth, Mr. Olaus | male | 25.00000 | … | 7.65000 | F G63 | Southampton | 1 |\n",
+ "| | Jorgensen | | | | | | | |\n",
+ "| 6 | Abelson, Mr. Samuel | male | 30.00000 | … | 24.00000 | null | Cherbourg | 0 |\n",
+ "| 7 | Abelson, Mrs. Samuel | female | 28.00000 | … | 24.00000 | null | Cherbourg | 1 |\n",
+ "| | (Hannah W… | | | | | | | |\n",
+ "| 8 | Abrahamsson, Mr. | male | 20.00000 | … | 7.92500 | null | Southampton | 1 |\n",
+ "| | Abraham Augus… | | | | | | | |\n",
+ "| 9 | Abrahim, Mrs. Joseph | female | 18.00000 | … | 7.22920 | null | Cherbourg | 1 |\n",
+ "| | (Sophie H… | | | | | | | |\n",
+ "+-----+----------------------+--------+----------+---+----------+-------+---------------+----------+"
+ ]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
- "execution_count": 13
+ "source": [
+ "titanic_slice.transform_column(\"parents_children\", lambda cell: cell > 0)"
+ ]
}
],
"metadata": {
diff --git a/src/safeds/data/tabular/transformation/_range_scaler.py b/src/safeds/data/tabular/transformation/_range_scaler.py
index c54b60dc8..3a93be88b 100644
--- a/src/safeds/data/tabular/transformation/_range_scaler.py
+++ b/src/safeds/data/tabular/transformation/_range_scaler.py
@@ -37,13 +37,7 @@ class RangeScaler(InvertibleTableTransformer):
# Dunder methods
# ------------------------------------------------------------------------------------------------------------------
- def __init__(
- self,
- min_: float = 0.0,
- max_: float = 1.0,
- *,
- column_names: str | list[str] | None = None,
- ) -> None:
+ def __init__(self, *, column_names: str | list[str] | None = None, min_: float = 0.0, max_: float = 1.0) -> None:
super().__init__(column_names)
if min_ >= max_: