2024-04-24 05:48:27 发布
网友
我想根据两个条件选择行
df.Length.str.isnumeric() == False & df.Type == "Type1"
并将特定列Length中所有对应行的值更改为列表中的值,例如:
Length
[120, 2151, 215, 25, 2451]
谢谢你!你知道吗
编辑
根据你的评论,我想出了一个简短的解决方案。你知道吗
import pandas as pd import math df = pd.DataFrame( [ [10, 15, float('NaN')], [25, 30, 35], [40, 45, 50], [55, 60, float('NaN')] ], columns=list('ABC')) pre_computed_list = [20, 65] row_indices = df['C'][df['C'].apply(math.isnan)].index.tolist() df['C'][row_indices] = pre_computed_list
编辑
根据你的评论,我想出了一个简短的解决方案。你知道吗
相关问题 更多 >
编程相关推荐