运行 ❯
获取你的
自己的 Python
服务器
×
更改方向
更改主题,深色/浅色
前往 Spaces
import pandas as pd data = { "age": [50, 40, 30, 40, 20, 10, 30], "qualified": [True, False, False, False, False, True, True] } df = pd.DataFrame(data) newdf = df.mask(df["age"] > 30) print(newdf)
age qualified 0 NaN NaN 1 NaN NaN 2 30.0 0.0 3 NaN NaN 4 20.0 0.0 5 10.0 1.0 6 30.0 1.0