Advertisement
korenizla

Untitled

Sep 14th, 2022
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.35 KB | None | 0 0
  1. actual_platforms = ["pc", "xone", "3ds"]
  2.  
  3. for platform in actual_platforms:
  4.     data = game_stat_actual.query("platform == @platform")[["critic_score","user_score","total_sales"]]
  5.     Q1, Q3 = data["total_sales"].quantile([0.25, 0.75])
  6.     IQR = Q3-Q1
  7.     data = data.query("@Q1-1.5*@IQR <= total_sales <= @Q3+1.5*@IQR")
  8.    
  9.     labels = ["Оценки критиков", "Оценки пользователей", "Продажи"]
  10.     display(data.corr().round(2).set_axis(labels, axis=1, inplace=False).set_axis(labels, axis=0, inplace=False).rename_axis(platform.upper(), axis=0, inplace=False))
  11.    
  12.     line_kws = {"color": "r"}
  13.     scatter_kws = {"alpha":0.5, "color": "w", "edgecolors":"blue"}
  14.     plot_kws = {"scatter_kws": scatter_kws, "line_kws":line_kws}
  15.  
  16.     diag_kws = {"color": "blue"}
  17.  
  18.     g = sns.pairplot(data=data.dropna(), kind="reg", plot_kws=plot_kws, diag_kws=diag_kws)
  19.     plt.gcf().set_size_inches(16,8)
  20.  
  21.     font_size = 14
  22.     labels = ["Оценки критиков", "Оценки пользователей", "Продажи"]
  23.  
  24.     for ax1, ax2, label in zip(g.axes.ravel(order="F"), g.axes[::-1].ravel(order="C"), labels):
  25.         ax1.set_ylabel(label, fontsize=font_size)
  26.         ax2.set_xlabel(label, fontsize=font_size)
  27.  
  28.     g.fig.subplots_adjust(hspace=0.02, wspace=0.01)
  29.     g.fig.suptitle(platform.upper(), fontsize=20)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement