Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 如何分配列标题/名称?_Python 3.x_Pandas_Columnname - Fatal编程技术网

Python 3.x 如何分配列标题/名称?

Python 3.x 如何分配列标题/名称?,python-3.x,pandas,columnname,Python 3.x,Pandas,Columnname,我的pandas dataframe列如下所示: 0 0.9.03 1 10.17 2.11.18 如何分配列名 将列0重命名为foo: df = pd.DataFrame([[9.03], [10.17], [11.18]]) df.rename(columns={0: "foo"}, inplace=True) df # => foo # 0 9.03 # 1 10.17 # 2 11.18

我的pandas dataframe列如下所示:

   0
0.9.03

1 10.17

2.11.18


如何分配列名

将列
0
重命名为
foo

df = pd.DataFrame([[9.03], [10.17], [11.18]])
df.rename(columns={0: "foo"}, inplace=True)
df
# =>      foo
#    0   9.03
#    1  10.17
#    2  11.18