LoslegenKostenlos loslegen

Creating DataFrames

A security position is a record of ownership that includes the purchase price and date. This information is necessary if you want to calculate how much profit was made on a stock. You can have multiple positions of the same stock, if you purchase it multiple times. Use these positions of Apple stock to create DataFrames in this exercise:

Sym Price Date
APPL 105.00 2015/12/31
APPL 117.05 2017/12/01
APPL 289.80 2019/12/27

Diese Übung ist Teil des Kurses

Intermediate Python for Finance

Kurs anzeigen

Interaktive Übung

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

# Create dict holding the data
data = {'____': ['APPL', 'APPL', 'APPL'],
        '____': [105.00, 117.05, 289.80],
        '____': ['2015/12/31', '2017/12/01', '2019/12/27']}

# Create DataFrame from the data
positions = pd.____(data=____)
print(positions)
Code bearbeiten und ausführen