MulaiMulai sekarang secara gratis

Plotting cash flow ratios

Sometimes, you might want to plot several line plots in one image. However, having too many lines in one plot will make it challenging to read. Making separate facets for every line is more elegant: the figure will look neat and more interpretable.

A pandas DataFrame plot_df has already been loaded for you. It has the columns "Year", "company","cash_flow_to_net_income" and "operating_cash_flow". Seaborn has been loaded with the alias sns.

Latihan ini adalah bagian dari kursus

Analyzing Financial Statements in Python

Lihat Kursus

Petunjuk latihan

  • Melt plot_dfto prepare it for plotting.
  • Use sns.relplot() to make a line plot of the cash flow to net income and operating cash flow ratio of Apple and Microsoft over time, with hue over the dimension of "Ratio".

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Melt the DataFrame to prepare for plotting
melt_data = plot_df.melt(____, var_name="Ratio")

# Plot your melted DataFrame
sns.relplot(data=____, x=____, y=____, col=____, kind=____, hue=____)

plt.show()
Edit dan Jalankan Kode