Mainland
Mainland

Reputation: 4584

Python generate a multi range values within a list

I want to generate a multi range values within a list. My code is given below

drop_cols = [6,21,range(38:14*16:16),range(229:229+14*16:16)]

My present output is :

drop_cols = [6,21,range(38:14*16:16),range(229:229+14*16:16)]
                              ^
SyntaxError: invalid syntax

My expected output is:

drop_cols = [6,21,38,....,229,..]

Upvotes: 2

Views: 51

Answers (1)

Scott Boston
Scott Boston

Reputation: 153510

Use np.r_:

drop_cols = np.r_[2:5, 10:15, 19]
drop_cols

Output:

array([ 2,  3,  4, 10, 11, 12, 13, 14, 19])

Upvotes: 4

Related Questions