我是靠谱客的博主 幸福星星,这篇文章主要介绍pandas基础--如何用jupyter notebook从现有列产生新列,现在分享给大家,希望可以做个参考。

如有产品表数据如图,需要求取价格这一列:
在这里插入图片描述
首先导入pandas,Products.head()默认查看前5行,看数据是否出错;
代码如下:

import pandas as pd

Products=pd.read_excel('E:\pandas基础\1\产品表.xlsx',index_col='ID')

Products.head()

查看结果,
在这里插入图片描述
最终代码;

import pandas as pd

Products=pd.read_excel('E:\pandas基础\1\产品表.xlsx',index_col='ID')

# Products.head()
Products['价格']=Products['市场价']*Products['折扣']
print(Products)

最终结果;
在这里插入图片描述

最后

以上就是幸福星星最近收集整理的关于pandas基础--如何用jupyter notebook从现有列产生新列的全部内容,更多相关pandas基础--如何用jupyter内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(71)

评论列表共有 0 条评论

立即
投稿
返回
顶部