Skip to content
Advertisement

Determinate Consecutive Values (Invoices) Pandas

I have a dataset with supplier and its invoices and I need to determinate which of the invoices are consecutives marking it with a 1 or a 0.

For example:

JavaScript
JavaScript

And what I want is a third column like this:

JavaScript

EDIT

Thanks for your answers, this options works great, but when I tried it in a real database I realized that I need to compare the suppliers, if the next row is a new supplier the consecutive must be 0.

For example:

JavaScript

Thanks in advance!

Advertisement

Answer

using npwhere and diff

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