Checking column types
Take a look at the UFO dataset's column types using the .info() method. Two columns jump out for transformation: the seconds column, which is a numeric column but is being read in as object, and the date column, which can be transformed into the datetime type. That will make our feature engineering efforts easier later on.
Bu egzersiz
Preprocessing for Machine Learning in Python
kursunun bir parçasıdırEgzersiz talimatları
- Call the
.info()method on theufodataset. - Convert the type of the
secondscolumn to thefloatdata type. - Convert the type of the
datecolumn to thedatetimedata type. - Call
.info()onufoagain to see if the changes worked.
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
# Print the DataFrame info
print(ufo.____)
# Change the type of seconds to float
ufo["seconds"] = ____
# Change the date column to type datetime
ufo["date"] = ____
# Check the column types
print(ufo.____)