Определите функцию, которая принимает среднее значение и порог в качестве переменных:
def helping_func(value, threshold):
return (value > threshold)
Используйте цикл for
для выполнения условной проверки и сохранения в отдельных файлах csv:
for i in np.arange(0,21,1): # to import numpy as np
threshold = i/10 # to overcome floating point inaccuracy
result_df = df[helping_func(df["Mean"], threshold)]
csvFileName = "result" + str(i) + ".csv" # name the individual csv files in any format as you deemed appropriate
result_df.to_csv(csvFileName, sep=",") # sep character at your preference
Либо просто примените условную проверку внутри цикла for
:
for i in np.arange(0,21,1): # to import numpy as np
threshold = i/10 # to overcome floating point inaccuracy
result_df = df[df["Mean"] > threshold]
csvFileName = "result" + str(i) + ".csv" # name the individual csv files in any format as you deemed appropriate
result_df.to_csv(csvFileName, sep=",") # sep character at your preference