# Start writing code here...
import numpy as np
import pandas as pd
from scipy import stats as st
import matplotlib.pyplot as plt
%matplotlib inline
val = pd.read_csv("nps.csv", delimiter=";")
val
dop = pd.read_csv("dop sved.csv", delimiter=";")
dop['ID'] = dop['Клиент']
del dop['Клиент']
dop
df = pd.merge(val, dop, on=('ID'))
df
SP_M = np.array(df.Статус[(df.Регион=="г. Санкт-Петербург, Ленинградская область")|(df.Регион == "г. Москва, Московская область")])
regions = np.array(df.Статус[(df.Регион !="г. Санкт-Петербург, Ленинградская область")|(df.Регион != "г. Москва, Московская область")])
SP_M
plt.hist(SP_M)
plt.hist(SP_M)
plt.hist(regions)
df['Пром'] = df['Статус'] =="Промоутер"
df
df['Крит'] = df['Статус'] == 'Критик'
df['Нейт'] = df['Статус'] == 'Нейтрал'
df
df["Пром"].sum() + df["Крит"].sum() +df['Нейт'].sum()
reg = df.groupby('Регион').sum()
reg['sum'] = reg['Пром']+ reg['Крит'] + reg['Нейт']
reg['NPS'] = ((reg['Пром']-reg['Крит'])/reg['sum'])*100
reg
plt.hist(reg['NPS'])
plt.show()
reg['id_reg'] = np.arange(len(reg))
reg
del reg['ID']
reg['id_reg'] = reg.index
reg
sex = df.groupby('Пол').sum()
sex['sum'] = sex['Пром']+ sex['Крит'] + sex['Нейт']
sex['NPS'] = ((sex['Пром']-sex['Крит'])/sex['sum'])*100
plt.hist(sex['NPS'])
plt.show()
sex['sex'] = sex.index
sex
sex = df.groupby('Пол').sum()
sex['sum'] = sex['Пром']+ sex['Крит'] + sex['Нейт']
sex['NPS'] = ((sex['Пром']-sex['Крит'])/sex['sum'])*100
sex['sex'] = sex.index
sex
os = df.groupby('и OS телефона').sum()
os['sum'] = os['Пром']+ os['Крит'] + os['Нейт']
os['NPS'] = ((os['Пром']-os['Крит'])/os['sum'])*100
os['os'] = os.index
os
df['Пол и ОС'] = df[['Пол', 'и OS телефона']].apply(tuple, axis=1)
df
sOS = df.groupby('Пол и ОС').sum()
sOS['sum'] = sOS['Пром']+ sOS['Крит'] + sOS['Нейт']
sOS['NPS'] = ((sOS['Пром']-sOS['Крит'])/sOS['sum'])*100
sOS['sos'] = sOS.index
sOS
car = df.groupby('Авто').sum()
car['sum'] = car['Пром']+ car['Крит'] + car['Нейт']
car['NPS'] = ((car['Пром']-car['Крит'])/car['sum'])*100
car['sos'] = car.index
car
This chart is empty
Chart was probably not set up properly in the notebook
inc = pd.read_csv('dop sved lric.csv', delimiter=';', decimal=',')
inc['NPS'] = ((inc['Пром']-inc['Крит'])/inc['sum'])*100
inc