我是编程和python的新手。我有一个由pandas模块创建的数据帧。数据集的索引列是“Rho”、“Capacity”和“Model Version”。基于这些因素,我运行了一些模拟,并找到了每一个5运行的收入。这些列表示“平均值”、“下限”和“上限”。你知道吗
现在我想为每个特定的Rho和容量找到最佳的收入。所以我应该比较不同模型的上界和下界。如果一行的下界高于另一个上界的值,我应该删除上界较小的行。你知道吗
以下是我目前拥有的代码:
from pandas import *
df_rev = DataFrame.from_csv(path="revenue_total.csv", index_col=[3, 4, 5])
print(df_rev.iloc[0][2])
# removing those revenues in a class that are low:
for index1, row1 in df_rev.iterrows():
for index2, row2 in df_rev.iterrows():
if index1[0] is index2[0] and index1[1] is index2[1]:
if row1[1] > row2[2]:
df_rev = df_rev.drop(df_rev.index[index2])
elif row2[1] > row1[2]:
df_rev = df_rev.drop(df_rev.index[index1])
print(df_rev)
但是,我知道这是行不通的。有人知道我该怎么办吗?你知道吗
谢谢
你应该找到最大的收入。你知道吗
这将给出在索引0和1上分组的其他列的最大值。你知道吗
相关问题 更多 >
编程相关推荐