Coding Challenges on Filtering and Sorting
Assess your ability to filter and sort data using Python.
Dataset description
We will work with the cities-america.csv
dataset, which includes information about various cities in Canada and the United States. Each record represents a different city, and each column in the dataset represents specific information about the cities. Here's a description of each column:
City
: The name of the city.Country
: The name of the country where the city is located.Area (km^2)
: The city's total area in square kilometers.Average Temperature (C)
: The city's average temperature in degrees Celsius.Landmark
: A well-known attraction or historical site in the city.Altitude (m)
: The height of an object above the surface of the ground or sea level.Elevation (m)
: The city's height above the mean sea level.
Challenge 1: Boolean indexing
We've already imported the pandas library. Write code using boolean indexing to filter for Canadian cities from the cities-america.csv
dataset. Save the filtered records in a cities_df
DataFrame, and print the DataFrame to preview the records.
Get hands-on with 1400+ tech skills courses.