Hello Q World,
If I get a DataFrame from history(),
how do I sort it by date?
According to
http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.sort.html
I do something like this:
sorted_prices = prices.sort(['A', 'B'], ascending=[1, 0])
So, I need to know the column names of the df.
google: How I get column names of python pandas dataframe?
ans: prices.columns.values
I tried that:
print(prices.columns.values)
I see:
[ Security(8554, symbol='SPY', security_name='SPDR S&P 500 ETF TRUST',
exchange='NYSE ARCA EXCHANGE', start_date=datetime.datetime(1993, 1,
29, 0, 0, tzinfo=), end_date=datetime.datetime(2014, 10, 27, 0,
0, tzinfo=), first_traded=None)]
Now I'm lost. Time to ask for help.
If I get a DataFrame from history(),
how do I sort it by date?