Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate head and tail in favor of first and last #1607

Merged
merged 4 commits into from
Dec 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions docs/src/lib/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ eachcol
eltypes
filter
filter!
head
insertcols!
mapcols
names!
Expand All @@ -51,7 +50,6 @@ repeat
show
sort
sort!
tail
unique!
permutecols!
```
6 changes: 3 additions & 3 deletions docs/src/man/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ julia> df = DataFrame(A = 1:2:1000, B = repeat(1:10, inner=50), C = 1:500)

Printing options can be adjusted by calling the `show` function manually: `show(df, allrows=true)` prints all rows even if they do not fit on screen and `show(df, allcols=true)` does the same for columns.

The `head` and `tail` functions can be used to look at the first and last rows of a data frame (respectively):
The `first` and `last` functions can be used to look at the first and last rows of a data frame (respectively):

```jldoctest dataframe
julia> head(df)
julia> first(df, 6)
6×3 DataFrame
│ Row │ A │ B │ C │
│ │ Int64 │ Int64 │ Int64 │
Expand All @@ -223,7 +223,7 @@ julia> head(df)
│ 5 │ 9 │ 1 │ 5 │
│ 6 │ 11 │ 1 │ 6 │

julia> tail(df)
julia> last(df, 6)
6×3 DataFrame
│ Row │ A │ B │ C │
│ │ Int64 │ Int64 │ Int64 │
Expand Down
43 changes: 21 additions & 22 deletions docs/src/man/reshaping_and_pivoting.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ julia> using DataFrames, CSV

julia> iris = CSV.read(joinpath(dirname(pathof(DataFrames)), "../test/data/iris.csv"));

julia> head(iris)
julia> first(iris, 6)
6×5 DataFrame
│ Row │ SepalLength │ SepalWidth │ PetalLength │ PetalWidth │ Species │
│ │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Categorical…⍰ │
Expand All @@ -19,7 +19,7 @@ julia> head(iris)
│ 5 │ 5.0 │ 3.6 │ 1.4 │ 0.2 │ setosa │
│ 6 │ 5.4 │ 3.9 │ 1.7 │ 0.4 │ setosa │

julia> tail(iris)
julia> last(iris, 6)
6×5 DataFrame
│ Row │ SepalLength │ SepalWidth │ PetalLength │ PetalWidth │ Species │
│ │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Categorical…⍰ │
Expand All @@ -33,7 +33,7 @@ julia> tail(iris)

julia> d = stack(iris, 1:4);

julia> head(d)
julia> first(d, 6)
6×3 DataFrame
│ Row │ variable │ value │ Species │
│ │ Symbol │ Float64⍰ │ Categorical…⍰ │
Expand All @@ -45,7 +45,7 @@ julia> head(d)
│ 5 │ SepalLength │ 5.0 │ setosa │
│ 6 │ SepalLength │ 5.4 │ setosa │

julia> tail(d)
julia> last(d, 6)
6×3 DataFrame
│ Row │ variable │ value │ Species │
│ │ Symbol │ Float64⍰ │ Categorical…⍰ │
Expand All @@ -63,7 +63,7 @@ The second optional argument to `stack` indicates the columns to be stacked. The
```jldoctest reshape
julia> d = stack(iris, [:SepalLength, :SepalWidth, :PetalLength, :PetalWidth]);

julia> head(d)
julia> first(d, 6)
6×3 DataFrame
│ Row │ variable │ value │ Species │
│ │ Symbol │ Float64⍰ │ Categorical…⍰ │
Expand All @@ -75,8 +75,7 @@ julia> head(d)
│ 5 │ SepalLength │ 5.0 │ setosa │
│ 6 │ SepalLength │ 5.4 │ setosa │


julia> tail(d)
julia> last(d, 6)
6×3 DataFrame
│ Row │ variable │ value │ Species │
│ │ Symbol │ Float64⍰ │ Categorical…⍰ │
Expand All @@ -99,7 +98,7 @@ A third optional argument to `stack` represents the id columns that are repeated
```jldoctest reshape
julia> d = stack(iris, [:SepalLength, :SepalWidth], :Species);

