Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. BacksGas_Flow_sccm ContextID StepID Time_Elapsed iso_forest
  2. 61.81640625 7289972 19 40.503 -1
  3. 62.59765625 7289972 19 41.503 -1
  4. 63.671875 7289972 19 42.503 1
  5. 65.625 7289972 19 43.503 1
  6. 61.81640625 7289973 19 40.448 -1
  7. 62.59765625 7289973 19 41.448 -1
  8. 63.671875 7289973 19 42.448 1
  9. 65.625 7289973 19 43.448 1
  10.  
  11. def minus1_plus1_ratio(dictionary, new_df, step_df):
  12. dictionary[new_df] = dictionary[step_df].groupby(['ContextID', 'iso_forest']).size().reset_index(name='count')
  13. dictionary[new_df] = pd.pivot_table(dictionary[new_df], values = 'count', columns = ['iso_forest'],
  14. index = ['ContextID']).fillna(value = 0)
  15. dictionary[new_df]['-1/1'] = (dictionary[new_df][-1])/(dictionary[new_df][1])
  16. dictionary[new_df] = dictionary[new_df].sort_values(by = '-1/1', ascending = False)
  17. return dictionary[new_df]
  18.  
  19. BacksGas_Flow_sccm ContextID StepID Time_Elapsed iso_forest
  20. 61.81640625 7289972 19 40.503 1
  21. 62.59765625 7289972 19 41.503 1
  22. 63.671875 7289972 19 42.503 1
  23. 65.625 7289972 19 43.503 1
  24. 61.81640625 7289973 19 40.448 1
  25. 62.59765625 7289973 19 41.448 1
  26. 63.671875 7289973 19 42.448 1
  27. 65.625 7289973 19 43.448 1
  28.  
  29. dictionary[new_df]['-1/1'] = (dictionary[new_df][-1])/(dictionary[new_df][1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement