Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas
- import seaborn
- data = pandas.read_csv('support_data.csv')
- # названия сегментов и интервалов
- segments_old = ['Segment 0', 'Segment 1', 'Segment 2']
- segments_new = ['Потенциальные клиенты', 'Обычные клиенты', 'VIP-клиенты']
- intervals = ['До внедрения роботов', 'После внедрения роботов']
- intervals_column = list(data['interval'])
- segments_column = list(data['segment'])# ваш код здесь
- score_column = list(data['score'])# ваш код здесь
- #print(sum(score_column[:300]))
- # средние оценки
- mean_scores = []
- # ваш код здесь
- # Создаём по циклу для каждой ячейки хитмэпа До и После
- counter_before = 0 # обнуляем счетчик значений
- counter_after = 0
- score_before = 0
- score_after = 0
- counter_before_list = [] #создаем списки для подсчета одинаковых значений до и после внедрения роботов
- counter_after_list = []
- for segment in segments_old:
- score_before = 0
- counter_before = 0
- score_after = 0
- counter_after = 0
- for cnt in intervals_column:
- if cnt == intervals[0]:
- counter_before_list.append(cnt)
- counter_before = len(counter_before_list)
- score_before = sum(score_column[:(counter_before+1)])
- # score_before = sum(float(counter_before_list))
- if cnt == intervals[1]:
- counter_after_list.append(cnt)
- counter_after = len(counter_after_list)
- score_after = sum(score_column[:(counter_after+1)])
- #print(counter_before_list[:5])
- segment_scores = [score_before / counter_before, score_after / counter_after]
- mean_scores.append(segment_scores)
- #
- print(counter_before, score_before)
- print(counter_after, score_after)
- seaborn.heatmap(mean_scores, xticklabels=intervals, yticklabels=segments_new, annot=True, cmap='RdYlGn')
Add Comment
Please, Sign In to add comment