简体   繁体   English

Pandas dataframe 列命名

[英]Pandas dataframe column naming

So in ipython i have created a pandas dataset and it is called df1.所以在 ipython 中我创建了一个 pandas 数据集,它被称为 df1。 I cannot change the name of the column my code is:我无法更改我的代码所在列的名称:

df1=pandas.DataFrame([[2,4,10],[100,200,300],columns=[“Price”,”Age”,”Value”]])

And the error is showing syntax error.并且错误显示语法错误。 on the colums equal to sign在等于符号的列上

You need list of lists for data parameter and also replace to ' or " :您需要data参数的列表列表,并将替换为'"

df1=pd.DataFrame(data=[[2,4,10],[100,200,300]],columns=['Price','Age','Value'])
print (df1)    
   Price  Age  Value
0      2    4     10
1    100  200    300

df1=pd.DataFrame(data=[[2,4,10],[100,200,300]],columns=["Price","Age","Value"])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM