CommencerCommencer gratuitement

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

Cet exercice fait partie du cours

Intermediate Python for Finance

Afficher le cours

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# 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)
Modifier et exécuter le code