python | pandas data frame . rml()

哎哎哎:# t0]https://www . geeksforgeeks . org/python 熊猫 data frame-rml/

Python 是进行数据分析的优秀语言,主要是因为以数据为中心的 python 包的奇妙生态系统。 【熊猫】 就是其中一个包,让导入和分析数据变得容易多了。

熊猫 dataframe.rmul() 函数用于寻找 dataframe 和其他元素(二进制运算符 rfloordiv)的乘积。该功能本质上与执行其他* dataframe 相同,但支持替换其中一个输入中缺失的数据。

语法: DataFrame.rmul(other,axis='columns ',level=None,fill_value=None) 参数: other : Series,DataFrame,或常量 axis : 对于 Series 输入,axis 要匹配 级别上的 Series 索引:跨级别广播,匹配传递的 MultiIndex 级别上的索引值 fill_value : 填充现有如果两个相应数据框位置的数据都丢失,结果将丢失 返回:结果:数据框

示例#1: 使用 rmul()函数查找一个数列与一个数据框的乘积。

Python 3

# importing pandas as pd
import pandas as pd

# Creating the dataframe
df = pd.DataFrame({"A":[1, 5, 3, 4, 2],
                   "B":[3, 2, 4, 3, 4],
                   "C":[2, 2, 7, 3, 4],
                   "D":[4, 3, 6, 12, 7]},
                    index =["A1", "A2", "A3", "A4", "A5"])

# Print the dataframe
df

让我们创建这个系列

Python 3

# importing pandas as pd
import pandas as pd

# Create the series
sr = pd.Series([12, 25, 64, 18], index =["A", "B", "C", "D"])

# Print the series
sr

让我们使用 dataframe.rmul()函数来查找数列与 dataframe 的乘积

Python 3

df.rmul(sr, axis = 1)