The ideal way is probably numpy.repeat
:
In [16]:
x1=[1,2,3,4]
In [17]:
np.repeat(x1,3)
Out[17]:
array([1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4])
More Related Contents:
- How to insert a space delimited text file into mysql using Python? [closed]
- Circular (or cyclic) imports in Python
- Checking multiple values for a variable [duplicate]
- Finding max value in the second column of a nested list?
- Importing from a relative path in Python
- Python : How to parse the Body from a raw email , given that raw email does not have a “Body” tag or anything
- Using Python Requests: Sessions, Cookies, and POST
- Error 28000: Login failed for user DOMAIN\\user with pyodbc
- Should conda, or conda-forge be used for Python environments?
- “In” operator for numpy arrays?
- Read file content from S3 bucket with boto3
- Remove final character from string
- Django – taking values from POST request
- PIP Install Numpy throws an error “ascii codec can’t decode byte 0xe2”
- How to manage division of huge numbers in Python?
- What does ‘u’ mean in a list?
- Replacing a sublist with another sublist in python
- Continuing in Python’s unittest when an assertion fails
- Define a method outside of class definition?
- Screen Capture with OpenCV and Python-2.7
- Why do I get “OverflowError: (34, ‘Result too large’)” or “OverflowError: (34, ‘Numerical result out of range’)” from floating-point exponentiation?
- Keras AttributeError: ‘Sequential’ object has no attribute ‘predict_classes’
- Understanding matplotlib: plt, figure, ax(arr)?
- How to convert R dataframe back to Pandas using rpy2?
- Converting a Mercurial (hg) repository to Git on Windows (7)
- Mixing categorial and continuous data in Naive Bayes classifier using scikit-learn
- How to use QThread correctly in pyqt with moveToThread()?
- Why am I getting NotImplementedError with async and await on Windows?
- Getting SVN revision number into a program automatically
- CSRF validation does not work on Django using HTTPS