import quandl
import pandas as pd
# Specify tickers we want
tickers = ["fb aapl googl amzn nflx v ge tsla brk_b ko"]
# Make them all upper case, and individual items in a list
tickers = [tic.upper().split() for tic in tickers]
# Flatten the nested list
tickers = [tic for sublist in tickers for tic in sublist]
# Add "WIKI/" as a prefix and ".11" as a suffix to each ticker
tickers_quandl = ["WIKI/" + tic + '.11' for tic in tickers]
tickers_quandl
# Extract Adj. Close data for all stocks
prices_df = quandl.get(tickers_quandl, start_date="2009-01-01")
prices_df.head()
# Remove "WIKI/" and "Adj. Close" from each column
prices_df.rename(columns={col : col.split('/')[1].split()[0] for col in prices_df.columns},
inplace=True)
prices_df.head()