pandas 运算
发布日期:2021-08-13 06:10:11 浏览次数:1 分类:技术文章

本文共 1151 字,大约阅读时间需要 3 分钟。

Data frame 和 series 的运算: 横列相加减:按照index ,row 的方向直接相加减。frame-series 纵列相加减:按照 columns,运用算术函数,相加减。
frame.sub(series3, axis=0)
'''operation between data frame and series ''' import numpy as np from pandas import Series, DataFrame arr = np.arange(12.).reshape((3, 4)) print(arr) print("arr[0]:") print(arr[0]) print("arr-arr[0]:") print(arr-arr[0]) print("Operation between data frame and series") frame = DataFrame(np.arange(12.).reshape((4, 3)), columns=list('bde'), index=['Utah', 'Ohio', 'Texas', 'Oregon']) series = frame.ix[0] print("frame is \n", frame) print("series is \n", series) print("frame-series: \n", frame-series) series2 = Series(range(3), index=['b', 'e', 'f']) print("if an index value is not found in either the DataFrame's columns or the Series' index") print("series2:\n", series2) print("frame+series2:\n", frame+series2) series3 = frame['d'] print("frame is \n", frame) print("series3 is \n", series3) print("if you want to instead broadcast over the columns,matching on the rows,you have to use one columns: ") print("frame.sub(series3,axis=0: \n", frame.sub(series3, axis=0))

转载于:https://www.cnblogs.com/wutongyuhou/p/6853207.html

转载地址:https://blog.csdn.net/weixin_30677617/article/details/96575248 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:如何写出高性能的SQL语句(转)
下一篇:Oracle 面试宝典 - General Questions

发表评论

最新留言

逛到本站,mark一下
[***.202.152.39]2024年04月18日 12时01分27秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章