当前位置: 首页 > news >正文

做网站尽在美橙互联河南关键词排名顾问

做网站尽在美橙互联,河南关键词排名顾问,网站建设 cn,长春做商业平台网站目录 一、用法精讲 116、pandas.Series.div方法 116-1、语法 116-2、参数 116-3、功能 116-4、返回值 116-5、说明 116-6、用法 116-6-1、数据准备 116-6-2、代码示例 116-6-3、结果输出 117、pandas.Series.truediv方法 117-1、语法 117-2、参数 117-3、功能 …

目录

一、用法精讲

116、pandas.Series.div方法

116-1、语法

116-2、参数

116-3、功能

116-4、返回值

116-5、说明

116-6、用法

116-6-1、数据准备

116-6-2、代码示例

116-6-3、结果输出

117、pandas.Series.truediv方法

117-1、语法

117-2、参数

117-3、功能

117-4、返回值

117-5、说明

117-6、用法

117-6-1、数据准备

117-6-2、代码示例

117-6-3、结果输出

118、pandas.Series.floordiv方法

118-1、语法

118-2、参数

118-3、功能

118-4、返回值

118-5、说明

118-6、用法

118-6-1、数据准备

118-6-2、代码示例

118-6-3、结果输出

119、pandas.Series.mod方法

119-1、语法

119-2、参数

119-3、功能

119-4、返回值

119-5、说明

119-6、用法

119-6-1、数据准备

119-6-2、代码示例

119-6-3、结果输出

120、pandas.Series.pow方法

120-1、语法

120-2、参数

120-3、功能

120-4、返回值

120-5、说明

120-6、用法

120-6-1、数据准备

120-6-2、代码示例

120-6-3、结果输出

二、推荐阅读

1、Python筑基之旅

2、Python函数之旅

3、Python算法之旅

4、Python魔法之旅

5、博客个人主页

一、用法精讲

116、pandas.Series.div方法
116-1、语法
# 116、pandas.Series.div方法
pandas.Series.div(other, level=None, fill_value=None, axis=0)
Return Floating division of series and other, element-wise (binary operator truediv).Equivalent to series / other, but with support to substitute a fill_value for missing data in either one of the inputs.Parameters:
other
Series or scalar value
level
int or name
Broadcast across a level, matching Index values on the passed MultiIndex level.fill_value
None or float value, default None (NaN)
Fill existing missing (NaN) values, and any new element needed for successful Series alignment, with this value before computation. If data in both corresponding Series locations is missing the result of filling (at that location) will be missing.axis
{0 or ‘index’}
Unused. Parameter needed for compatibility with DataFrame.Returns:
Series
The result of the operation.
116-2、参数

116-2-1、other(必须)标量、Series或DataFrame,表示要除以的值,可以是一个标量、另一个Series或DataFrame,如果是Series或DataFrame,则会根据索引进行对齐。

116-2-2、level(可选,默认值为None)一个整数或字符串,如果other是一个MultiIndex的Series或DataFrame,使用该参数可以指定索引的哪个层进行对齐,传入的值应该是层的级别的名称或位置(索引值)。

116-2-3、fill_value(可选,默认值为None)标量值,当对齐时,如果某个Series中的某个索引值在另一个Series中不存在,可以通过此参数提供一个填充值,以在计算时替换缺失值,默认为None,即缺失值会返回NaN

116-2-4、axis(可选,默认值为0)当other是DataFrame时,此参数指定沿哪个轴进行操作;对于Series,通常不需要使用此参数,默认值为0。

116-3、功能

        用于执行元素级除法的函数,它可以将当前Series的每个元素除以另一个Series或标量值。

116-4、返回值

        返回一个新的Series,其中包含除法运算的结果。如果参与运算的两个对象没有相同的索引,结果中缺失的索引会被填充为NaN(若未设置fill_value)。

116-5、说明

        无

