后浪云Python教程:python中Insert函数怎么用?

后浪云Python教程:python中Insert函数怎么用?插图 

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

函数用法:

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

函数参数:

Loc、column、value、allow_duplicates

实例代码:

实现第三列插入新列

后浪云Python教程:python中Insert函数怎么用?插图1 

实现代码:

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

输出结果:

后浪云Python教程:python中Insert函数怎么用?插图2 

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

THE END