I want to delete the data named volvo and dodge belonging to the make column. However, although I tried all kinds of functions, I still couldn't remove the data I didn't want from the column.how can I do that. I should delete or show multiple data at once. Very Thank you.
import csv
import pandas as pd
csv_path = "traffic-crashes-vehicles-1.csv"
data = pd.read_csv(csv_path)
filter_data1= data[['MAKE']]
filter_data2 = filter_data1[filter_data1.isin(['DODGE','VOLVO'])].dropna()
DATAFRAME:
MAKE VEHICLE_YEAR
0 DODGE 2011.0
1 VOLVO 2020.0
2 UNKNOWN NaN
3 TOYOTA MOTOR COMPANY, LTD. 2015.0
4 SUBARU 2014.0
... ... ...
700461 NISSAN 2013.0
700462 MERCEDES-BENZ 2016.0
700463 DODGE 2018.0
700464 KIA MOTORS CORP 2013.0
700465 LEXUS 2014.0
You were close !
data = data[~ data['MAKE'].isin(['DODGE','VOLVO'])]
should do it
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.