Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HEI-422] Make it possible to change specific cell values in the dataset. #126

Open
wants to merge 1 commit into
base: dev/architecture_v11
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions hypex/dataset/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ def __getitem__(self, item) -> "Dataset":
data=t_data,
roles={k: v for k, v in self.roles.items() if k in t_data.columns},
)

def __setitem__(self, item, value):
column_name = item[1]
if column_name not in self.backend.data.columns:
raise KeyError("Column must be added by using add_column method.")
else:
self.backend.data.loc[item] = value

class ILocker:
def __init__(self, backend, roles):
Expand All @@ -66,6 +73,13 @@ def __getitem__(self, item) -> "Dataset":
data=t_data,
roles={k: v for k, v in self.roles.items() if k in t_data.columns},
)

def __setitem__(self, item, value):
column_index = item[1]
if column_index >= len(self.backend.data.columns):
raise IndexError("Column must be added by using add_column method.")
else:
self.backend.data.iloc[item] = value

def __init__(
self,
Expand Down