Reputation: 121
I have a list:
l1 = [2, 3, 5, 7, 11, 13]
With the indexes and values:
ind val
0 2
1 3
2 5
3 7
4 11
5 13
Now I slice the array with:
l2 = l1[3:]
And get:
ind val
0 7
1 11
2 13
But I want the indexes to remain the same as they were before the cutting:
ind val
3 7
4 11
5 13
Upvotes: 2
Views: 164
Reputation: 986
With Pandas and series:
import pandas as pd
list=[2, 3, 5, 7, 11, 13]
x = pd.Series(list)
# Display sub serie
x.iloc[3:]
# Display sub serie values as a list
x.iloc[3:].tolist()
# Display sub serie index as a list
x.iloc[3:].index.tolist()
Upvotes: 1