'I want to increase the frequency of each element of an array with particular amount?
Solution 1:[1]
If you know what the expanded frequency will be at the time when you create the array, you can use a list comprehension to expand it first:
import numpy as np
a_prime = [64, 45, 56, 67, 78, 12, 112, 232]
a = np.array([x for x in a for i in range(4)])
If you need to change the amount to expand it by, you could wrap this in a function:
def expand_frequency(lst, n):
return [x for x in lst for i in range(n)]
a = np.array(expand_frequency(a_prime, 4))
I'm not sure if this is quite what you are looking for, but it should serve as a starting point.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Schol-R-LEA |

