您的当前位置:首页正文

python中Insert函数怎么用?

来源:花图问答

 

本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。

函数用法:

Dataframe.insert(loc, column, value, allow_duplicates=False)

函数参数:

Loc、column、value、allow_duplicates

实例代码:

实现第三列插入新列

 

实现代码:

new_col = np.random.randn(10)
df.insert(2, 'new_col', new_col)
Df

输出结果:

 

好啦,Insert函数的使用方法,上述内容已全部给大家清楚,希望可以帮助大家学习使用哦~