Aan de slagGa gratis aan de slag

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).

Deze oefening maakt deel uit van de cursus

Introduction to Python for Finance

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Create boolean array 
boolean_array = (____ 'Information Technology')

# Subset sector-specific data
it_names = ____
it_pe = ____

# Display sector names
print(it_names)
print(it_pe)
Code bewerken en uitvoeren