JuliaData / JuliaData/DataFrames.jl
Rename ignoring not found
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 1.8k
- Forks
- 372
- Avg merge
- 5d 7h
- Merged PRs (30d)
- 5
Description
For the mapping overloads of rename / rename! - I've at times wanted to ignore columns that aren't found.
rename(df::AbstractDataFrame, (from => to)::Pair...)
rename(df::AbstractDataFrame, d::AbstractDict)
rename(df::AbstractDataFrame, d::AbstractVector{<:Pair})
I think an optional kwarg would be a reasonable extension of the api? (not sure on name)
julia> df = DataFrame(; a=[1, 2, 3], b=[4, 5, 6])
3×2 DataFrame
Row │ a b
│ Int64 Int64
─────┼──────────────
1 │ 1 4
2 │ 2 5
3 │ 3 6
julia> rename(df, :a => :column_1, :c => :column_2)
ERROR: ArgumentError: Tried renaming :c to :column_2, when :c does not exist in the Index.
julia> rename(df, :a => :column_1, :c => :column_2; ignorenotfound=true)
3×2 DataFrame
Row │ column_1 b
│ Int64 Int64
─────┼─────────────────
1 │ 1 4
2 │ 2 5
3 │ 3 6
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the mapping overloads of rename and rename! described in the issue, including Pair, AbstractDict, and AbstractVector{<:Pair} inputs. Check how missing source columns currently raise errors and determine the final keyword argument name and behavior from the API discussion. Done means existing columns are renamed while missing columns are ignored when the option is enabled, with current behavior preserved by default.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100