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 Replace #42

Merged
merged 14 commits into from
Apr 13, 2022
Merged

Add Replace #42

merged 14 commits into from
Apr 13, 2022

Conversation

eliascarv
Copy link
Member

@eliascarv eliascarv commented Apr 12, 2022

This PR implements Replace tranformation. The Replace(oldᵢ => newᵢ) transformations replaces all occurrences of oldᵢ with newᵢ in the table.

Note: If the type of old is different from the type of new, the column type is changed to a type common to the new column elements, without promotion.
Example:

julia> using TableTransforms, DataFrames

julia> df = DataFrame(a = [2, 1, 2], b = [1, 1, 1])
3×2 DataFrame       
 Row │ a      b     
     │ Int64  Int64 
─────┼──────────────
   1 │     2      1 
   2 │     1      1 
   3 │     2      1 

julia> T = Replace(1 => 1.5)
Replace{Int64, Float64}(IdDict(1 => 1.5))

julia> T(df)
3×2 DataFrame
 Row │ a     b       
     │ Real  Float64 
─────┼───────────────
   1 │  2        1.5
   2 │  1.5      1.5
   3 │  2        1.5

@eliascarv eliascarv requested a review from juliohm April 12, 2022 12:39
src/TableTransforms.jl Outdated Show resolved Hide resolved
src/transforms/replace.jl Outdated Show resolved Hide resolved
@eliascarv eliascarv requested a review from juliohm April 12, 2022 13:20
@codecov-commenter
Copy link

codecov-commenter commented Apr 12, 2022

Codecov Report

Merging #42 (2f87e1d) into master (af0128a) will increase coverage by 0.15%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master      #42      +/-   ##
==========================================
+ Coverage   92.69%   92.85%   +0.15%     
==========================================
  Files          18       19       +1     
  Lines         452      462      +10     
==========================================
+ Hits          419      429      +10     
  Misses         33       33              
Impacted Files Coverage Δ
src/transforms.jl 97.82% <ø> (ø)
src/transforms/replace.jl 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update af0128a...2f87e1d. Read the comment docs.

Copy link
Member

@juliohm juliohm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to resolve newly added conflicts with master.

@eliascarv eliascarv requested a review from juliohm April 13, 2022 11:05
src/TableTransforms.jl Show resolved Hide resolved
src/transforms.jl Show resolved Hide resolved
src/transforms/replace.jl Outdated Show resolved Hide resolved
test/transforms.jl Outdated Show resolved Hide resolved
Co-authored-by: Júlio Hoffimann <julio.hoffimann@gmail.com>
@eliascarv eliascarv requested a review from juliohm April 13, 2022 11:32
src/transforms/replace.jl Outdated Show resolved Hide resolved
src/transforms/replace.jl Outdated Show resolved Hide resolved
test/transforms.jl Outdated Show resolved Hide resolved
@eliascarv eliascarv requested a review from juliohm April 13, 2022 19:47
Copy link
Member

@juliohm juliohm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The IdDict trick was clever 💯

src/transforms/replace.jl Outdated Show resolved Hide resolved
@eliascarv
Copy link
Member Author

eliascarv commented Apr 13, 2022

The IdDict trick was clever 💯

Thanks @juliohm!

@eliascarv
Copy link
Member Author

Can I merge when tests pass @juliohm?

@juliohm
Copy link
Member

juliohm commented Apr 13, 2022

Yes, feel free to merge when all green tickets show up. 👍🏽

@eliascarv eliascarv merged commit ee9f36e into JuliaML:master Apr 13, 2022
@eliascarv eliascarv deleted the replace branch April 13, 2022 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants