Julia'da Veri İşleme
Katerina Zahradova
Instructor
# review_date hariç chocolates'taki tüm sütunları seçme
select(chocolates, :company, :bean_origin, :REF, :cocoa,
:company_location, :ratings, :bean_type, :bean_location)
ArgumentError: column name "ratings" not found in the data frame;
existing most similar names are: "rating"
...
# review_date sütunu hariç chocolates'taki tüm sütunları seçme
select(chocolates, Not(:review_date))
1795×9 DataFrame
Row company bean_origin REF cocoa company_location rating bean_type bean_location
String String Int64 Float64 String31 Float64 String31? String31?
______________________________________________________________________________________
1 A. Morin Agua Grande 1876 63.0 France 3.75 Sao Tome
...
# Aynı sütunu iki kez kaldırma
select!(chocolates, Not(:review_date))
# Birkaç satır sonra ...
select(chocolates, Not(:review_date))
ArgumentError: column name :review_date not found in the data frame
# Cols kullanımı
select(chocolates, Not(Cols(==("review_date"))))
1795×9 DataFrame
Row company bean_origin REF cocoa company_location rating bean_type bean_location
String String Int64 Float64 String31 Float64 String31? String31?
...
# Regex kullanımı
select(chocolates, Not(r"review\_date"))
1795×9 DataFrame
Row company bean_origin REF cocoa company_location rating bean_type bean_location
String String Int64 Float64 String31 Float64 String31? String31?
...
# Önceden seçilmiş çikolatalar
first(chocolates)
1795x5 DataFrame
Row company review_date cocoa rating bean_location
String Int64 Float64 Float64 String31?
__________________________________________________________
1 A. Morin 2016 63.0 3.75 Sao Tome
# cocoa sütununu sola taşıma
select(chocolates, :cocoa, :)
1795x5 DataFrame
Row cocoa company review_date rating bean_location
Float64 String Int64 Float64 String31?
__________________________________________________________
1 63.0 A. Morin 2016 3.75 Sao Tome
...
# cocoa ve rating sütunlarını sola taşıma
select(chocolates, :cocoa, :rating, :)
1795x5 DataFrame
Row cocoa rating company review_date bean_location
Float64 Float64 String Int64 String31?
__________________________________________________________
1 63.0 3.75 A. Morin 2016 Sao Tome
...
# company sütununu sağa taşıma
select(chocolates, Not(:company), :company)
1795x5 DataFrame
Row review_date cocoa rating bean_location company
Int64 Float64 Float64 String31? String
__________________________________________________________
1 2016 63.0 3.75 Sao Tome A. Morin
...
# İki hamleyi birleştirme
select(chocolates, :cocoa, :rating, Not(:company), :company)
1795x5 DataFrame
Row cocoa rating bean_location review_date company
Float64 Float64 String31 Int64 String
__________________________________________________________
1 63.0 3.75 Sao Tome 2016 A. Morin
...
# Yeniden sırala ve review_date'i düşür
# İki hamleyi birleştir
select(chocolates, :cocoa, :rating, Not([:company, :review_date]), :company)
1795x4 DataFrame
Row cocoa rating bean_location company
Float64 Float64 String31 String
__________________________________________________________
1 63.0 3.75 Sao Tome A. Morin
...
Sütun kaldırma:
# col1 ve col 2'yi kaldır
select(df, Not([:col1, "col 2"]))
Güvenli sütun kaldırma:
# Olmayabilecek col1 ve col 2'yi kaldır
select(df, Not(r"col1"), Not(Cols(==("col 2"))))
Sütunları sola taşıma
# col1 ve col 2'yi sola taşı
select(df, :col1, "col 2", :)
Sütunları sağa taşıma
# col1 ve col 2'yi sağa taşı
select(df, Not([:col1, "col 2"]) ,:col1, "col 2")
Julia'da Veri İşleme