Forum Discussion

M4dsteve's avatar
M4dsteve
Frequent Visitor
5 years ago
Solved

Calculated Column (Probability of Exceedance) Using Earlier Values

Hi all,   I am having some difficulty with a calculation that is used to calulate a probability of exceedance in a given data set.   Long story short this is for the Industrial Hygiene industry a...
  • M4dsteve's avatar
    M4dsteve
    5 years ago

    Hi v-janeyg-msft ,

     

    I managed to solve this with a python script that outputs the data after processing the recursive calculation. 

     

    Turns out pandas is super powerful and it was a good learning experience 😄

    Snippet of code from that column:

     # Build pdep Column
        for i in range(0, (len(support))):
            if support.loc[i, 'IsNDValue']:
                na = 0
            else:
                na = support.loc[i, 'Exposure Result mg_x']
            nbj = support.loc[i, 'n_bj']
            if i != 0:
                prev = support.loc[i - 1, 'pdep']
                support.loc[i, 'pdep'] = prev + (1 - prev) * na / (na + nbj)
            else:
                prev = 0
                support.loc[i, 'pdep'] = prev + (1 - prev) * na / (na + nbj)

     

     

    Thanks for your help.