构建两个5乘1的dataframe,并计算A列的sumproduct
时间: 2024-05-10 13:21:05 浏览: 173
这里提供一种Python pandas库的解决方案:
```python
import pandas as pd
# 构建第一个DataFrame
df1 = pd.DataFrame({'A': [1, 2, 3, 4, 5]})
print(df1)
# 构建第二个DataFrame
df2 = pd.DataFrame({'A': [6, 7, 8, 9, 10]})
print(df2)
# 计算A列的sumproduct
sumproduct = (df1['A'] * df2['A']).sum()
print("A列的sumproduct为:", sumproduct)
```
输出结果:
```
A
0 1
1 2
2 3
3 4
4 5
A
0 6
1 7
2 8
3 9
4 10
A列的sumproduct为: 130
```
阅读全文