Skip to content

Add __setitem__ - #165

Merged
gsheni merged 16 commits into
mainfrom
set_item
Sep 29, 2020
Merged

gsheni merged 16 commits into
mainfrom
set_item

Conversation

@tamargrey

Copy link
Copy Markdown
Contributor

closes #120

@codecov

codecov Bot commented Sep 29, 2020 •

Copy link
Copy Markdown

Codecov Report

Merging #165 into main will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #165   +/-   ##
=======================================
  Coverage   99.83%   99.84%           
=======================================
  Files          20       20           
  Lines        1787     1880   +93     
=======================================
+ Hits         1784     1877   +93     
  Misses          3        3           
Impacted Files Coverage Δ
woodwork/data_table.py 100.00% <100.00%> (ø)
woodwork/tests/data_table/test_datatable.py 100.00% <100.00%> (ø)
woodwork/logical_types.py 97.26% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 349a986...f4cf7fa. Read the comment docs.

Comment thread woodwork/data_table.py
raise KeyError(f"Column with name '{key}' not found in DataTable")
return self.columns[key]

def __setitem__(self, col_name, column):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be careful to keep the name of the DataColumn (which is just DataColumn.series.name) in sync with the name we are using for the column in the DataTable. I think by passing a different name here with col_name it is possible that the DataTable will use a name for the column that is different than series.name, which could be confusing if users inspect the underlying values.

Maybe we should just rename the DataColumn.series to match the value the user supplies for col_name to keep things in sync.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I agree with matching to whatever col_name is.

Thoughts on warning the user if they supply a name in the series that doesnt match the col_name that they supplied? Not sure it'd be necessary since going with col_name seems more expected here, but thought I'd bring it up

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems appropriate to raise a warning if we rename the series to alert the user that this was done.

Comment thread woodwork/data_table.py Resolved
Comment thread docs/source/changelog.rst Resolved

@gsheni gsheni left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good overall. Just 1 minor thing.

Comment thread woodwork/data_table.py Resolved
@gsheni
gsheni merged commit 8d535cb into main Sep 29, 2020
@gsheni
gsheni deleted the set_item branch September 29, 2020 20:28
@gsheni gsheni mentioned this pull request Oct 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add __setitem__ to DataTable to create/overwrite an existing DataColumn

3 participants