Skip to content

Commit

Permalink
included fill_na
Browse files Browse the repository at this point in the history
  • Loading branch information
drizk1 committed Aug 3, 2023
1 parent 4e51309 commit 4db0700
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/TidierData.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ using Reexport
@reexport using ShiftedArrays: lag, lead

export TidierData_set, across, desc, n, row_number, starts_with, ends_with, matches, if_else, case_when, ntile,
as_float, as_integer, as_string, @select, @transmute, @rename, @mutate, @summarize, @summarise, @filter,
as_float, as_integer, as_string, fill_na, @select, @transmute, @rename, @mutate, @summarize, @summarise, @filter,
@group_by, @ungroup, @slice, @arrange, @distinct, @pull, @left_join, @right_join, @inner_join, @full_join,
@pivot_wider, @pivot_longer, @bind_rows, @bind_cols, @clean_names, @count, @tally, @drop_na, @glimpse, @separate,
@unite, @summary
Expand Down
47 changes: 46 additions & 1 deletion src/docstrings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2099,4 +2099,49 @@ julia> @chain df begin
2 │ C 11 12.0 13.0 12.6667 13.5 14 3 2
3 │ D 16 17.0 18.0 18.0 19.0 20 5 0
```
"""
"""

const = docstring_fill_na
"""
fill(column, method)
Fills missing values in a given column of a DataFrame. This function uses either Last Observation Carried Forward (LOCF) or Next Observation Carried Backward (NOCB) methods based on the provided argument.
# Arguments
- `column`: Column that with missing values
- `method`: "nocb" or "locf" depending on the desired strategy.
```jldoctest
julia> df = DataFrame(dt1=[missing, 0.2, missing, missing, 1, missing, 5, 6], dt2=[0.3, missing, missing, 3, missing, 5, 6,missing])
8×2 DataFrame
Row │ dt1 dt2
│ Float64? Float64?
─────┼──────────────────────
1 │ missing 0.3
2 │ 0.2 missing
3 │ missing missing
4 │ missing 3.0
5 │ 1.0 missing
6 │ missing 5.0
7 │ 5.0 6.0
8 │ 6.0 missing
julia> @chain df begin
@mutate(dt1 = ~fill_na(dt1, "locf"))
@mutate(dt2 = ~fill_na(dt2, "nocb"))
end
8×2 DataFrame
Row │ dt1 dt2
│ Float64? Float64?
─────┼──────────────────────
1 │ missing 0.3
2 │ 0.2 3.0
3 │ 0.2 3.0
4 │ 0.2 3.0
5 │ 1.0 5.0
6 │ 1.0 5.0
7 │ 5.0 6.0
8 │ 6.0 missing
```
"""

0 comments on commit 4db0700

Please sign in to comment.