Reputation: 1130
I need to replace all values of pandas dataframe in a fast way.
data = pd.read_csv("data.txt", sep="\s*,", header=None)
cross_tab1 = pd.crosstab(data[0], data[1], rownames=['data0'], colnames=['data1'])
after that I want to take all values from data frame and add noise to all. I need something to make this possible data.values = data.values + np.random.normal(0, 2.0)
Can you please help me?
Upvotes: 0
Views: 424
Reputation: 3464
if you want a line as close as possible to data.values = data.values + np.random.normal(0, 2.0)
then you might try something like:
data.update(data.values + np.random.normal(0, 2.0))
you could also look at apply, applymap, or transform
Upvotes: 2