获得两个列表之间的最小值和最大值

时间:2018-06-06 10:11:56

标签: python list compare max min

我正在尝试获取列表之间的最大值和最小值,以便稍后进行计算,但我一直收到语法错误,我不知道出了什么问题。这是我的代码:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats
data = pd.DataFrame({"concentratie": [0.05, 0.10, 0.15, 0.20, 0.30, 0.50, 0.75, 1.00], "absorptie": [0.415, 0.509, 0.573, 0.640, 0.686, 0.711, 0.724, 0.733], "Duplo": [0.446, 0.529, 0.622, 0.638, 0.675, 0.702, 0.715, 0.732]})

def function(absorptie, Duplo):
    list 3 = [max(value) for value in zip(data['absorptie'],data['Duplo'])]
    return list 3

def function(absorptie, Duplo):
    list 4 = [min(value) for value in zip(absorptie, Duplo)]
    return list 4

1 个答案:

答案 0 :(得分:0)

您的变量名称无效:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats
data = pd.DataFrame({"concentratie": [0.05, 0.10, 0.15, 0.20, 0.30, 0.50, 0.75, 1.00], "absorptie": [0.415, 0.509, 0.573, 0.640, 0.686, 0.711, 0.724, 0.733], "Duplo": [0.446, 0.529, 0.622, 0.638, 0.675, 0.702, 0.715, 0.732]})

def function(absorptie, Duplo):
    list_3 = [max(value) for value in zip(data['absorptie'],data['Duplo'])]
    return list_3

def function(absorptie, Duplo):
    list_4 = [min(value) for value in zip(absorptie, Duplo)]
    return list_4