Reputation: 142
import pandas as pd
x = pd.DataFrame([[1,2,3],[4,5,6]])
x[::2]
what does the above command mean and how does it function?
Upvotes: 1
Views: 48
Reputation: 862406
Better is more data, it return even rows only by slicing:
x = pd.DataFrame([[1,2,3],[4,5,6],[7,8,9],[0,1,2]]) print (x) 0 1 2 0 1 2 3 1 4 5 6 2 7 8 9 3 0 1 2 print (x[::2]) 0 1 2 0 1 2 3 2 7 8 9