subset first and last consecutive value from pandas df col – python
Advertisements I want to subset a df by returning the first and last consecutive value from a pandas col. Drop_duplciates won’t work because it doesn’t account for consecutive groupings. I’m using .shift() (below) but this only returns the last consecutive value, where I want the first and last. import pandas as pd df = pd.DataFrame({"Item":[‘A’,… Read More subset first and last consecutive value from pandas df col – python