Advertisement
AliaksandrLet

Функция для одной строки

Apr 18th, 2022 (edited)
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. import pandas as pd
  2. support_log_grouped = pd.read_csv('/datasets/support_log_grouped.csv')
  3.  
  4. def alert_group_importance(row):
  5.     """
  6.    Возвращает приоритет
  7.    """
  8.    
  9.     alert_group = row['alert_group']
  10.     importance = row['importance']
  11.    
  12.     if (alert_group == 'средний') & (importance == 1):
  13.         return 'обратить внимание'
  14.     elif (alert_group == 'высокий') & (importance == 1):
  15.         return 'высокий риск'
  16.     elif (alert_group == 'критичный') & (importance == 1):
  17.         return 'блокер'
  18.     return 'в порядке очереди'
  19.  
  20. row_values = ['высокий', 1]
  21. row_columns = ['alert_group', 'importance']
  22.  
  23. row = pd.Series(data=row_values, index=row_columns)
  24.  
  25. #print(alert_group_importance(row))
  26.  
  27. support_log_grouped['importance_status'] = support_log_grouped.apply(alert_group_importance, axis=1)
  28.  
  29. #print(support_log_grouped)
  30. print(support_log_grouped['importance_status'].value_counts())
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement