I have a dataframe of values which I want to add some noise. For that I made this function:
def noise(df, noise):
return np.random.normal(0, df.std() * noise, df.size)
And call it with:
noise(test_df, 0.15)
However it's giving me a shape missmatch error:
ValueError: shape mismatch: objects cannot be broadcast to a single shape
A dataframe example:
test_df = pd.DataFrame([[1,2],[3,4]], columns=list('AB'), dtype=float)
I do need my function to have as arguments the dataframe and the noise. What am I doing wrong?
Thank you