The problem: I want to shift the index by adding 2 (index+=2) to match it with the indices of a .csv file.
I have a dataframe which looks as follows:
Counts | Counts | |
---|---|---|
7 | 10951.0 | 870.0 |
8 | 8653.0 | 1772.0 |
19 | 28598.0 | 37608.0 |
20 | 115266.0 | 123491.0 |
21 | 73097.0 | 145261.0 |
my desired result would look like this:
Counts | Counts | |
---|---|---|
9 | 10951.0 | 870.0 |
10 | 8653.0 | 1772.0 |
21 | 28598.0 | 37608.0 |
22 | 115266.0 | 123491.0 |
23 | 73097.0 | 145261.0 |
Thanks for the help and sorry if there is anything wrong with my question.
This function:
shifted_df.index = pd.Index(range(2, len(shifted_df) + 2))
is the first one which as actually changing the index of my dataframe but it just overwrites the given index with the numbers 2 to len(shifted_df)