Repository navigation
Conversation
|
@mhvk - Wow, nice to see the exploratory PR! I had spent an hour mucking about in the same direction but didn't get this far. We both ran into the same issue of non-numeric Columns. I wonder if there is any fundamental reason that Quantity cannot support non-numeric values with a requirement that there be no unit ( |
|
I'd probably rather that QuantityColumns were only used for numeric columns, and not try to chunk on even more functionality to get it to work on strings--I think that's asking for trouble. Given that QuantityColumn is a subclass of Column there's no reason a table can't have a mix of both. You could even modify the |
|
@taldcroft - interesting thought. Although I share some of @embray's reservations, I'll still look at A possible advantage still would be that |
|
closing this in favour of the more general #1839. |
While looking again at #1540, I realised that to have table columns behave like quantities, it is not good enough to just add some methods, as, e.g.,
c.mean()should produce a quantity, not just a number. One more complete solution is to subclass. Fortunately, withsuperthis is surprisingly easy, as shown in this PR. Note especially the lovely definitionSome notes:
MaskedQuantityimplementation.table.join, etc.).unitonly changes the nature of theColumnif it is already part of aTable(where I use_rebuild_table_column_views). I don't know how to handle a column by itself.unit(Quantities should allow in-place change to compatible units #1253 rears its head!).Columnstill will be; for numerical cases, aQuantityColumnwithunit=''would always seem more appropriate.Anyway, for now it is fun being able to do things like