Pandas - Büyüktür Operatörü
Cts 16 Temmuz 2022> Operatörü
Örnek Veri çerçevemiz aşağıda görünmektedir.
import pandas as pd
imdb = pd.read_excel("Veri_Setleri/imdb.xlsx", decimal=",")
print(imdb)
Film_Adı | Yıl | Puan | Oylayan_Kişi | |
---|---|---|---|---|
0 | The Shawshank Redemption | 1994 | 9.2 | 1071904 |
1 | The Godfather | 1972 | 9.2 | 751381 |
2 | The Godfather: Part II | 1974 | 9.0 | 488889 |
3 | Pulp Fiction | 1994 | 8.9 | 830504 |
4 | The Dark Knight | 2008 | 8.9 | 1045186 |
... | ... | ... | ... | ... |
242 | Mystic River | 2003 | 7.9 | 256159 |
243 | In the Heat of the Night | 1967 | 7.9 | 37081 |
244 | Arsenic and Old Lace | 1944 | 7.9 | 45893 |
245 | Before Sunrise | 1995 | 7.9 | 100974 |
246 | Papillon | 1973 | 7.9 | 62517 |
247 rows × 4 columns
Karşılaştırma operatorlerini, Filtreleme işlemini dışında kıyaslama amacıyla da kullanabiliriz. Aşağıdaki kullanımı inceleyelim.
Mantiksal_imdb = imdb["Puan"] > 8
print(Mantiksal_imdb)
0 True
1 True
2 True
3 True
4 True
...
242 False
243 False
244 False
245 False
246 False
Name: Puan, Length: 247, dtype: bool
Bu durumda, Puan sütunundaki değerler, verilen kritere göre (8'den büyük olup olmadığı) sorgulanıyor ve her değer için True (Doğru) yani değer 8'den büyük ya da False (yanlış) yani değer 8'e eşit ya da küçük sonucu döndürüyor.
Puan'ı 8'den büyük verileri tablo halinde görmek istersek aşağıdaki kodu kullanabiliriz.
print(imdb[imdb["Puan"] > 8])
Film_Adı | Yıl | Puan | Oylayan_Kişi | |
---|---|---|---|---|
239 | Beauty and the Beast | 1991 | 7.9 | 189229 |
240 | Three Colors: Red | 1994 | 7.9 | 43438 |
241 | Bringing Up Baby | 1938 | 7.9 | 35695 |
242 | Mystic River | 2003 | 7.9 | 256159 |
243 | In the Heat of the Night | 1967 | 7.9 | 37081 |
244 | Arsenic and Old Lace | 1944 | 7.9 | 45893 |
245 | Before Sunrise | 1995 | 7.9 | 100974 |
246 | Papillon | 1973 | 7.9 | 62517 |