I do not think it is a major blocker . I think of it as one of these things that are on the border of my personal preference and I acknowledge that people might have diverging opinion on it (that is why when you proposed deprecating it I was OK with this, as you had “big pro deprecation” opinion while I had “very small con deprecation” opinion).
This issue is really minor (but I am OK to discuss it if people want). Compare this to conflicting opinions how plotting should be implemented .
I don’t understand why one would prefer legacy over generality. If there are existing functions that are used all over Base or other packages that make perfect sense in the context of a dataframe, why prefer different names? Just because they are legacy from pandas or R? I could see an argument for the DataFrames use of first not being the same as in Base, but for example why not prefer size(df,1) over nrows(df) when size has a perfectly universal meaning in Julia, is it really that much more typing? I feel like nobody would ask for nrows for an array.
first is a bad pun here: DataFrames per se are not iterable (one has to go through the Tables.jl interface to get a row iterator),
it is not really a good idea to combine the extraction of the first row (a DataFrameRow) and the first n rows (a DataFrame) in a single interface function; that’s like a function sometimes returning a matrix, sometimes a vector,
one should not necessarily introduce a function for either of these, but think about the purpose: the user usually just wants a preview of the dataframe without looking at the whole thing; so just make Base.show print the first and last 10-10 rows or so (currently I think it is 20-20). For the rest, there are the shiny new Base.getindex accessors.
That said, I think these things are the decision of the package maintainers, and the best place to discuss them is in issues. It is great to solicit input from users, but interfaces need a single architect, or possibly a small team of 2-3 individuals, but not more.
head, nrow and other single-argument functions are more convenient for interactive use: DataFrame(...) |> ... some processing ... |> head
vs DataFrame(...) |> ... some processing ... |> x->first(x, 5)
In terms of “conceptual purity”, I agree that, if one needs eachrow to iterate rows, then getting the first row should be first(eachrow(df)) or df[1, :] (esp. since it seems DataFrames are a 2D container in that you need to indices to get a value, unlike for example IndexedTables). Why not simply df[1:6, :] to get the first few rows?
I agree, but I still wonder what the use case is. In R, assignments do not print, and values print in full, so
> df <- data.frame(x = 1:100, y = 101:200)
> head(df)
x y
1 1 101
2 2 102
3 3 103
4 4 104
5 5 105
6 6 106
> df # and this prints 100 lines, not included
and head makes sense. But in Julia we can just make Base.show show a couple of rows from the beginning and the end (this is what is currently done, I would show fewer rows).
What’s the use case from head (or first(..., n)) when we have this?
I do agree that this is a printing issue rather than a function issue. R just spits a lot of data when printing a df and you do need head and tail to make sense of large dataframes. Those functions can be replaced with a nicer output, that does not overwhelm the REPL and allows a quick glance at the df to make sure things worked as expected. I understand a lot of us have a lot of “ticks” and muscle memory patterns coming from R, but when I thought about some of the desing choices in R, they really don’t make much sense, while most of them do in Julia.
Have you considered making a small package DataFramesExtra in which you would dump things like ncol, nrow, head, tail and all these convenience utilities that people from R or Pandas expect to find. Instead of endless discussions, you could point people to the package, while “not recommending it”.
In fact I stopped seeing these discussions for many months now. However, incidentally, this week on my blogpost I planned to comment why we support nrow and ncol but not head and tail. The core of the issue is:
number of verbs the user has to learn
how likely a name clash is when we introduce some exported name
is there already a name in Julia Base that does a similar thing
I completely understand and just as Michael said, it’s just a matter of getting used to it. DataFrames is a fantastic package.
Personally I use R, Python, Julia, Maple, Matlab (and a few more) on and off as the need arises, have become skilled in none of them, and find it difficult to remember right away whether it’s head(df), df.head, first(df), or whatever.
The first step for me is usually:
julia> ?head
When that fails I google for “Julia DataFrames head”. This is how I got to this thread and no doubt will visit again in the future.
Might be useful to have ?head return something like “Couldn’t find head. Perhaps you are looking for first” rather than the current “Couldn’t find head. Perhaps you meant read, …”