-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
102 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "DataConvenience" | ||
uuid = "3b531cbf-ee43-4e67-8118-dca2c9372f86" | ||
authors = ["Dai ZJ <[email protected]>"] | ||
version = "0.3.1" | ||
version = "0.3.2" | ||
|
||
[deps] | ||
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
export onehot, onehot! | ||
|
||
using DataFrames: AbstractDataFrame | ||
|
||
""" | ||
onehot(df, col, cate = sort(unique(df[!, col])); outnames = Symbol.(:ohe_, cate)) | ||
onehot!(df, col, cate = sort(unique(df[!, col])); outnames = Symbol.(:ohe_, cate)) | ||
One-hot encode a column and create columns. The output columns will be overwritten WITHOUT warning | ||
Arguments: | ||
df - The DataFrame | ||
col - The column to onehot encode | ||
cate - The categories | ||
""" | ||
function onehot!(df::AbstractDataFrame, col, cate = sort(unique(df[!, col])); outnames = Symbol.(:ohe_, cate)) | ||
transform!(df, @. col => ByRow(isequal(cate)) .=> outnames) | ||
end | ||
|
||
function onehot(df::AbstractDataFrame, col, cate = sort(unique(df[!, col])); outnames = Symbol.(:ohe_, cate)) | ||
transform(df, @. col => ByRow(isequal(cate)) .=> outnames) | ||
end |
This file was deleted.
Oops, something went wrong.
f007a18
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
f007a18
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/39450
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: