where cut query melt函数用法
一,where函数用法
where可以通过Pandas包调用也可以通过numpy来调用。但是日常我们使用numpy调用where的场景会更多。
1. 使用Pandas中的where
数据源
1 #%%
2
3 import pandas as pd
4 import numpy as np
5 df = pd.DataFrame(
6 {
7 "商品":["mate book Pro2020 X","mate P40","mate Pro 40"],
8 "活动价":[9899,0,6899],
9 "原价":[10480,4188,7388]
10 }
11 )
12 df

![【Python】where cut query melt函数用法[编程语言教程]](https://www.zixueka.com/wp-content/uploads/2024/01/1706711987-28953ea31480149.jpg)

