Sometimes we have two or more series and we have to find all those elements that are present in one series but not in other. We can do this easily, using the Bitwise NOT operator along with the pandas.isin() function.
Example 1: Taking two Integer Series
In the above example, we take 2 pandas series of int type ‘ps1‘ and ‘ps2‘ and find all those elements of ps1 that are not present in ps2.
Example 2: Taking two Floating point Series
In the above example, we take 2 pandas series of float type ‘ps1‘ and ‘ps2‘ and find all those elements of ps1 that are not present in ps2.
Example 3: Taking two String Series
In the above example, we take 2 pandas series of string type ‘ps1‘ and ‘ps2‘ and find all those elements of ps1 that are not present in ps2.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Check whether a given column is present in a Pandas DataFrame or not
- Get the items which are not common of two Pandas series
- Python | Pandas Series.nonzero() to get Index of all non zero values in a series
- Add a Pandas series to another Pandas series
- Python | Remove all values from a list present in other list
- Python | Pandas series.str.get()
- Python | Pandas Series.get()
- Python - Remove records if Key not present
- Python - Remove dictionary from a list of dictionaries if a particular value is not present
- Python | Pandas series.cumprod() to find Cumulative product of a Series
- Python | Pandas Series.str.replace() to replace text in a series
- Python | Pandas Series.astype() to convert Data type of series
- Python | Pandas Series.cumsum() to find cumulative sum of a Series
- Python | Pandas series.cummax() to find Cumulative maximum of a series
- Python | Pandas Series.cummin() to find cumulative minimum of a series
- Python | Pandas Series.mad() to calculate Mean Absolute Deviation of a Series
- Convert a series of date strings to a time series in Pandas Dataframe
- Convert Series of lists to one Series in Pandas
- Converting Series of lists to one Series in Pandas
- Python - Replace index elements with elements in Other List
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.