看过来
《pandas 教程》 持续更新中,提供建议、纠错、催更等加作者微信: gr99123(备注:pandas教程)和关注公众号「盖若」ID: gairuo。跟作者学习,请进入 Python学习课程。欢迎关注作者出版的书籍:《深入浅出Pandas》 和 《Python之光》。
(编码题)一句话:把两个 3 天销售额取最大值
import pandas as pd
a = pd.Series([10, 20, 30], index=['8-01', '8-02', '8-03'])
b = pd.Series([15, 25, 20], index=['8-01', '8-02', '8-03'])
代码如下:
max_sales = a.combine(b, max)
print(max_sales)
输出:
8-01 15
8-02 25
8-03 30
dtype: int64
(完)
更新时间:2025-08-28 11:48:35 标签:pandas python 销售额 最大值