BaşlayınÜcretsiz Başlayın

Booleans for the win!

Time for a showdown! In this exercise, you'll compare looping over a pandas' DataFrame and Boolean indexing head-to-head.

First, loop over the rows of the wildlife_strikes DataFrame and print the following information about the strike if it involved a Snowy egret, a migratory bird native to North and South America:

  • Date of incident (INCIDENT_DATE column)
  • Airport (AIRPORT column)
  • Type of aircraft (ATYPE column)
  • Severity of the damage (DAMAGE column)

Then, compare this method with Boolean indexing and print the same information on the subset DataFrame.

Bu egzersiz

Python for MATLAB Users

kursunun bir parçasıdır
Kursu Görüntüle

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Loop through wildlife_strikes and print snowy egret data
for i, row in wildlife_strikes.____():
    if row['SPECIES']=='Snowy egret':
        print(row['INCIDENT_DATE'],
              row['AIRPORT'],
              row['ATYPE'],
              row['DAMAGE'])
Kodu Düzenle ve Çalıştır