Plot IPO timeline for all exchanges using countplot()
To create a basic visualization of the number of observations per category in a dataset, the seaborn
countplot()
function is usually the way to go:
seaborn.countplot(x=None, hue=None, data=None, ...)
The x
parameter contains the names of the variables in the data
argument, which is the DataFrame to be plotted. hue
identifies an additional categorical variable with color. These are three optional parameters out of many accepted by the function; for a full list, check out the seaborn
documentation.
Let's use this tool to compare the timeline of IPO activity across the three exchanges. pandas
as pd
, matplotlib.pyplot
as plt
, and seaborn
as sns
have been imported, and the listings
DataFrame with reference column 'Exchange'
is available in your workspace.
Este ejercicio forma parte del curso
Importing and Managing Financial Data in Python
Instrucciones del ejercicio
- Filter
listings
to only include IPO years after the year 2000. - Convert the data in the column
'IPO Year'
to integers. - Plot a
sns.countplot()
oflistings
using'IPO Year'
as thex
variable and'Exchange'
forhue
. - Rotate the
xticks()
by 45 degrees and show the result.
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
# Select IPOs after 2000
listings = listings[____[____] > ____]
# Convert IPO Year to integer
listings['IPO Year'] = ____[____].____(____)
# Create a countplot
sns.countplot(x=____, hue=____, data=____)
# Rotate xticks and show result
plt.xticks(rotation=45)
# Show the plot
plt.show()