Visualizing financial ratios for comparison

Analyzing Financial Statements in Python

Rohan Chatterjee

Risk Modeler

Plotting the ratios of two companies

sns.set_style("whitegrid")
ax = sns.lineplot(data=current_ratio,
        x="Year",y='current_ratio',
        hue="company", alpha=0.7)
plt.xlabel("Year")
plt.ylabel("Current Ratio")

This image shows the current ratio of the Coca-cola company and Pepsico from the years 2008 to 2020.

Analyzing Financial Statements in Python

Overcrowding when using sns.lineplot()

This graph has too much information in too little space, making it overcrowded This image shows the debt-to-equity, current ratio, quick ratio and gross margin of the Coca-cola company and Pepsico in one image. The image is very crowded.

Analyzing Financial Statements in Python

Introducing sns.relplot()

  • First step is to melt the DataFrame to get longitudinal data.

  • The "unmelted" DataFrame:

plot_df.head()

The image shows a wide DataFrame.

Analyzing Financial Statements in Python

Now, melt the DataFrame

plot_df_melt = plot_df.melt(id_vars = ['company','Year'], var_name = "Ratio")

The image shows the top few rows of a molten DataFrame.

Analyzing Financial Statements in Python

Plot ratios using sns.relplot()

ax = sns.relplot(data=df_melt, x="Year",
                 y="value", hue="Ratio",
                 alpha=0.7,
                 col='company',
                 kind='line')
ax.set_ylabels('')
ax.set_xlabels('')

This image shows the debt-to-equity, current ratio, quick ratio and gross margin of the Coca-cola company and Pepsico. Where the ratio of the two companies are in two different panes.

Analyzing Financial Statements in Python

A closer look at the plot

This image shows the debt-to-equity, current ratio, quick ratio and gross margin of the Coca-cola company and Pepsico. Where the ratio of the two companies are in two different panes.

Analyzing Financial Statements in Python

Let's practice!

Analyzing Financial Statements in Python

Preparing Video For Download...