Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
1.6 kB
1
Indexable
Never
# Выбрать клиентов из anomalies_grouped_sorted с меткой 'dil_MO+KP' и значениями MO_dealer_monthly_ton_GZPN и KP_dealer_monthly_ton_GZPN выше 75 квартиля
anomalies_MO_KP = anomalies_grouped_sorted[anomalies_grouped_sorted['label'] == 'dil_MO+KP']
quantile_MO_KP = anomalies_MO_KP['MO_dealer_monthly_ton_GZPN'].quantile(0.75)
quantile_KP_KP = anomalies_MO_KP['KP_dealer_monthly_ton_GZPN'].quantile(0.75)

# Выбрать клиентов из anomalies_grouped_sorted с меткой 'dil_MO' и значение MO_dealer_monthly_ton_GZPN выше 75 квартиля
anomalies_MO = anomalies_grouped_sorted[anomalies_grouped_sorted['label'] == 'dil_MO']
quantile_MO = anomalies_MO['MO_dealer_monthly_ton_GZPN'].quantile(0.75)

# Выбрать клиентов из anomalies_grouped_sorted с меткой 'dil_KP' и значение KP_dealer_monthly_ton_GZPN выше 75 квартиля
anomalies_KP = anomalies_grouped_sorted[anomalies_grouped_sorted['label'] == 'dil_KP']
quantile_KP = anomalies_KP['KP_dealer_monthly_ton_GZPN'].quantile(0.75)

# Фильтрация df по условиям
df_new_anomalies = df[
    ((df['client_inn_dil'].isin(anomalies_MO_KP['client_inn_dil'])) & 
    (df['MO_dealer_monthly_ton_GZPN'] > quantile_MO_KP) & 
    (df['KP_dealer_monthly_ton_GZPN'] > quantile_KP_KP)) |
    ((df['client_inn_dil'].isin(anomalies_MO['client_inn_dil'])) & 
    (df['MO_dealer_monthly_ton_GZPN'] > quantile_MO)) |
    ((df['client_inn_dil'].isin(anomalies_KP['client_inn_dil'])) & 
    (df['KP_dealer_monthly_ton_GZPN'] > quantile_KP))
]
Leave a Comment