Skip to content

Instantly share code, notes, and snippets.

@nilforooshan
Last active March 30, 2019 05:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nilforooshan/c05a17b15213f2f8fe9499accbc38978 to your computer and use it in GitHub Desktop.
Save nilforooshan/c05a17b15213f2f8fe9499accbc38978 to your computer and use it in GitHub Desktop.
py: rep() equivalent in Python

rep() equivalent in Python

Use numpy arrays and the numpy.repeat function.

import numpy as np x = np.array(["A", "B"]) print np.repeat(x, [2, 3], axis=0)

['A' 'A' 'B' 'B' 'B']

source

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment