Skip to content

Introduction to Portofolio Returns

Use this workspace to take notes, store code snippets, or build your own interactive cheatsheet! For courses that use data, the datasets will be available in the datasets folder.

# Import any packages you want to use here
import pandas as pd

Open CSV data. parse dates and sort by date

import pandas as pd

StockPrices = pd.read_csv('datasets/MSFTPrices.csv', parse_dates=['Date'])
StockPrices = StockPrices.sort_values(by='Date')
print(df.head())
#Calculate dailu returns of the adjusted price change
StockPrices = StockPrices['Adjusted'].pct_change()
StockPrices.head()