I loaded in a .dat
file to a pandas dataframe. Two of the columns are mean and error. I used the values in these two columns to create a randomized value for mean. I want to replace the mean column in the dataframe with the new values for mean. However I want to continuously do this and create new dataframes as I go because every dataframe needs to be saved back to a file and used in a simulation.
df = pd.read_table('file.dat', skiprows=9, sep="s+", usecols=[0,1,2,3,4], names=['col1', 'col2', 'col3', 'col4', 'col5'])
N = 10
r = np.random.normal(df['col3'], abs(df['col4']), (N, len(df)))
for i in r:
df['col3'] = r[i]
df.copy() = df[i]{i} #Wanted to copy what I just made and save it to a new named dataframe, not sure how to convert the dataframe back to a .dat file either
Allyand Camshow is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1