Filtering arrays
In this lesson, you will focus on two sectors:
- Information Technology
- Consumer Staples
numpy
is imported as np
and S&P 100 data is stored as arrays: names
, sectors
, and pe
(price to earnings ratio).
This exercise is part of the course
Introduction to Python for Finance
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Create boolean array
boolean_array = (____ 'Information Technology')
# Subset sector-specific data
it_names = ____
it_pe = ____
# Display sector names
print(it_names)
print(it_pe)