Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 从dataframe.min()系列对象中提取整数?_Python_Pandas_Dataframe_Series - Fatal编程技术网

Python 从dataframe.min()系列对象中提取整数?

Python 从dataframe.min()系列对象中提取整数?,python,pandas,dataframe,series,Python,Pandas,Dataframe,Series,我试图使用Pandas计算dataframe列中的最小值,然后对变量运行一个求值语句(如果是这个,那么是那个)。但是,无法对序列对象求值。如何从熊猫系列对象中提取数值 for file_ in postFiles: df2 = pd.read_csv(file_, header=0, delimiter=';', usecols=[0,1,2]) ymax = df2[['xvalue']].max(numeric_only=True) y

我试图使用Pandas计算dataframe列中的最小值,然后对变量运行一个求值语句(如果是这个,那么是那个)。但是,无法对序列对象求值。如何从熊猫系列对象中提取数值

    for file_ in postFiles:
        df2 = pd.read_csv(file_, header=0, delimiter=';', usecols=[0,1,2])
        ymax = df2[['xvalue']].max(numeric_only=True)
        ymin = df2[['yvalue']].min(numeric_only=True)
        print(ymax)
        print(ymin)

        if ymax > ymin:
        print ('hello')
这是我的代码示例

运行此操作时,我遇到以下错误:

ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

max
min
返回一个
Series
你想要数组中的标量值试试这个:
ymax=df2[['xvalue']].max(numeric_only=True)[0]ymin=df2['yvalue'].min(numeric_only=True)[0]
Perfect@EdChum,正是我需要的答案-非常感谢你的快速回复
max
min
返回一个
Series
你想要数组中的标量值试试这个:
ymax=df2[['xvalue']].max(numeric_only=True)[0]ymin=df2['yvalue'].min(numeric_only=True)[0]
Perfect@EdChum,这正是我需要的答案-非常感谢你的快速回复!