根据条件先筛选,再修改指定列的值
import pandas as pdimport numpy as npdf_params = pd.DataFrame({'city_name': ['杭州', '福州', '泉州', '扬州']})df_params['f1'] = 0df_params['f2'] = 0df_params['f3'] = 0df_params['f4'] = 0# 方法1 locdf_params.loc[df_params['city_name'].isin(['福州', '泉州']), 'f1
原创
2021-12-29 14:18:39 ·
239 阅读 ·
0 评论