116-6、用法
116-6-1、数据准备
116-6-2、代码示例
# 116、pandas.Series.div方法
import pandas as pd
# 创建一个Series
s1 = pd.Series([10, 20, 30], index=['a', 'b', 'c'])
s2 = pd.Series([1, 2, 3], index=['a', 'b', 'd'])
# 使用div方法
result = s1.div(s2, fill_value=0)
print(result)
116-6-3、结果输出
# 116、pandas.Series.div方法
# a    10.0
# b    10.0
# c     inf
# d     0.0
# dtype: float64
117、pandas.Series.truediv方法
117-1、语法
# 117、pandas.Series.truediv方法
pandas.Series.truediv(other, level=None, fill_value=None, axis=0)
Return Floating division of series and other, element-wise (binary operator truediv).Equivalent to series / other, but with support to substitute a fill_value for missing data in either one of the inputs.Parameters:
other
Series or scalar value
level
int or name
Broadcast across a level, matching Index values on the passed MultiIndex level.fill_value
None or float value, default None (NaN)
Fill existing missing (NaN) values, and any new element needed for successful Series alignment, with this value before computation. If data in both corresponding Series locations is missing the result of filling (at that location) will be missing.axis
{0 or ‘index’}
Unused. Parameter needed for compatibility with DataFrame.Returns:
Series
The result of the operation.
117-2、参数

117-2-1、other(必须)标量、Series或DataFrame,表示要进行除法运算的值,可以是标量、另一个Series或DataFrame,如果other是Series或DataFrame,则会根据索引进行对齐。

117-2-2、level(可选,默认值为None)一个整数或字符串,如果other是具有MultiIndex的Series或DataFrame,使用该参数可以指定索引的哪个层进行对齐,level可以是层的名称或位置(索引值)。

117-2-3、fill_value(可选,默认值为None)标量值,在对齐过程中,如果某个Series的某个索引值在另一个Series或DataFrame中不存在,可以通过此参数提供一个填充值,以在计算时替换缺失值,默认值为None,即缺失值会返回NaN。

117-2-4、axis(可选,默认值为0)当other是DataFrame时,此参数指定沿哪个轴进行操作;对于Series,通常不需要使用此参数,默认值为0(即沿索引方向)。

117-3、功能

        用于执行元素级的真除法运算,它与Series.div()方法的主要区别在于truediv明确表示执行浮点除法(即除法结果是浮点数),而div方法默认会根据传入的数据类型自动选择整数除法或浮点除法。

117-4、返回值

        返回一个新的Series,其中包含除法运算的结果,如果参与运算的两个对象没有相同的索引,结果中缺失的索引会被填充为NaN(若未设置fill_value)。

117-5、说明

        无

117-6、用法
117-6-1、数据准备
117-6-2、代码示例
# 117、pandas.Series.truediv方法
import pandas as pd
# 创建两个Series
s1 = pd.Series([10, 20, 30], index=['a', 'b', 'c'])
s2 = pd.Series([1, 2, 3], index=['a', 'b', 'd'])
# 使用truediv方法进行真除法
result = s1.truediv(s2, fill_value=1)  
print(result)
117-6-3、结果输出
# 117、pandas.Series.truediv方法
# a    10.000000
# b    10.000000
# c    30.000000
# d     0.333333
# dtype: float64
118、pandas.Series.floordiv方法
118-1、语法
# 118、pandas.Series.floordiv方法
pandas.Series.floordiv(other, level=None, fill_value=None, axis=0)
Return Integer division of series and other, element-wise (binary operator floordiv).Equivalent to series // other, but with support to substitute a fill_value for missing data in either one of the inputs.Parameters:
other
Series or scalar value
level
int or name
Broadcast across a level, matching Index values on the passed MultiIndex level.fill_value
None or float value, default None (NaN)
Fill existing missing (NaN) values, and any new element needed for successful Series alignment, with this value before computation. If data in both corresponding Series locations is missing the result of filling (at that location) will be missing.axis
{0 or ‘index’}
Unused. Parameter needed for compatibility with DataFrame.Returns:
Series
The result of the operation.
118-2、参数

118-2-1、other(必须)标量、Series或DataFrame,表示要进行地板除法运算的值,可以是标量、另一个 Series或DataFrame,如果other是Series或DataFrame,则会根据索引进行对齐。

118-2-2、level(可选,默认值为None)一个整数或字符串,如果other是具有MultiIndex的Series或DataFrame,使用该参数可以指定索引的哪个层进行对齐,level可以是层的名称或位置(索引值)。

118-2-3、fill_value(可选,默认值为None)标量值,在对齐过程中,如果某个Series的某个索引值在另一个Series或DataFrame中不存在,可以通过此参数提供一个填充值,以在计算时替换缺失值,默认值为None,即缺失值会返回NaN

118-2-4、axis(可选,默认值为0)一个整数或字符串,当other是DataFrame时,此参数指定沿哪个轴进行操作;对于Series,通常不需要使用此参数,默认值为0(即沿索引方向)。

