Duiken in DataFrames

Data manipulatie in Julia

Katerina Zahradova

Instructor

Cursusoverzicht

  • Werken met kolommen
  • Groeperen van data
  • Samenvattende statistieken
  • Draaipatronen (pivots)
  • CSV-bestanden laden en opslaan
  • Visualisaties
  • Leesbare, geordende code schrijven
Data manipulatie in Julia

Datasets

Pinguïns

Loon VS

Chocolade

Vliegtuig

1 Pexels
Data manipulatie in Julia

Strings en symbolen

# Met strings
df[:, "col 1"]

df[:, "col2"]
# Met symbolen
df[:, Symbol("col 1")]


df[:, :col2]
Data manipulatie in Julia

Wat ontbreekt er

# Met first()
println(first(penguins))
Row    species    island    culmen_l_mm ...
       String15   String15  String7?    ...
____________________________________________
1      Adelie     Torgersen 39.1
# Met describe
describe(penguins)
7x7 DataFrame
Row  variable     ...   nmissing  ...
     Symbol       ...   Int64     ... 
______________________________________
1    species      ...   0         ...       
2    island       ...   0         ...
3    culmen_l_mm  ...   10        ...
4    culmen_d_mm  ...   10        ...
5    flipper_l_mm ...   10        ...
...
Data manipulatie in Julia

Beter beschrijven

# Describe
describe(penguins)
Row  variable     mean    min     ...
     Symbol       Nothing Union   ...
________________________________________________
1    species              Adelie        
2    island               Biscoe        
3    culmen_l_mm  32.1    34.7
4    culmen_d_mm  13.1    16    
5    flipper_l_mm 205.4   165
...
# Describe met alleen enkele kolommen
describe(penguins, :nmissing, :eltype)
Row  variable     nmissing    eltype
     Symbol       Int64       DataType
________________________________________________
1    species      0           String15        
2    island       0           String15        
3    culmen_l_mm  10          Float64
4    culmen_d_mm  10          Float64
5    flipper_l_mm 10          Float64
...
Data manipulatie in Julia

Beschrijven zoals wij willen

# Met sum

describe(penguins, sum => :total)
7×2 DataFrame
Row  variable     total
     Symbol       Union
________________________________________
1    species    
2    island    
3    culmen_l_mm  15136.6
4    culmen_d_mm  5163.4    
...
Data manipulatie in Julia

DataFrames-syntaxis

Sjabloon kolomtransformatie

Data manipulatie in Julia

DataFrames-syntaxis

Sjabloon kolomtransformatie

Data manipulatie in Julia

Laten we oefenen!

Data manipulatie in Julia

Preparing Video For Download...