julia> head(d)
julia> first(d, 6)
6×3 DataFrame
│ Row │ variable │ value │ Species │
│ │ Symbol │ Float64⍰ │ Categorical…⍰ │
Expand All @@ -111,7 +110,7 @@ julia> head(d)
│ 5 │ SepalLength │ 5.0 │ setosa │
│ 6 │ SepalLength │ 5.4 │ setosa │

julia> tail(d)
julia> last(d, 6)
6×3 DataFrame
│ Row │ variable │ value │ Species │
│ │ Symbol │ Float64⍰ │ Categorical…⍰ │
Expand All @@ -129,7 +128,7 @@ julia> tail(d)
```jldoctest reshape
julia> d = melt(iris, :Species);

julia> head(d)
julia> first(d, 6)
6×3 DataFrame
│ Row │ variable │ value │ Species │
│ │ Symbol │ Float64⍰ │ Categorical…⍰ │
Expand All @@ -141,7 +140,7 @@ julia> head(d)
│ 5 │ SepalLength │ 5.0 │ setosa │
│ 6 │ SepalLength │ 5.4 │ setosa │

julia> tail(d)
julia> last(d, 6)
6×3 DataFrame
│ Row │ variable │ value │ Species │
│ │ Symbol │ Float64⍰ │ Categorical…⍰ │
Expand All @@ -162,7 +161,7 @@ julia> iris[:id] = 1:size(iris, 1)

julia> longdf = melt(iris, [:Species, :id]);

julia> head(longdf)
julia> first(longdf, 6)
6×4 DataFrame
│ Row │ variable │ value │ Species │ id │
│ │ Symbol │ Float64⍰ │ Categorical…⍰ │ Int64 │
Expand All @@ -174,7 +173,7 @@ julia> head(longdf)
│ 5 │ SepalLength │ 5.0 │ setosa │ 5 │
│ 6 │ SepalLength │ 5.4 │ setosa │ 6 │

julia> tail(longdf)
julia> last(longdf, 6)
6×4 DataFrame
│ Row │ variable │ value │ Species │ id │
│ │ Symbol │ Float64⍰ │ Categorical…⍰ │ Int64 │
Expand All @@ -188,7 +187,7 @@ julia> tail(longdf)

julia> widedf = unstack(longdf, :id, :variable, :value);

julia> head(widedf)
julia> first(widedf, 6)
6×5 DataFrame
│ Row │ id │ PetalLength │ PetalWidth │ SepalLength │ SepalWidth │
│ │ Int64 │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Float64⍰ │
Expand All @@ -200,7 +199,7 @@ julia> head(widedf)
│ 5 │ 5 │ 1.4 │ 0.2 │ 5.0 │ 3.6 │
│ 6 │ 6 │ 1.7 │ 0.4 │ 5.4 │ 3.9 │

julia> tail(widedf)
julia> last(widedf, 6)
6×5 DataFrame
│ Row │ id │ PetalLength │ PetalWidth │ SepalLength │ SepalWidth │
│ │ Int64 │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Float64⍰ │
Expand All @@ -218,7 +217,7 @@ If the remaining columns are unique, you can skip the id variable and use:
```jldoctest reshape
julia> longdf = melt(iris, [:Species, :id]);

julia> head(longdf)
julia> first(longdf, 6)
6×4 DataFrame
│ Row │ variable │ value │ Species │ id │
│ │ Symbol │ Float64⍰ │ Categorical…⍰ │ Int64 │
Expand All @@ -232,7 +231,7 @@ julia> head(longdf)

julia> widedf = unstack(longdf, :variable, :value);

julia> head(widedf)
julia> first(widedf, 6)
6×6 DataFrame
│ Row │ Species │ id │ PetalLength │ PetalWidth │ SepalLength │ SepalWidth │
│ │ Categorical…⍰ │ Int64 │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Float64⍰ │
Expand All @@ -250,7 +249,7 @@ julia> head(widedf)
```jldoctest reshape
julia> d = stackdf(iris);

julia> head(d)
julia> first(d, 6)
6×4 DataFrame
│ Row │ variable │ value │ Species │ id │
│ │ Symbol │ Float64⍰ │ Categorical…⍰ │ Int64 │
Expand All @@ -262,7 +261,7 @@ julia> head(d)
│ 5 │ SepalLength │ 5.0 │ setosa │ 5 │
│ 6 │ SepalLength │ 5.4 │ setosa │ 6 │

julia> tail(d)
julia> last(d, 6)
6×4 DataFrame
│ Row │ variable │ value │ Species │ id │
│ │ Symbol │ Float64⍰ │ Categorical…⍰ │ Int64 │
Expand Down Expand Up @@ -291,7 +290,7 @@ None of these reshaping functions perform any aggregation. To do aggregation, us
```jldoctest reshape
julia> d = melt(iris, :Species);

