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

Add insert! and pushfirst! #3072

Merged
merged 19 commits into from
Jun 19, 2022
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: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
* Add `resize!`, `keepat!`, `pop!`, `popfirst!`, and `popat!`,
make `deleteat!` signature more precise
([#3047](https://github.com/JuliaData/DataFrames.jl/pull/3047))
* Add `pushfirst!` and `insert!`
([#3072](https://github.com/JuliaData/DataFrames.jl/pull/3072))
* New `threads` argument allows disabling multithreading in
`combine`, `select`, `select!`, `transform`, `transform!`, `subset` and `subset!`
([#3030](https://github.com/JuliaData/DataFrames.jl/pull/3030))
Expand Down
2 changes: 2 additions & 0 deletions docs/src/lib/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ combine
fillcombinations
flatten
hcat
insert!
insertcols
insertcols!
invpermute!
Expand All @@ -86,6 +87,7 @@ mapcols!
permute!
prepend!
push!
pushfirst!
reduce
repeat
repeat!
Expand Down
9 changes: 8 additions & 1 deletion docs/src/man/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ julia> df = DataFrame(A=Int[], B=String[])
0×2 DataFrame
```

Rows can then be added as tuples or vectors, where the order of elements matches that of columns:
Rows can then be added as tuples or vectors, where the order of elements matches that of columns.
To add new rows at the end of a data frame use [`push!`](@ref):

```jldoctest dataframe
julia> push!(df, (1, "M"))
Expand Down Expand Up @@ -261,6 +262,12 @@ Note that constructing a `DataFrame` row by row is significantly less performant
constructing it all at once, or column by column. For many use-cases this will not matter,
but for very large `DataFrame`s this may be a consideration.

If you want to add rows at the beginning of a data frame use [`pushfirst!`](@ref)
and to insert a row in an arbitrary location use [`insert!`]((@ref)).

You can also add whole tables to a data frame using the [`append!`](@ref)
and [`prepend!`](@ref) functions.

### Constructing from another table type

DataFrames supports the [Tables.jl](https://github.com/JuliaData/Tables.jl) interface for
Expand Down
2 changes: 2 additions & 0 deletions src/DataFrames.jl
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ include("abstractdataframe/abstractdataframe.jl")
include("dataframe/dataframe.jl")
include("subdataframe/subdataframe.jl")
include("dataframerow/dataframerow.jl")
include("dataframe/insertion.jl")

include("groupeddataframe/groupeddataframe.jl")
include("groupeddataframe/utils.jl")

Expand Down
Loading