【发布时间】:2021-05-18 09:10:21
【问题描述】:
如何在 pandas(python) 中使用用户输入添加列。如何修改代码来实现这一点?
sel= str(input("would you like to add a new column to df"))
if sel == "yes":
name=str(input("Name of new column to df"))
name=[]
df= df.append(name)
else:
print("column not added")
【问题讨论】:
-
如果需要对解决方案进行进一步说明,请告知我们。如果没有其他问题,请选择您认为最适合您要求的解决方案。谢谢!
标签: python pandas dataframe data-science user-input