I have an 8000-element 1D array.
I want to obtain the following two arrays:
test contains the element with the index from [1995:1999], [3995:3999], [5999:5999], [7995:7999]. 
train should contains everything else. 
How should I do that?
idx = [1995,1996,1997,1998, 1999, 3995, 3996, 3997,3998, 3999, 5995, 5996, 5997, 5998, 5999, 7995, 7996, 7997, 7998, 7999]
test = [X[i] for i in idx]
train = [X[i] for i **not** in idx]
                Based on your example, a simple workaround would be this:
train = [X[i] for i, _ in enumerate(X) if i not in idx]
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With