I have a data frame like the one below and I want to add a new column to it. So that this column has a value up to a certain row and another value for the rest. How can I do this?
f1 f2 f3 ... f10000
0 0.037026 0.037026 0.037026 ... 0.000000
1 0.000000 0.000000 0.000000 ... 0.000000
2 0.000000 0.000000 0.000000 ... 0.004047
...
I know I can add columns using the following command, but I do not know how to specify that the value change after a specific row (for example row 1).
df['new_col'] = '1'
What I get:
f1 f2 f3 ... f10000 new_col
0 0.037026 0.037026 0.037026 ... 0.000000 1
1 0.000000 0.000000 0.000000 ... 0.000000 1
2 0.000000 0.000000 0.000000 ... 0.004047 1
...
What I want:
f1 f2 f3 ... f10000 new_col
0 0.037026 0.037026 0.037026 ... 0.000000 1
1 0.000000 0.000000 0.000000 ... 0.000000 0
2 0.000000 0.000000 0.000000 ... 0.004047 0
...