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 |
This exercise is part of the course
Intermediate Python for Finance
Hands-on interactive exercise
Have a go at this exercise by completing this sample 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)