Julia DataFrames

 

Filtering DataFrame


New Syntax

 

Syntax explained:

  1. from original "data" (type DataFrames)
  2. create new "dataA" (type DataFrames)
  3. filter indices in column "Treatment" with values equal to "A"
  4. include ALL COLUMNS indicated by ":"
  5. Show the first 6 rows


dataA = data[isequal.(data.Treatment, "A"), : ] 

first(dataA, 6)



6 rows × 5 columns

AgeWCCCRPTreatmentResult
Int64Float64Int64StringString
13710.230AWorse
26710.470AWorse
34210.4100AStatic
45612.580AWorse
5609.50AStatic
66213.710AWorse

 


Deprecated Syntax

# dataA = data[data[:Treatment] .== "A", :] 

 

Warning: `getindex(df::DataFrame, col_ind::ColumnIndex)` is deprecated, use `df[!, col_ind]` instead.





As an Amazon Associate I earn from qualifying purchases.

My favorite quotations..


“A man should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects.”  by Robert A. Heinlein

"We are but habits and memories we chose to carry along." ~ Uki D. Lucas


Popular Recent Articles