pandas 数据帧到 select 特定数据的条件

Conditions over pandas dataframe to select specific data

我想select我的部分数据作图,条件是方程式。 例如:select_data = Qtn < Fr**2 and Qtn > 0.1*Fr 完整的代码和数据为here

df = pd.DataFrame()
df['Qtn'] = np.linspace(0.1,10,100)
df['Fr'] = np.linspace(0.1,200,100)
data_select =  df[(df.Qtn < (70/((1+0.06*df.Fr)**17)+11)) & (df.Qtn > ((32*70-1000)/(100-32*df.Fr))) ]

但这不起作用,因为没有使用 df.Fr 进行元素智能化 这是我的数据,我想要 select 是基于第 1 行和第 2 行等式的 SC 区域

但是当我 运行 代码时,我可以 select 是这样的:

你的等式(32*70-1000)/(100-32*Fr)在渐近线后变为负数:

import numpy as np
import matplotlib.pyplot as plt 

qt2 = (32*70-1000)/(100-32*Fr)
Fr = np.logspace(-3, 3, 100)
plt.semilogx(Fr, qt2)

所以在 Fr > 100/32(等式中的分母为 0)之后,您将再次满足这两个条件。因此,添加条件以限制 Fr 值将是比限制小于曲线交点更通用的解决方案:

df[(df.Qtn < (70/((1+0.06*df.Fr)**17)+11)) & (df.Qtn > ((32*70-1000)/(100-32*df.Fr)) & (df.Fr < 100/32) ]