首页 > 解决方案 > How to delete rows in Dataframe that contain attribute values in Series

问题描述

I have a series of employee ID's and a dataframe that uses employee id's. I would like to delete all the rows from the dataframe that have corresponding employee id's in the Series

I have this code which provides the Series

resigned = employee_change['employee_id'][employee_change['type_of_termination'] == 'resignation']

I then have a dataframe called change_employee and would like to remove all rows of change_employee that has an employee_id in the series resigned

标签: python-3.xpandasdataframeseries

解决方案


change_employee = change_employee.loc[~change_employee['employee_id'].isin(resigned)]

推荐阅读