Keeping it descriptive
To further understand travelers' experiences in the San Francisco Airport, the quality assurance department sent out a qualitative questionnaire to all travelers who gave the airport the worst score on all possible categories. The objective behind this questionnaire is to identify common patterns in what travelers are saying about the airport.
Their response is stored in the survey_response
column. Upon a closer look, you realized a few of the answers gave the shortest possible character amount without much substance. In this exercise, you will isolate the responses with a character count higher than 40 , and make sure your new DataFrame contains responses with 40 characters or more using an assert
statement.
The airlines
DataFrame is in your environment, and pandas
is imported as pd
.
This exercise is part of the course
Cleaning Data in Python
Exercise instructions
- Using the
airlines
DataFrame, store the length of each instance in thesurvey_response
column inresp_length
by using.str.len()
. - Isolate the rows of
airlines
withresp_length
higher than40
. - Assert that the smallest
survey_response
length inairlines_survey
is now bigger than40
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Store length of each row in survey_response column
resp_length = ____
# Find rows in airlines where resp_length > 40
airlines_survey = airlines[____ > ____]
# Assert minimum survey_response length is > 40
assert ____.str.len().____ > _____
# Print new survey_response column
print(airlines_survey['survey_response'])