I have a more complicated code but I just created this simple example to explain what I need to do.
for i in np.arange(0,360):
r = 2*i
print(r)
d = {'r': [r]}
df = pd.DataFrame(data=d)
Instead of printing r, how would I save r into the dataframe df? I tried to replicate an example from the documentation for dataframes but I'm lost how to properly add every iteration of r to the dataframe.
dfis a dict, not a data frame. Regardless of the terminology, you're asking us how to assign to a well-documented data structure -- just what confuses you from the tutorials and examples on your data type?dto a single-element dict, and then convert that to a single-row data frame, overwriting the original data frame. Please work through a tutorial on data frames to see how to initialize them from various sources.