Median market capitalization by IPO year
In the last lesson of the previous chapter, you created a timeline for the number of IPOs per year for technology companies.
Let's now analyze how market capitalization has evolved for different IPO years. You can combine data from all three exchanges to get a more comprehensive view.
pandas as pd and matplotlib.pyplot as plt have been imported, and the listings DataFrame from previous exercises which now includes an added reference column 'exchange' that contains the exchange for each listed company, is available in your workspace.
Este exercício faz parte do curso
Importing and Managing Financial Data in Python
Instruções do exercício
- Inspect and display
listingsusing.info()and.head(). - Using broadcasting, create a new column
market_cap_mforlistingsthat contains the market cap in millions of USD. - Select all companies with an
'IPO Year'after 1985. - Drop all missing values in the
'IPO Year' column, and convert the remaining values todtypeinteger. - Group
listingsby'IPO Year', select themarket_cap_mcolumn and calculate themedian, sort with.sort_index(), and assign the result toipo_by_year. - Plot and show the results as a bar chart.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# Inspect listings
listings.____()
# Show listings head
print(listings.____())
# Create market_cap_m
listings['market_cap_m'] = ____[____].div(1e6)
# Select companies with IPO after 1985
listings = listings[____[____] > ____]
# Drop missing values and convert to integers
listings['IPO Year'] = ____[____].dropna().____(int)
# Calculate the median market cap by IPO Year and sort the index
ipo_by_year = listings.____(____).____.median().____()
# Plot results as a bar chart
ipo_by_year.plot(kind='bar')
# Show the plot
plt.show()