LoslegenKostenlos loslegen

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

Diese Übung ist Teil des Kurses

Introduction to Python for Finance

Kurs anzeigen

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# 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 bearbeiten und ausführen