Skip to content

Commit

Permalink
Make @df support string column names (#5033)
Browse files Browse the repository at this point in the history
* @df -- Support string column names

Add a special case to `add_sym!` to convert an `AbstractString` column name to a `Symbol` before adding it.

The old behavior would iterate over the string and try to add each character as a column name. This produced a stack overflow, since `add_sym!` had no special case for `Char`, resulting in indefinite recursion.

* Add Ron Wolf to .zenodo.json
  • Loading branch information
ron-wolf authored Nov 25, 2024
1 parent f017272 commit 0b9a176
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .zenodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,10 @@
{
"name": "Patrick Jaap",
"type": "Other"
},
{
"name": "Wolf, Ron",
"type": "Other"
}
],
"upload_type": "software"
Expand Down
2 changes: 2 additions & 0 deletions StatsPlots/src/df.jl
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ get_col(syms, col_nt, names) = hcat((get_col(s, col_nt, names) for s ∈ syms)..

# get the appropriate name when passed an Integer
add_sym!(cols, i::Integer, names) = push!(cols, names[i])
# get the appropriate name when passed an AbstractString
add_sym!(cols, str::AbstractString, names) = add_sym!(cols, Symbol(str), names)
# check for errors in Symbols
add_sym!(cols, s::Symbol, names) = s in names ? push!(cols, s) : cols
# recursively extract column names
Expand Down

0 comments on commit 0b9a176

Please sign in to comment.