1. Учиться
  2. /
  3. Courses
  4. /
  5. Pythonで学ぶ財務諸表分析

Connected

Exercise

ファセットグリッドプロットを作成する

前の演習で、次のコードを書きました。

# Subset tech and fmcg companies
subset_dat = dataset.loc[dataset["comp_type"].isin(["tech", "fmcg"])]

# Compute yearly average gross margin ratio of tech and fmcg companies
subset_dat_avg = subset_dat.pivot_table(index=["Year", "comp_type"], values = "gross_margin").reset_index()

#Add column company
subset_dat_avg["company"] = np.where(subset_dat_avg["comp_type"]=="tech", "Avg tech", "Avg fmcg")

#Concat the DataFrames
plot_df = pd.concat([subset_dat, subset_dat_avg], axis=0)

このコードは、次のプロットを作成するためのデータ準備を行いました。 This plot shows the gross margin of tech companies, FMCG companies, the average tech company, and the average FMCG companies over many years.

それでは、実際にプロットを作成しましょう。

Инструкции

100 XP
  • DataFrame plot_df を使い、説明にあるファセットグリッドのプロットを seaborn で作成してください。