I have a pandas Dataframe named dataframe. I want to add two rows at the start and end of the data frame with 0s.
#create DataFrame
df_x = pd.DataFrame({'logvalue': ['20', '20.5', '18.5', '2', '10'],
'ID': ['1', '2', '3', '4', '5']})
Output should look like below.
logvalue | ID | violatedInstances |
---|---|---|
0 | 0 | 0 |
20 | 1 | 0 |
20.5 | 2 | 1 |
18.5 | 3 | 0 |
2 | 4 | 1 |
10 | 5 | 1 |
0 | 0 | 0 |
The output should rearrange the indexes of the dataframe as well. How can I do this in pandas?