julia> head(d)
julia> first(d, 6)
6×3 DataFrame
│ Row │ variable │ value │ Species │
│ │ Symbol │ Float64⍰ │ Categorical…⍰ │
Expand All @@ -305,7 +304,7 @@ julia> head(d)

julia> x = by(d, [:variable, :Species], df -> DataFrame(vsum = mean(df[:value])));

julia> head(x)
julia> first(x, 6)

6×3 DataFrame
│ Row │ variable │ Species │ vsum │
Expand All @@ -318,7 +317,7 @@ julia> head(x)
│ 5 │ SepalWidth │ versicolor │ 2.77 │
│ 6 │ SepalWidth │ virginica │ 2.974 │

julia> head(unstack(x, :Species, :vsum))
julia> first(unstack(x, :Species, :vsum), 6)
5×4 DataFrame
│ Row │ variable │ setosa │ versicolor │ virginica │
│ │ Symbol │ Float64⍰ │ Float64⍰ │ Float64⍰ │
Expand Down
24 changes: 12 additions & 12 deletions docs/src/man/sorting.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ julia> iris = CSV.read(joinpath(dirname(pathof(DataFrames)), "../test/data/iris.

julia> sort!(iris);

julia> head(iris)
julia> first(iris, 6)
6×5 DataFrame
│ Row │ SepalLength │ SepalWidth │ PetalLength │ PetalWidth │ Species │
│ │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Categorical…⍰ │
Expand All @@ -21,7 +21,7 @@ julia> head(iris)
│ 5 │ 4.5 │ 2.3 │ 1.3 │ 0.3 │ setosa │
│ 6 │ 4.6 │ 3.1 │ 1.5 │ 0.2 │ setosa │

julia> tail(iris)
julia> last(iris, 6)
6×5 DataFrame
│ Row │ SepalLength │ SepalWidth │ PetalLength │ PetalWidth │ Species │
│ │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Categorical…⍰ │
Expand All @@ -39,7 +39,7 @@ In Sorting `DataFrame`s, you may want to sort different columns with different o
```jldoctest sort
julia> sort!(iris, rev = true);

julia> head(iris)
julia> first(iris, 6)
6×5 DataFrame
│ Row │ SepalLength │ SepalWidth │ PetalLength │ PetalWidth │ Species │
│ │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Categorical…⍰ │
Expand All @@ -51,7 +51,7 @@ julia> head(iris)
│ 5 │ 7.7 │ 2.6 │ 6.9 │ 2.3 │ virginica │
│ 6 │ 7.6 │ 3.0 │ 6.6 │ 2.1 │ virginica │

julia> tail(iris)
julia> last(iris, 6)
6×5 DataFrame
│ Row │ SepalLength │ SepalWidth │ PetalLength │ PetalWidth │ Species │
│ │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Categorical…⍰ │
Expand All @@ -65,7 +65,7 @@ julia> tail(iris)

julia> sort!(iris, (:SepalWidth, :SepalLength));

julia> head(iris)
julia> first(iris, 6)
6×5 DataFrame
│ Row │ SepalLength │ SepalWidth │ PetalLength │ PetalWidth │ Species │
│ │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Categorical…⍰ │
Expand All @@ -77,7 +77,7 @@ julia> head(iris)
│ 5 │ 4.5 │ 2.3 │ 1.3 │ 0.3 │ setosa │
│ 6 │ 5.0 │ 2.3 │ 3.3 │ 1.0 │ versicolor │

julia> tail(iris)
julia> last(iris, 6)
6×5 DataFrame
│ Row │ SepalLength │ SepalWidth │ PetalLength │ PetalWidth │ Species │
│ │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Categorical…⍰ │
Expand All @@ -92,7 +92,7 @@ julia> tail(iris)
julia> sort!(iris, (order(:Species, by = uppercase),
order(:SepalLength, rev = true)));

julia> head(iris)
julia> first(iris, 6)
6×5 DataFrame
│ Row │ SepalLength │ SepalWidth │ PetalLength │ PetalWidth │ Species │
│ │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Categorical…⍰ │
Expand All @@ -104,7 +104,7 @@ julia> head(iris)
│ 5 │ 5.5 │ 4.2 │ 1.4 │ 0.2 │ setosa │
│ 6 │ 5.4 │ 3.4 │ 1.7 │ 0.2 │ setosa │

julia> tail(iris)
julia> last(iris, 6)
6×5 DataFrame
│ Row │ SepalLength │ SepalWidth │ PetalLength │ PetalWidth │ Species │
│ │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Categorical…⍰ │
Expand All @@ -127,7 +127,7 @@ The following two examples show two ways to sort the `iris` dataset with the sam
julia> sort!(iris, (:Species, :SepalLength, :SepalWidth),
rev = (true, false, false));

julia> head(iris)
julia> first(iris, 6)
6×5 DataFrame
│ Row │ SepalLength │ SepalWidth │ PetalLength │ PetalWidth │ Species │
│ │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Categorical…⍰ │
Expand All @@ -139,7 +139,7 @@ julia> head(iris)
│ 5 │ 5.8 │ 2.7 │ 5.1 │ 1.9 │ virginica │
│ 6 │ 5.8 │ 2.8 │ 5.1 │ 2.4 │ virginica │

julia> tail(iris)
julia> last(iris, 6)
6×5 DataFrame
│ Row │ SepalLength │ SepalWidth │ PetalLength │ PetalWidth │ Species │
│ │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Categorical…⍰ │
Expand All @@ -153,7 +153,7 @@ julia> tail(iris)

julia> sort!(iris, (order(:Species, rev = true), :SepalLength, :SepalWidth));

julia> head(iris)
julia> first(iris, 6)
6×5 DataFrame
│ Row │ SepalLength │ SepalWidth │ PetalLength │ PetalWidth │ Species │
│ │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Categorical…⍰ │
Expand All @@ -165,7 +165,7 @@ julia> head(iris)
│ 5 │ 5.8 │ 2.7 │ 5.1 │ 1.9 │ virginica │
│ 6 │ 5.8 │ 2.8 │ 5.1 │ 2.4 │ virginica │

julia> tail(iris)
julia> last(iris, 6)
6×5 DataFrame
│ Row │ SepalLength │ SepalWidth │ PetalLength │ PetalWidth │ Species │
│ │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Categorical…⍰ │
Expand Down
4 changes: 2 additions & 2 deletions docs/src/man/split_apply_combine.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ julia> using DataFrames, CSV, Statistics

julia> iris = CSV.read(joinpath(dirname(pathof(DataFrames)), "../test/data/iris.csv"));

julia> head(iris)
julia> first(iris, 6)
6×5 DataFrame
│ Row │ SepalLength │ SepalWidth │ PetalLength │ PetalWidth │ Species │
│ │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Categorical…⍰ │
Expand All @@ -23,7 +23,7 @@ julia> head(iris)
│ 5 │ 5.0 │ 3.6 │ 1.4 │ 0.2 │ setosa │
│ 6 │ 5.4 │ 3.9 │ 1.7 │ 0.4 │ setosa │

julia> tail(iris)
julia> last(iris, 6)
6×5 DataFrame
│ Row │ SepalLength │ SepalWidth │ PetalLength │ PetalWidth │ Species │
│ │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Float64⍰ │ Categorical…⍰ │
Expand Down
3 changes: 0 additions & 3 deletions src/DataFrames.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export AbstractDataFrame,
eachrow,
eltypes,
groupby,
head,
insertcols!,
mapcols,
melt,
Expand All @@ -58,8 +57,6 @@ export AbstractDataFrame,
stackdf,
unique!,
unstack,
head,
tail,
permutecols!


Expand Down
Loading