The slice notation
a[start:stop] # items start through stop-1 a[start:] # items start through the rest of the array a[:stop] # items from the beginning through stop-1 a[:] # a copy of the whole array Reference https://stackoverflow.com/questions/509211/understanding-slice-notation |
mydict = [{'a': 1, 'b': 2, 'c': 3, 'd': 4}, {'a': 100, 'b': 200, 'c': 300, 'd': 400} {'a': 1000, 'b': 2000, 'c': 3000, 'd': 4000 }] import pandas as pd data = pd.DataFrame(mydict)
# Get the latest column serials # Row selection: : <-- a copy whole row # Col selection: -1 <-- choose the latest column y = data.iloc[:, -1]
# Get the rest of the column serials # Row selection: : <-- a copy whole row # Col selection: :-1 <-- select whole column without the latest one X = data.iloc[:,:-1]
|