118-3、功能

        用于执行元素级的地板除法运算,该运算的结果是向下取整的整数除法,即不管余数是多少,结果都会向下舍入到最接近的整数。

118-4、返回值

        返回一个新的Series,其中包含地板除法运算的结果,对于不存在的索引值,结果中将填充为NaN(若未设置fill_value)。

118-5、说明

        无

118-6、用法
118-6-1、数据准备
118-6-2、代码示例
# 118、pandas.Series.floordiv方法
import pandas as pd
# 创建两个Series
s1 = pd.Series([10, 20, 30], index=['a', 'b', 'c'])
s2 = pd.Series([3, 4, 7], index=['a', 'b', 'd'])
# 使用floordiv方法进行地板除法
result = s1.floordiv(s2, fill_value=1)
print(result)
118-6-3、结果输出
# 118、pandas.Series.floordiv方法
# a     3.0
# b     5.0
# c    30.0
# d     0.0
# dtype: float64
119、pandas.Series.mod方法
119-1、语法
# 119、pandas.Series.mod方法
pandas.Series.mod(other, level=None, fill_value=None, axis=0)
Return Modulo of series and other, element-wise (binary operator mod).Equivalent to series % other, but with support to substitute a fill_value for missing data in either one of the inputs.Parameters:
other
Series or scalar value
level
int or name
Broadcast across a level, matching Index values on the passed MultiIndex level.fill_value
None or float value, default None (NaN)
Fill existing missing (NaN) values, and any new element needed for successful Series alignment, with this value before computation. If data in both corresponding Series locations is missing the result of filling (at that location) will be missing.axis
{0 or ‘index’}
Unused. Parameter needed for compatibility with DataFrame.Returns:
Series
The result of the operation.
119-2、参数

119-2-1、other(必须)标量、Series或DataFrame,表示要进行模运算的值,可以是标量、另一个Series或DataFrame,如果other是Series或DataFrame,则会根据索引进行对齐。

119-2-2、level(可选,默认值为None)一个整数或字符串,如果other是具有MultiIndex的Series或DataFrame,使用该参数可以指定索引的哪个层进行对齐,level可以是层的名称或位置(索引值)。

119-2-3、fill_value(可选,默认值为None)标量值,在对齐过程中,如果某个Series的某个索引值在另一个Series或DataFrame中不存在,可以通过此参数提供一个填充值,以在计算时替换缺失值,默认值为None,即缺失值会返回NaN。

119-2-4、axis(可选,默认值为0)当other是DataFrame时,此参数指定沿哪个轴进行操作;对于Series,通常不需要使用此参数,默认值为0(即沿索引方向)。

119-3、功能

        用于执行元素级的模运算(取余运算),该运算将每个元素除以给定的值,并返回余数。

119-4、返回值

        返回一个新的Series,其中包含模运算的结果,对于不存在的索引值,结果中将填充为NaN(若未设置fill_value)。

119-5、说明

119-5-1、对齐:当other是另一个Series或DataFrame时,mod()会根据索引进行对齐,如果索引不匹配,可能会得到NaN(除非使用fill_value填充)。

119-5-2、数据类型:模运算的结果将具有与输入Series相同的数据类型。对于整数类型的Series,结果也是整数类型;对于浮点型,结果将是浮点型。

119-6、用法
119-6-1、数据准备
119-6-2、代码示例
# 119、pandas.Series.mod方法
import pandas as pd
# 创建两个Series
s1 = pd.Series([10, 20, 30], index=['a', 'b', 'c'])
s2 = pd.Series([3, 4, 7], index=['a', 'b', 'd'])
# 使用mod方法进行模运算
result = s1.mod(s2, fill_value=1)
print(result)
119-6-3、结果输出
# 119、pandas.Series.mod方法
# a    1.0
# b    0.0
# c    0.0
# d    1.0
# dtype: float64
120、pandas.Series.pow方法
120-1、语法
# 120、pandas.Series.pow方法
pandas.Series.pow(other, level=None, fill_value=None, axis=0)
Return Exponential power of series and other, element-wise (binary operator pow).Equivalent to series ** other, but with support to substitute a fill_value for missing data in either one of the inputs.Parameters:
other
Series or scalar value
level
int or name
Broadcast across a level, matching Index values on the passed MultiIndex level.fill_value
None or float value, default None (NaN)
Fill existing missing (NaN) values, and any new element needed for successful Series alignment, with this value before computation. If data in both corresponding Series locations is missing the result of filling (at that location) will be missing.axis
{0 or ‘index’}
Unused. Parameter needed for compatibility with DataFrame.Returns:
Series
The result of the operation.
120-2、参数

