我正在寻找一种更Pythonic(并且更快!)的方法来清除任何行中具有三个字符串之一的任何行。我的代码可以工作,但是太慢了!
任何建议,将不胜感激!
# Check out each row
for i,row in df2.iterrows():
for index in range(df2.shape[1]):
# Check out values in each column
# if it's 98 or 99, drop it
if df2.iloc[i,index] == '98.00':
df2.drop(i)
print('dropped row ', i, ' due to high value')
elif df2.iloc[i,index] == '99.00':
df2.drop(i)
print('dropped row ', i, ' due to high value')
# or if the value is the default text null value, drop it
elif df2.iloc[i,index] == '#NULL!':
df2.drop(i)
print('dropped row ', i, 'due to null value')
素胚勾勒不出你
呼啦一阵风
潇湘沐
冉冉说
相关分类