Finding sequential invoice - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Finding sequential invoice (/thread-25218.html) |
Finding sequential invoice - william888 - Mar-24-2020 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) dfThe 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 |