Python Forum

Full Version: Finding sequential invoice
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I have the following dataframe and I would need to find the sequential invoice from each same name. Can kindly advise? Thanks.

data={'myid':[1,2,3,4,5,6],'name':['Mary','John','John','Peh','Alex','ken'],'invoice':['INV001','INV003','INV004','INV007','GAA002','INV008']}
df=pd.DataFrame(data)
df
The following are the result. John has squential invoice of INV003 and INV004. INV007 and INV008 although is sequential but was not from same person.

result={'myid':[2,3],'name':['John','John'],'invoice':['INV003','INV004']}
df_result=pd.DataFrame(result)
df_result