简体   繁体   中英

I am trying to pass values to a function from the reliability library but without much success. here is my sample data and code

My sample data was as follows

Tag_Typ Alpha_Estimate Beta_Estimate PM01_Avg_Cost PM02_Avg_Cost
OLK-AC-101-14A_PM01 497.665 0.946584 1105.635 462.3833775
OLK-AC-103-01_PM01 288.672 0.882831 1303.8875 478.744375
OLK-AC-1105-01_PM01 164.282 0.787158 763.4475758 512.185814
OLK-AC-236-05A_PM01 567.279 0.756839 640.718 450.3277778
OLK-AC-276-05A_PM01 467.53 0.894773 1536.78625 439.78

This my sample code

import pandas as pd
import numpy as np
from reliability.Repairable_systems import optimal_replacement_time
import matplotlib.pyplot as plt
data = pd.read_excel (r'C:\Users\\EU_1_EQ_PM01_Cost.xlsx')
data_frame = pd.DataFrame(data, columns= ['Alpha_Estimate','Beta_Estimate','PM01_Avg_Cost','PM02_Avg_Cost'])

Alpha_Est=pd.DataFrame(data, columns= ['Alpha_Estimate'])
Beta_Est=pd.DataFrame(data, columns= ['Beta_Estimate'])
PM_Est=pd.DataFrame(data, columns= ['PM02_Avg_Cost'])
CM_Est=pd.DataFrame(data, columns= ['PM01_Avg_Cost'])
optimal_replacement_time(cost_PM=PM_Est, cost_CM=CM_Est, weibull_alpha=Alpha_Est, weibull_beta=Beta_Est,q=0)
plt.show()

I need to loop through the value set for each tag and pass those values to the Optimal replacement function to return the results.

[Sample Output] ValueError: Can only compare identically-labeled DataFrame objects

I would appreciate any suggestions on how I can pass the values of the PM cost, PPM cost, and the distribution parameters alpha and beta in the function as I iterate through the tag-type and print the results for each tag. Thanks.

The core of your question is how to iterate through a list in Python. This will achieve what you're after:

import pandas as pd
from reliability.Repairable_systems import optimal_replacement_time

df = pd.read_excel(io=r"C:\Users\Matthew Reid\Desktop\sample_data.xlsx")
alpha = df["Alpha_Estimate"].tolist()
beta = df["Beta_Estimate"].tolist()
CM = df["PM01_Avg_Cost"].tolist()
PM = df["PM02_Avg_Cost"].tolist()

ORT = []
for i in range(len(alpha)):
    ort = optimal_replacement_time(cost_PM=PM[i], cost_CM=CM[i], weibull_alpha=alpha[i], weibull_beta=beta[i],q=0)
    ORT.append(ort.ORT)

print('List of the optimal replacement times:\n',ORT)

On a separate note, all of your beta values are less than 1. This means the hazard rate is decreasing (aka. infant mortality / early life failures). When you run the above script, each iteration will print the warning:

"WARNING: weibull_beta is < 1 so the hazard rate is decreasing, therefore preventative maintenance should not be conducted."

If you have any further questions, you know how to contact me:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM