I want to create a column and assign it to a dataframe after every iteration of the for loop in python.
df_xyz = pd.DataFrame()
for j in range(0,3):
for k in range(j+1,4):
print(j,k)
So, in this case it should create 6 new columns in the dataframe with the name as "ABC1","ABC2"..."ABC6". And the columns will get the values from a numpy array which is generated by running the code present in the loop. My actual code involves some algorithm but here I am just placing the relevant code on which I need help.
Edit 1:
Updated the code:
z= np.array([1,2,4])
df_xyz = pd.DataFrame()
for j in range(0,3):
for k in range(j+1,4):
print(j,k)
df_xyz = pd.DataFrame(z)
This creates a new column only once.