Filtering DataFrame
New Syntax
Syntax explained:
- from original "data" (type DataFrames)
- create new "dataA" (type DataFrames)
- filter indices in column "Treatment" with values equal to "A"
- include ALL COLUMNS indicated by ":"
- Show the first 6 rows
dataA = data[isequal.(data.Treatment, "A"), : ]
first(dataA, 6)
6 rows × 5 columns
Age | WCC | CRP | Treatment | Result | |
---|---|---|---|---|---|
Int64 | Float64 | Int64 | String | String | |
1 | 37 | 10.2 | 30 | A | Worse |
2 | 67 | 10.4 | 70 | A | Worse |
3 | 42 | 10.4 | 100 | A | Static |
4 | 56 | 12.5 | 80 | A | Worse |
5 | 60 | 9.5 | 0 | A | Static |
6 | 62 | 13.7 | 10 | A | Worse |
Deprecated Syntax
# dataA = data[data[:Treatment] .== "A", :]
Warning: `getindex(df::DataFrame, col_ind::ColumnIndex)` is deprecated, use `df[!, col_ind]` instead.