Skip to content

Commit

Permalink
schema methods to table
Browse files Browse the repository at this point in the history
  • Loading branch information
SmiteDeluxe committed Jan 27, 2023
1 parent 64acb6f commit 5f5d416
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 deletions Runtime/safe-ds/safe_ds/data/_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
UnknownColumnNameError,
)

from ._column_type import ColumnType
from ._column import Column
from ._row import Row
from ._table_schema import TableSchema
Expand Down Expand Up @@ -594,7 +595,8 @@ def add_rows(self, rows: Union[list[Row], Table]) -> Table:

def has_column(self, column_name: str) -> bool:
"""
Returns if the table contains a given column
Alias for self.schema.hasColumn(column_name: str) -> bool.
Returns if the table contains a given column.
Parameters
----------
Expand Down Expand Up @@ -641,14 +643,37 @@ def list_columns_with_non_numerical_values(self) -> list[Column]:

def get_column_names(self) -> list[str]:
"""
Get a list of the ordered column names
Alias for self.schema.get_column_names() -> list[str].
Returns a list of all column names saved in this schema
Returns
-------
result: list[str]
Order Column names
column_names: list[str]
the column names
"""
return list(self.schema._schema.keys())
return self.schema.get_column_names()

def get_type_of_column(self, column_name: str) -> ColumnType:
"""
Alias for self.schema.get_type_of_column(column_name: str) -> ColumnType.
Returns the type of the given column.
Parameters
----------
column_name : str
The name of the column you want the type of
Returns
-------
type: ColumnType
The type of the column
Raises
------
ColumnNameError
If the specified target column name doesn't exist
"""
return self.schema.get_type_of_column(column_name)

def sort_columns(
self,
Expand Down

0 comments on commit 5f5d416

Please sign in to comment.