Python: Generate incremental sequence number programmatically each time the py file is run

I am trying to generate a number which is sequential in nature and depends upon previous run of a py file.

Lets take an example:

df = pd.DataFrame({'Desc':['This is a test sequence generator'],'Seq_Num':[100]},index=None)

When I run this I get the following dataframe:

       Desc                             Seq_Num
This is a test sequence generator         100

Now when I shall run the above statement again, I want Seq_Num as 101. So the resultant df would be:

      Desc                             Seq_Num
This is a test sequence generator         101

And so on. I.e. every time that .py script runs, seq_num is increased by unit 1. After, say 10 consecutive runs, the Seq_Num should be 110.

Any clue on this

Read more here:

Content Attribution

This content was originally published by pythondumb at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: