Closed baarkerlounger closed 7 years ago
Yes, it is deliberate inconsistency. Ruby's Array works exactly the same way:
a = (1..5).to_a
# => [1, 2, 3, 4, 5]
a[1]
# => 2
a[1,2]
# => [2, 3]
In simple functionality, we always try to follow Ruby's default collections behavior. For rubyists, it will produce least surprise, even despite the inconsistency.
@db579 - Daru a #to_df
method you can use if you want to ensure that the result is always a dataframe. df[:a]
will return a vector, but df[:a].to_df
will return a dataframe with a single vector. Likewise df.to_df
returns df
, so if you are dynamically selecting vectors and there's a chance you may only select one, it's safe to add #to_df
.
Dataframe.row gives your result as a new vector if you specify a single row index but as a dataframe if you provide multiple row indexes. Is that expected? Seems inconsistent?