Issue
A simplified script I have now working is as follows:
columns = df.columns.tolist()
df1=pd.DataFrame()
for i in columns:
df1[i]=[random.uniform(-1*(df[i].std()*3),(df[i].std()*3))+df[i].mean()]
How can I get the same result (a one row dataframe) with a simpler, more efficient code?
Solution
Try with apply
:
df1 = df.apply(lambda x: random.uniform(-3*x.std(),3*x.std())+x.mean())
Answered By - not_speshal
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.