Advertisements
I want to filter my data to only Honda CRVs. I noticed that there are a couple types of Honda CRVs and I can’t find the condition to select CRVs only.
Kinda having a hard time here. Don’t know what to do
>Solution :
We can look at some examples on pandas filtering and see that we can combine multiple filters using &
and then we have can look at some string methods we can use with pandas to see that we have a str.startswith
. So we if we combine them into something like this, could work:
honda_crv_df = df_train_new[(df_train_new['Manufacture'] == "Honda") & (df_train_new['Name'].str.startswith('Honda CR-V'))].sort_values(by="Price", ascending=False)