120-2-1、other(必须)标量、Series或DataFrame,表示幂运算的指数,可以是标量(单一的幂值),也可以是另一个Series或DataFrame,如果other是Series或DataFrame,则会根据索引进行对齐。

120-2-2、level(可选,默认值为None)一个整数或字符串,如果other是具有MultiIndex的Series或DataFrame,使用该参数可以指定索引的哪个层进行对齐,level可以是层的名称或位置(索引值)。

120-2-3、fill_value(可选,默认值为None)标量值,在对齐过程中,如果某个Series的某个索引值在另一个Series或DataFrame中不存在,可以通过此参数提供一个填充值,以在计算时替换缺失值,默认值为None,即缺失值会返回NaN。

120-2-4、axis(可选,默认值为0)当other是DataFrame时,此参数指定沿哪个轴进行操作;对于Series,通常不需要使用此参数,默认值为0(即沿索引方向)。

120-3、功能

        用于对Series中的每个元素进行幂运算,它的功能是将Series的每个元素的值提高到指定的幂次。

120-4、返回值

        返回一个新的Series,其中包含幂运算的结果,对于不存在的索引值,结果中将填充为NaN(若未设置fill_value)。

120-5、说明

120-5-1、对齐:当other是另一个Series或DataFrame时,pow()方法会根据索引进行对齐,如果索引不匹配,可能会得到NaN(除非使用fill_value填充)。

120-5-2、数据类型:幂运算的结果将具有与输入Series相同的数据类型,对于整数类型的Series,结果也是整数类型;对于浮点型,结果将是浮点型。

120-6、用法
120-6-1、数据准备
120-6-2、代码示例
# 120、pandas.Series.pow方法
import pandas as pd
# 创建两个Series
s1 = pd.Series([2, 3, 4], index=['a', 'b', 'c'])
s2 = pd.Series([1, 2, 3], index=['a', 'b', 'd'])
# 使用pow方法进行幂运算
result = s1.pow(s2, fill_value=0)
print(result)
120-6-3、结果输出
# 120、pandas.Series.pow方法
# a    2.0
# b    9.0
# c    1.0
# d    0.0
# dtype: float64

二、推荐阅读

1、Python筑基之旅
2、Python函数之旅
3、Python算法之旅
4、Python魔法之旅
5、博客个人主页
http://www.ds6.com.cn/news/124239.html

相关文章:

  • 网站界面设计策划书怎么做seo学院
  • 做网站一般费用多少百度官方入口
  • 旅游网站如何做站长工具忘忧草
  • 祁阳网站设计刷移动关键词优化
  • 测试网站怎么做的企业qq怎么申请
  • 建设官方网站的好处和坏处贵港seo关键词整站优化
  • 杭州的网站建设公司哪家好下百度安装
  • 名片在哪个网站可以做青岛seo外包公司
  • 网站如何做搜狗搜索引擎外贸网站免费建站
  • 装饰公司网站建站阿里云官网首页
  • 长沙网上商城网站建设方案营销渠道的三个类型
  • 南山网站制作亚马逊跨境电商
  • 北京通州做网站百度官方网
  • 网站先做移动站在做pc站可行吗北京搜索引擎优化经理
  • 网站定位授权开启权限怎么做百度题库
  • 移动端html5模板seo排名如何
  • 如何分析竞争对手的网站武汉楼市最新消息
  • 做网站空间放哪些文件夹12345浏览器
  • 承德网站开发网站制作工具有哪些
  • 国内权重网站排名公司软文
  • Dw怎么做网站往里面加标题和字南京网站设计优化公司
  • 19年做网站免费申请网站com域名
  • 博山政府网站建设哪家好关键词优化是什么工作
  • 短视频素材库大全深圳seo排名哪家好
  • wordpress 标签链接地址seo关键字排名
  • 上海专业网站制作设计公司哪家好怎么开发一个网站
  • 临海企业网站建设公司北京seo主管
  • 自己做的网站如何赚钱厦门seo推广
  • 网站建设公司加盟百度seo权重
  • 开发公司网签操作流程seo标题优化的方法