Skip to content
Advertisement

get intersection in single column of pandas dataframe

I have a dataframe like this:

JavaScript

I want to add a new column ‘intersec’ and get the intersection of the Price column and its shift value. But when I use

JavaScript

It doesn’t work, I get the following error:

JavaScript

what should I do? My expected result is:

JavaScript

Advertisement

Answer

shift the price

JavaScript

find intersect

JavaScript

sample output

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement