# I might have missed this but why is \`head(df::AbstractDataFrame)\` deprecated?

**URL:** <https://discourse.julialang.org/t/i-might-have-missed-this-but-why-is-head-df-abstractdataframe-deprecated/27988>\
**Category:** Data\
**Created:** [August 26, 2019, 7:42am UTC](https://discourse.julialang.org/t/i-might-have-missed-this-but-why-is-head-df-abstractdataframe-deprecated/27988 "2019-08-26T07:42:53Z")\
**Posts on this page:** 13\
**Page:** 3

<div class="post-metadata">

**Author:** ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Post date:** [May 12, 2021, 12:10pm UTC](https://discourse.julialang.org/t/i-might-have-missed-this-but-why-is-head-df-abstractdataframe-deprecated/27988/41 "2021-05-12T12:10:53Z")

</div>

This is the point that we do not want `?head` to work. I will expand on it in my blog post.

The issue is that it steals `head` as a variable name in global scope. And `head` is a very common name to use in user’s code.

E.g. we had H2O benchmarks for DataFrames.jl not running correctly for ~2 weeks due to a similar issue. One of the reasons why benchmarks were failing (as there were more in general) was that in these benchmarks a `big` variable name was used and it conflicts with `big` function in Julia Base (I sent a patch to H2O benchmarks to fix it and now all is OK). Such things are hard to avoid of course, but the point is that we do not want to pollute global namespace with common names like `head`.

Of course in case of `big` it is a name defined in Julia Base, so it should ideally not be used in user’s code. However, `big` is used very seldom in practice and most users do not even know about it so it is super easy to introduce a name clash, especially if one is a casual user who is not deep into all details of the language.

---

<div class="post-metadata">

**Author:** ![ptoche](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ptoche/32/23554_2.png) [@ptoche](https://discourse.julialang.org/u/ptoche)\
**Post date:** [May 12, 2021, 12:39pm UTC](https://discourse.julialang.org/t/i-might-have-missed-this-but-why-is-head-df-abstractdataframe-deprecated/27988/42 "2021-05-12T12:39:17Z")

</div>

I was suggesting making `?head` direct to `first`, **not making it available as a variable name.**

One problem right now is if you google DataFrames you are taken to `R` code or `Pandas` code. And Julia’s presence on `stackoverflow` is overwhelmed by `Python`. The second link after this one when you google `julia dataframes head` is [Getting Started · DataFrames.jl](https://dataframes.juliadata.org/v0.11/man/getting_started.html). And that’s not a great place to start.

---

<div class="post-metadata">

**Author:** ![johnmyleswhite](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnmyleswhite/32/31_2.png) [@johnmyleswhite](https://discourse.julialang.org/u/johnmyleswhite)\
**Post date:** [May 12, 2021, 12:49pm UTC](https://discourse.julialang.org/t/i-might-have-missed-this-but-why-is-head-df-abstractdataframe-deprecated/27988/43 "2021-05-12T12:49:45Z")

</div>

> [@ptoche](#):
>
> I was suggesting making `?head` direct to `first` , **not making it available as a variable name.**

This is an interesting suggestion conceptually, but the concrete way the help system works links these experiences – you can’t get one without the other.

---

<div class="post-metadata">

**Author:** ![ptoche](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ptoche/32/23554_2.png) [@ptoche](https://discourse.julialang.org/u/ptoche)\
**Post date:** [May 12, 2021, 1:05pm UTC](https://discourse.julialang.org/t/i-might-have-missed-this-but-why-is-head-df-abstractdataframe-deprecated/27988/44 "2021-05-12T13:05:41Z")

</div>

Oh! I didn’t realize that. In that case we need to improve Google. 😉

Edit: `R` has `??` (aka help-search), which searches the help system for documentation matching a given character string. But setting that up would be a big undertaking I imagine.

---

<div class="post-metadata">

**Author:** ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Post date:** [May 12, 2021, 1:06pm UTC](https://discourse.julialang.org/t/i-might-have-missed-this-but-why-is-head-df-abstractdataframe-deprecated/27988/45 "2021-05-12T13:06:41Z")

</div>

@nalimilan + @viralbshah (as both of you were updating handling of DataFrames.jl documentation web pages):  
Do you know if it is possible to disable links like [Getting Started · DataFrames.jl](https://dataframes.juliadata.org/v0.11/man/getting_started.html) that lead to an extremely outdated documentation?

---

<div class="post-metadata">

**Author:** ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)\
**Post date:** [May 12, 2021, 1:20pm UTC](https://discourse.julialang.org/t/i-might-have-missed-this-but-why-is-head-df-abstractdataframe-deprecated/27988/46 "2021-05-12T13:20:04Z")

</div>

> [@ptoche](#):
>
> `R` has `??` (aka help-search), which searches the help system for documentation matching a given character string.

Julia has `apropos`. Trying `apropos("head")` gives too many results, `apropos(r"\bhead\b")` is better but doesn’t point to `first` (yet 🙂 ).

Maybe the system could be extended, e.g. with docstrings declaring tags, and tag matches could be shown first…

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [May 12, 2021, 1:31pm UTC](https://discourse.julialang.org/t/i-might-have-missed-this-but-why-is-head-df-abstractdataframe-deprecated/27988/47 "2021-05-12T13:31:32Z")

</div>

I have a script [here](https://gist.github.com/pfitzseb/4b910449e21b51fed4b4a2a7c20912ff) that runs over a package’s documentation and inserts a big(ish) red popup that notifies the user that the current docs are outdated (see e.g. [this](https://diffeq.sciml.ai/v4.0/)).

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [May 12, 2021, 1:47pm UTC](https://discourse.julialang.org/t/i-might-have-missed-this-but-why-is-head-df-abstractdataframe-deprecated/27988/48 "2021-05-12T13:47:11Z")

</div>

> [@ptoche](#):
>
> `R` has `??` (aka help-search),

Julia also has that, you can do e.g. `?"search"` and you’ll get a list of objects whos docstring contains the given string.

---

<div class="post-metadata">

**Author:** ![ptoche](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ptoche/32/23554_2.png) [@ptoche](https://discourse.julialang.org/u/ptoche)\
**Post date:** [May 12, 2021, 2:00pm UTC](https://discourse.julialang.org/t/i-might-have-missed-this-but-why-is-head-df-abstractdataframe-deprecated/27988/49 "2021-05-12T14:00:51Z")

</div>

please forgive my ignorance, these are some great options!

`?"head"` is easy enough to remember. The [docs](https://docs.julialang.org/en/v1/stdlib/InteractiveUtils/#Base.Docs.apropos) don’t say, but it looks equivalent to `apropos("head")`. 👍

---

<div class="post-metadata">

**Author:** ![ptoche](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ptoche/32/23554_2.png) [@ptoche](https://discourse.julialang.org/u/ptoche)\
**Post date:** [May 12, 2021, 9:55pm UTC](https://discourse.julialang.org/t/i-might-have-missed-this-but-why-is-head-df-abstractdataframe-deprecated/27988/50 "2021-05-12T21:55:22Z")

</div>

Is there a feature whereby package creators could make a dictionary of strings they want to prioritize in the `apropos` search? `Dict(“head” => "was deprecated in favor of first as of version x.x.x. See also tail"). Then the dictionary entry would be listed first when `apropos(“head”)` is called.

---

<div class="post-metadata">

**Author:** ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Post date:** [May 13, 2021, 3:02am UTC](https://discourse.julialang.org/t/i-might-have-missed-this-but-why-is-head-df-abstractdataframe-deprecated/27988/51 "2021-05-13T03:02:14Z")

</div>

> [@ptoche](#):
>
> Is there a feature whereby package creators could make a dictionary of strings they want to prioritize in the `apropos` search?

Not that I know of, would be pretty cool. There’s still a lot of open real estate in the not-essential-but-would-be-nice tooling arena. Mostly I suspect stuff like this will need to be in packages, but 🤷‍♂️.

Also, to pivot back to this exchange -

> [@xiaodai](#):
>
> > [@ptoche](#):
> >
> > Have you considered making a small package `DataFramesExtra`
> 
> No. Have you?

I think @xiaodai 's point was that if this is something that appeals to you, I wouldn’t be that hard to implement.

```julia
module DataFramesPlus

export head, tail

using Reexport
@reexport using DataFrames

head(df:: AbstractDataFrame, n=10) = first(df, min(n, nrow(df)))

tail(df:: AbstractDataFrame, n=10) = last(df, min(n, nrow(df)))

end

```

… should maybe work? I didn’t test it. It’s technically type piracy, but if you’re cool with that 🕶

More concretely, I personally don’t **want** @bkamins working on anything else - his efforts on DataFrames itself (not just development, but also blog posts etc) are already beyond what could reasonably be expected.

But Julia makes it absurdly easy to roll your own solution for things like this, and there may be others that are in the same boat and would use it too. My own solution is to just stick with Julia for everything so I don’t get confused 😜

---

<div class="post-metadata">

**Author:** ![ptoche](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ptoche/32/23554_2.png) [@ptoche](https://discourse.julialang.org/u/ptoche)\
**Post date:** [May 13, 2021, 8:56pm UTC](https://discourse.julialang.org/t/i-might-have-missed-this-but-why-is-head-df-abstractdataframe-deprecated/27988/52 "2021-05-13T20:56:28Z")

</div>

Thanks for sharing this Kevin: I would not have known about `Reexport` and would have copied entire definitions. Excellent to know. I won’t be needing this right away as our discussion will make me remember `first` and `last` for some time 😂 (a binding for `??` would be extra lazy). In addition to making more string keywords available to search would be to make them available to autocomplete too (some people hate it, but it’s useful for newbies). As I start typing `first` (after `using DataFrames` of course), I get an autocomplete suggestion. Autocomplete is even clever enough to suggest `first` when I incorrectly type `fist`, which is amazing. Now the crazy idea would be to suggest `first` when I type `head` 🤪

---

<div class="post-metadata">

**Author:** ![ptoche](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ptoche/32/23554_2.png) [@ptoche](https://discourse.julialang.org/u/ptoche)\
**Post date:** [May 13, 2021, 9:08pm UTC](https://discourse.julialang.org/t/i-might-have-missed-this-but-why-is-head-df-abstractdataframe-deprecated/27988/53 "2021-05-13T21:08:32Z")

</div>

To get apropos pickup `"head"`, looks like it would just be a matter of creating a module for that purpose. To rank the terms would be a bit more work. **Edit:** It uses the “Levenshtein Distance”, no wonder it’s so clever. If we could set `distance("first", "head")` to `0` or something small enough…

> <https://github.com/JuliaLang/julia/blob/bb5b98e72a151c41471d8cc14cacb495d647fb7f/stdlib/REPL/src/docview.jl#L799>

[Previous page](https://discourse.julialang.org/t/i-might-have-missed-this-but-why-is-head-df-abstractdataframe-deprecated/27988.md?page=2)
