I have a variable that comes from a function that returns an integer.
I need to create an incremental column in my dataframe from this integer, how can I do that?
Integer example: 201
Output expected:
Stores | New column |
---|---|
Marcos Store | 202 |
Lais Store | 203 |
Carol Store | 204 |
Ana Store | 205 |
Maria Store | 206 |
CodePudding user response:
n = 201
df['New column'] = df.index n 1
Output:
Stores New column
0 Marcos Store 202
1 Lais Store 203
2 Carol Store 204
3 Ana Store 205
4 Maria Store 206