-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[ENH] Table: Add methods get_column and set_column #6058
Conversation
As you say, using For me, this is a confusing mixture of two very different behaviors. It implies a fast operation. So I do not like the name. I do not have any better ideas though. |
Would it be possible to have something similar to pandas' |
@ajdapretnar, that would be more messing with the data structure. :) Especially in this case because the actual variable (with its compute value) is important, not the name. Now I think I'd deprecate Slightly related: do we ever enforce what shape functions doing |
I checked what should the
For dense arrays, Slicing on sparse matrices, on the other hand, always returns something that is 2D, because they do not have 1D slices at all. For now, the output shape of this |
You're right, the result of What about sparse data? We could also request
Me too, but its everywhere and we'll never remove it. We can just recommend not using it.
There may be cases when one needs a view, e.g. because you just created and unlocked a table. As current function does not really always give a view, but it has a good name that we can't reuse: the function (Setting both |
7d5be06
to
58a7280
Compare
6e09a84
to
123ad30
Compare
123ad30
to
4b8aa55
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #6058 +/- ##
=======================================
Coverage 86.65% 86.65%
=======================================
Files 315 315
Lines 67957 67974 +17
=======================================
+ Hits 58890 58905 +15
- Misses 9067 9069 +2 |
8cb7f58
to
ee199e0
Compare
ee199e0
to
d347de5
Compare
d347de5
to
7137d0d
Compare
@janezd, thanks for this. All the new usages look much simpler, especially when the values needed to be set. Merging as soon as the tests pass. |
Issue
There are two differences between
data.get_column_view(x)[0]
anddata.transform(Domain([x]).X[:, 0]
.If using Text to Columns used
get_column_view
, Apply Domain could not apply the second transformation because the required attribute (discretized petal length) is not in the domain.Using
transform
works because it invokescompute_value
.Description of changes
Add
Table.get_column
which should be preferred overTable.get_column_view
, and must be used in places where the variable is not guaranteed to exist (in particular, incompute_value
functions).If the column exists, it calls
get_column_view
, otherwise it usescompute_value
.Includes