gpt4 book ai didi

python - 查找给定温度范围内数组中的最大值

转载 作者:太空宇宙 更新时间:2023-11-03 19:47:27 24 4
gpt4 key购买 nike

Study   Gas Surfactant  Surfactant Concentration    Additive    Additive 

Concentration LiquidPhase Quality Pressure (Psi) Temperature (C) Shear Rate (/Sec) Halflife (Min) Viscosity Color
Thakore 2020 N2 AOS 1 w% None None DI Water 0.95 10 50 0 0 0 yellow
Thakore 2020 N2 AOS 1 w% None None DI Water 0.95 10 50 0 51 0 yellow
Thakore 2020 N2 AOS 1 w% None None DI Water 0.95 10 50 0 61 0 yellow
Thakore 2020 N2 AOS 1 w% None None DI Water 0.95 10 50 0 75 0 yellow
Thakore 2020 N2 AOS 1 w% None None DI Water 0.95 10 50 0 105 0 yellow
Thakore 2020 N2 AOS 1 w% None None DI Water 0.95 10 50 0 0 0 yellow
Thakore 2020 N2 AOS 1 w% None None DI Water 0.95 10 50 0 12 0 yellow
Thakore 2020 N2 AOS 1 w% None None DI Water 0.95 10 50 0 25 0 yellow
Thakore 2020 N2 AOS 1 w% None None DI Water 0.95 10 50 0 34 0 yellow
Thakore 2020 N2 AOS 1 w% None None DI Water 0.95 10 50 0 48 0 yellow
Thakore 2020 N2 AOS 1 w% None None DI Water 0.95 10 100 0 0 0 yellow
Thakore 2020 N2 AOS 1 w% None None DI Water 0.95 10 100 0 0.1 0 yellow
Thakore 2020 N2 AOS 1 w% None None DI Water 0.95 10 100 0 0.5 0 yellow
Thakore 2020 N2 AOS 1 w% None None DI Water 0.95 10 100 0 0.79 0 yellow
Thakore 2020 N2 AOS 1 w% None None DI Water 0.95 10 100 0 0.9 0 yellow
Thakore 2020 N2 AOS 1 w% Guar 0.36 w% DI Water 0.95 10 50 0 0 0 yellow
Thakore 2020 N2 AOS 1 w% Guar 0.36 w% DI Water 0.95 10 50 0 26 0 yellow
Thakore 2020 N2 AOS 1 w% Guar 0.36 w% DI Water 0.95 10 50 0 72 0 yellow
Thakore 2020 N2 AOS 1 w% Guar 0.36 w% DI Water 0.95 10 50 0 84 0 yellow
Thakore 2020 N2 AOS 1 w% Guar 0.36 w% DI Water 0.95 10 50 0 120 0 yellow
Thakore 2020 N2 AOS 1 w% Guar 0.36 w% DI Water 0.95 10 100 0 0 0 yellow
Thakore 2020 N2 AOS 1 w% Guar 0.36 w% DI Water 0.95 10 100 0 0.33 0 yellow
Thakore 2020 N2 AOS 1 w% Guar 0.36 w% DI Water 0.95 10 100 0 1 0 yellow
Thakore 2020 N2 AOS 1 w% Guar 0.36 w% DI Water 0.95 10 100 0 1.9 0 yellow
Thakore 2020 N2 AOS 1 w% Guar 0.36 w% DI Water 0.95 10 100 0 2.4 0 yellow
Thakore 2020 N2 AOS 1 w% Guar 0.36 w% DI Water 0.95 10 100 0 0 0 yellow
Thakore 2020 N2 AOS 1 w% Guar 0.36 w% DI Water 0.95 10 100 0 0.2 0 yellow
Thakore 2020 N2 AOS 1 w% Guar 0.36 w% DI Water 0.95 10 100 0 1 0 yellow
Thakore 2020 N2 AOS 1 w% Guar 0.36 w% DI Water 0.95 10 100 0 1.3 0 yellow
Thakore 2020 N2 AOS 1 w% Guar 0.36 w% DI Water 0.95 10 100 0 1.9 0 yellow
Thakore 2020 N2 AOS 1 w% Guar 0.36 w% DI Water 0.95 10 100 0 0 0 yellow
Thakore 2020 N2 AOS 1 w% Guar 0.36 w% DI Water 0.95 10 100 0 0.1 0 yellow
Thakore 2020 N2 AOS 1 w% Guar 0.36 w% DI Water 0.95 10 100 0 0.2 0 yellow
Thakore 2020 N2 AOS 1 w% Guar 0.36 w% DI Water 0.95 10 100 0 0.26 0 yellow
Thakore 2020 N2 AOS 1 w% Guar 0.36 w% DI Water 0.95 10 100 0 0.3 0 yellow
Thakore 2020 N2 AOS 1 w% Guar 0.36 w% DI Water 0.95 10 150 0 0 0 yellow
Thakore 2020 N2 AOS 1 w% Guar 0.36 w% DI Water 0.95 10 150 0 0.05 0 yellow
Thakore 2020 N2 AOS 1 w% Guar 0.36 w% DI Water 0.95 10 150 0 0.08 0 yellow
Thakore 2020 N2 AOS 1 w% Guar 0.36 w% DI Water 0.95 10 150 0 0.13 0 yellow
Thakore 2020 N2 AOS 1 w% Guar 0.36 w% DI Water 0.95 10 150 0 0.2 0 yellow

