You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think the "hash of arrays" idea works really well in Squib, but often I'm wondering if we could use more utility methods for this. For example, the data['Name'].size feels like a hack to me - it should just be data.rows or something.
Here's what I have in mind. I'll edit this list over time.
Call it a Squib::DataFrame
It acts like a hash of arrays. So it still supports the [] and returns arrays of values.
It has an #nrows method that returns the maximum length of a column across all columns
It has a #ncolumns method that returns the number of columns
It has a #columns method that returns the column names
It has a pretty_print method that works a lot like my to_json for better version control diff'ing. Can also print out a given card.
It has its own trim_whitespace functionality so that doesn't get duplicated (still gets turned on or off by csv and xlsx).
It has some metaprogramming that allows for dynamic methods to be declared based on snake-cased access to columns. For example data['Actor Name'] could be accessed by data.actor_name. We could even add another method like #bind_them! that dynamically declares methods in Squib::Deck based on column names. Or are these "too magical"?
Provide other validation in its construction, like duplicate columns and stuff.
Quantity explosion is implemented in this class so we're not duplicating code there either
More custom functionality around auto-converting to integers or floats or whatever. Nobody's complained about this yet, but it could be nice for some narrow cases.
The text was updated successfully, but these errors were encountered:
I think the "hash of arrays" idea works really well in Squib, but often I'm wondering if we could use more utility methods for this. For example, the
data['Name'].size
feels like a hack to me - it should just bedata.rows
or something.Here's what I have in mind. I'll edit this list over time.
[]
and returns arrays of values.#nrows
method that returns the maximum length of a column across all columns#ncolumns
method that returns the number of columns#columns
method that returns the column namespretty_print
method that works a lot like myto_json
for better version control diff'ing. Can also print out a given card.csv
andxlsx
).data['Actor Name']
could be accessed bydata.actor_name
. We could even add another method like#bind_them!
that dynamically declares methods inSquib::Deck
based on column names. Or are these "too magical"?The text was updated successfully, but these errors were encountered: