numpy’s repeat
function gets the job done:
>>> import numpy as np
>>> x = [2, 3, 4]
>>> y = [1, 2, 3]
>>> np.repeat(x, y)
array([2, 3, 3, 4, 4, 4])
More Related Contents:
- Fastest way to count number of occurrences in a Python list
- I don’t know how to display step 3 for this assignment
- How do I concatenate items in a list to a single string?
- Split a string by a delimiter in python
- Access a particular field in arbitrarily nested JSON data [duplicate]
- Is there a zip-like function that pads to longest length?
- Why does this iterative list-growing code give IndexError: list assignment index out of range?
- Different behaviour for list.__iadd__ and list.__add__
- Slicing a list in Python without generating a copy
- How do I check if there are duplicates in a flat list?
- Memory errors and list limits?
- Take the content of a list and append it to another list
- [] and {} vs list() and dict(), which is better?
- How to find the maximum value in a list of tuples? [duplicate]
- How to access List elements
- In Python, why is list[] automatically global?
- Understand Python swapping: why is a, b = b, a not always equivalent to b, a = a, b?
- Why do I get “List index out of range” when trying to add consecutive numbers in a list using “for i in list”? [duplicate]
- How do I sort this list in Python, if my date is in a String?
- How can I format a list to print each element on a separate line in python? [duplicate]
- Group list by values [duplicate]
- What to consider before subclassing list?
- How do I send list of dictionary as Body parameter in FastAPI?
- Python Sort One List According to Another List
- Loop through list with both content and index [duplicate]
- In Python, is there an elegant way to print a list in a custom format without explicit looping?
- Retrieve the two highest item from a list containing 100,000 integers
- Python find list lengths in a sublist
- Python: Random numbers into a list
- How to create a nested dictionary from a list in Python?