name = ['x', 'y', 'z']
for i in range(0,3):
df = pd.DataFrame({'Name': name[i]})
I have just started programming.
I am getting the following error --
If using all scalar values, you must pass an index
.
Even if I write :
df = pd.DataFrame([{'Name': name[i]}])
this gives a column with last value only.
I want a column with all the values in an array. Can someone help me with this?
question from:
https://stackoverflow.com/questions/65901705/creating-dynamically-generated-column-in-dataframe 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…