Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
2.2 kB
12
Indexable
Never
len(data_mo[data_mo['oblast']=='ХМАО + ЯНАО'])
len(data_mo[data_mo['oblast']=='Челябинская обл.'])
len(data_mo[data_mo['oblast']=='Свердловская обл.'])
len(data_mo[data_mo['oblast']=='Тюменская обл.'])

ural = data_mo[(data_mo['oblast']=='Ярославская обл.')&(data_mo['date']>='2015-01-01')]
ural_monthly = ural.groupby('date').agg(
    total_volume=('volume_t', 'sum'),
    total_revenue=('revenue', 'sum')
).reset_index()

ural_monthly

yaroslav_monthly = yaroslav_monthly[:-1]
yaroslav_monthly['region'] = 'Ярославская обл.'
yaroslav_monthly

yaroslav_monthly = yaroslav_monthly[['region', 'date', 'total_volume', 'total_revenue']]
data = pd.read_csv('data.csv')
data['date'] = pd.to_datetime(data['date'])
data = data.drop(['year_oper', 'month_oper', 'avg_price_stela', 'avg_price_komp', 'volume_l', 'sum_stela', 'sum_komp'], axis=1)

data.info()


yaroslav_full = pd.merge(yaroslav_monthly, data, on='date', how='outer')
yaroslav_full = yaroslav_full.drop(['region'], axis=1)
yaroslav_full

correlation_matrix = yaroslav_full.corr()

plt.figure(figsize=(8, 6))
sns.heatmap(correlation_matrix, annot=True, cmap='coolwarm', fmt='.2f')
plt.show()


yaroslav_analysis = yaroslav_full.copy()
yaroslav_analysis['year'] = yaroslav_full['date'].dt.year
yaroslav_analysis = yaroslav_analysis.groupby('year').agg({'total_volume':'sum', 'total_revenue':'sum'}).reset_index()

yaroslav_ipp = pd.merge(yaroslav_analysis, ipp_annual, on='year', how='inner')
yaroslav_ipp = yaroslav_ipp.drop(['ОКВЭД'], axis=1)
yaroslav_ipp

yaroslav_ipp_corr = yaroslav_ipp[['total_volume','total_revenue', 'ipp_index']].corr()
plt.figure(figsize=(10,8))
sns.heatmap(yaroslav_ipp_corr, annot=True, cmap='coolwarm')
plt.title('Матрица корреляции от ИПП')
plt.show()


combinde_data_yaroslav = pd.merge(yaroslav_analysis, ipp_pivoted, on='year', how='inner')
correlation_matrix = combinde_data_yaroslav.corr()
plt.figure(figsize=(14,10))
sns.heatmap(correlation_matrix, annot=True, cmap='coolwarm')
plt.title('Матрица корреляции')
plt.show()
Leave a Comment