上面显示的是我的数组的示例。如何找到给定温度下“半衰期”的最大值?假设我想从每个温度为 25 度的元素中找到“半衰期”的最大值。有没有一种优雅的方法来做到这一点?

我尝试在 for 循环中循环,将温度分成单独的列表,然后使用大量 if 语句,找到每个列表的最大值并将其编译回主列表中。这非常丑陋且耗时,我想知道是否有更好的方法来做到这一点。请告诉我!

基本上,我将 Excel 文件加载到 pandas 数据框中:

dv = pd.read_excel('data.xlsx')

然后我清理它并将其重命名为“cleaned”,这并不重要,只是提一下。

ahmed17 = cleaned[cleaned.Study == "Ahmed 2017"]
ahmed18 = cleaned[cleaned.Study == "Ahmed 2018"]
alzo = cleaned[cleaned.Study == "Alzobaidi 2017"]
reid = cleaned[cleaned.Study == "Reidenbach 1986"]
har = cleaned[cleaned.Study == "Harris 1987"]
chen = cleaned[cleaned.Study == "Chen, Y. 2016b"]
yan = cleaned[cleaned.Study == "Yanqing Wang 2017"]
hut = cleaned[cleaned.Study == "Hutchins 2005"]
tha = cleaned[cleaned.Study == "Thakore 2020"]
ha = cleaned[cleaned.Study == "Harris 1995"]

从那里,我将清理后的数据框分成单独的研究,这个项目是文献的组成。

trace1 = go.Scatter(y=ahmed17[selected_y], x=ahmed17[selected_x])

最后,我将每个单独的研究加载到迹线中,并将它们显示在图表中。选定的 y 和选定的 x 是字符串,例如“Temperature (C)”和“Halflife (Min)”。

我需要做的是,在将数组拆分为单独的研究之前,找到相对于每个温度(0,50,100,150,200,250,300)的最大“半衰期”并将它们编译成单独的列表,然后将它们编译成同一个列表。从那里我可以将列表分成单独的研究,然后我就可以开始了。我尝试使用以下内容来做到这一点:

tha25 = [x for x in tha[selected_x] if x == 25]

将 thakore 研究分成 25 度列表,然后从那里找到最大值。但我得到了我编译的列表的一堆 Nan 值,并且我不确定我是否正确地拆分了列表。

最佳答案

如果您的原始、清理后的数据框是 df,请尝试以下操作:

(df[df['Temperature']==25])['Halflife'].max()

关于python - 查找给定温度范围内数组中的最大值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60031589/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com