How to select rows of unique dates in DateTimeIndex - python

Suppose i have a DataFrame with DateTimeIndex like this:
Date_TimeOpen High Low Close Volume
2018-01-22 11:05:00 948.00 948.10 947.95 948.10 9820.0
2018-01-22 11:06:00 948.10 949.60 948.05 949.30 33302.0
2018-01-22 11:07:00 949.25 949.85 949.20 949.85 20522.0
2018-03-27 09:15:00 907.20 908.80 905.00 908.15 126343.0
2018-03-27 09:16:00 908.20 909.20 906.55 906.60 38151.0
2018-03-29 09:30:00 908.90 910.45 908.80 910.15 46429.0
I want to select only the first row of each Unique Date (discard Time) so that i get such output as below:
Date_Time Open High Low Close Volume
2018-01-22 11:05:00 948.00 948.10 947.95 948.10 9820.0
2018-03-27 09:15:00 907.20 908.80 905.00 908.15 126343.0
2018-03-29 09:30:00 908.90 910.45 908.80 910.15 46429.0
I tried with loc and iloc but it dint helped.
Any help will be greatly appreciated.

You need to group by date and get the first element of each group:
import pandas as pd
data = [['2018-01-22 11:05:00', 948.00, 948.10, 947.95, 948.10, 9820.0],
['2018-01-22 11:06:00', 948.10, 949.60, 948.05, 949.30, 33302.0],
['2018-01-22 11:07:00', 949.25, 949.85, 949.20, 949.85, 20522.0],
['2018-03-27 09:15:00', 907.20, 908.80, 905.00, 908.15, 126343.0],
['2018-03-27 09:16:00', 908.20, 909.20, 906.55, 906.60, 38151.0],
['2018-03-29 09:30:00', 908.90, 910.45, 908.80, 910.15, 46429.0]]
df = pd.DataFrame(data=data)
df = df.set_index([0])
df.columns = ['Open', 'High', 'Low', 'Close', 'Volume']
result = df.groupby(pd.to_datetime(df.index).date).head(1)
print(result)
Output
Open High Low Close Volume
0
2018-01-22 11:05:00 948.0 948.10 947.95 948.10 9820.0
2018-03-27 09:15:00 907.2 908.80 905.00 908.15 126343.0
2018-03-29 09:30:00 908.9 910.45 908.80 910.15 46429.0

Related

Join in Pandas dataframe (Auto conversion from date to date-time?)

I tried to use the join function to combine the close price of all 500 stocks in 5 year period (2013-02-08 to 2018-02-07), where each column represent a stock, with the index of the dataframe being the dates.
But the join function in pandas seems to automatically change the date format (index), rendering all the entries in the combined dataframe to be NaN.
The code to import and preview the file:
import pandas as pd
df= pd.read_csv('all_stocks_5yr.csv')
df.head()
(https://i.stack.imgur.com/29Wq4.png)
# df.info()
df['Name'].unique().shape #There are 505 stock names in total
# dates = pd.date_range(df['date'].min(), df['date'].max()) #check the date range
Single out the close prices:
close_prices = pd.DataFrame(index=dates) #Make the index column to be the dates
# close_prices.head()
symbols = df['Name'].unique(). #Denote the stock names as an array
So I tried to test the result for each stock using the first 3 stocks:
i = 1
for symbol in symbols:
df_sym = df[df['Name']==symbol]
df_tmp = pd.DataFrame(data=df_sym['close'].to_numpy() , index = df_sym['date'], columns=[symbol])
print(df_tmp) #print the temporary dataframes
i += 1
if i >3: break
And the results were expected, a dataframe indexed by date and only one stock:
AAL
date
2013-02-08 14.75
2013-02-11 14.46
2013-02-12 14.27
2013-02-13 14.66
2013-02-14 13.99
... ...
2018-02-01 53.88
2018-02-02 52.10
2018-02-05 49.76
2018-02-06 51.18
2018-02-07 51.40
[1259 rows x 1 columns]
AAPL
date
2013-02-08 67.8542
2013-02-11 68.5614
2013-02-12 66.8428
2013-02-13 66.7156
2013-02-14 66.6556
... ...
2018-02-01 167.7800
2018-02-02 160.5000
2018-02-05 156.4900
2018-02-06 163.0300
2018-02-07 159.5400
[1259 rows x 1 columns]
...
Now here's part I find very confusing: I checked what happens when combining first 3 stock dataframes using join function, with index 'date':
i = 1
for symbol in symbols:
df_sym = df[df['Name']==symbol]
df_tmp = pd.DataFrame(data=df_sym['close'].to_numpy() , index = df_sym['date'], columns=[symbol])
close_prices = close_prices.join(df_tmp)
i += 1
if i >3: break
close_prices.head()
(https://i.stack.imgur.com/MqVDo.png)
Somehow the index changed from date to date-time format, and therefore naturally "join" function will recognize that none of the entries matches with the new index, and automatically put a NA there for every single entry.
What caused the date to have changed to date-time?
You can use pivot:
df = pd.read_csv('all_stocks_5yr.csv')
out = df1.pivot(index='date', columns='Name', values='close')
Output:
>>> df.iloc[:, :8]
Name A AAL AAP AAPL ABBV ABC ABT ACN
date
2013-02-08 45.08 14.75 78.90 67.8542 36.25 46.89 34.41 73.31
2013-02-11 44.60 14.46 78.39 68.5614 35.85 46.76 34.26 73.07
2013-02-12 44.62 14.27 78.60 66.8428 35.42 46.96 34.30 73.37
2013-02-13 44.75 14.66 78.97 66.7156 35.27 46.64 34.46 73.56
2013-02-14 44.58 13.99 78.84 66.6556 36.57 46.77 34.70 73.13
... ... ... ... ... ... ... ... ...
2018-02-01 72.83 53.88 117.29 167.7800 116.34 99.29 62.18 160.46
2018-02-02 71.25 52.10 113.93 160.5000 115.17 96.02 61.69 156.90
2018-02-05 68.22 49.76 109.86 156.4900 109.51 91.90 58.73 151.83
2018-02-06 68.45 51.18 112.20 163.0300 111.20 91.54 58.86 154.69
2018-02-07 68.06 51.40 109.93 159.5400 113.62 94.22 58.67 155.15
[1259 rows x 8 columns]
Source 'all_stocks_5yr.csv': Kaggle

How to index out open and close in pandas datetime dataframe?

Okay so I have a csv with minute data for the S&P 500 index for 2020, and I am looking how to index out only the close and open for 9:30 and 4:00 only. In essence I just want what the market open and close was. So far the code is:
import pandas as pd
import datetime as dt
import numpy as np
d = pd.read_csv('/Volumes/Seagate Portable/usindex_2020_all_tickers_awvbxk9/SPX_2020_2020.txt')
d.columns = ['Dates', 'Open', 'High', 'Low', 'Close']
d.drop(['High', 'Low'], axis=1, inplace=True)
d.set_index('Dates', inplace=True)
d.head()
It wont let me share the csv file but this is what the output looks like:
Open Close
Dates
2020-01-02 09:31:00 3247.19 3245.22
2020-01-02 09:32:00 3245.07 3244.66
2020-01-02 09:33:00 3244.89 3247.61
2020-01-02 09:34:00 3247.38 3246.92
2020-01-02 09:35:00 3246.89 3249.09
I have tried using loc and dt.time, which I am assmuning is the right way to code I just cannot think of the exact code to index out these 2 times. Any ideas? Thank you!
If the .dt extractor is used on the 'Dates' column (d.Dates.dt.time[0]), the .time component is datetime.time(9, 30), therefore d.Dates.dt.time == dtime(9, 30) must be used for the Boolean match, and not d.Dates.dt.time == '09:30:00'
import pandas as pd
from datetime import time as dtime
# test dataframe
d = pd.DataFrame({'Dates': ['2020-01-02 09:30:00', '2020-01-02 09:31:00', '2020-01-02 09:32:00', '2020-01-02 09:33:00', '2020-01-02 09:34:00', '2020-01-02 09:35:00', '2020-01-02 16:00:00'], 'Open': [3247.19, 3247.19, 3245.07, 3244.89, 3247.38, 3246.89, 3247.19], 'Close': [3245.22, 3245.22, 3244.66, 3247.61, 3246.92, 3249.09, 3245.22]})
# display(d)
Dates Open Close
0 2020-01-02 09:30:00 3247.19 3245.22
1 2020-01-02 09:31:00 3247.19 3245.22
2 2020-01-02 09:32:00 3245.07 3244.66
3 2020-01-02 09:33:00 3244.89 3247.61
4 2020-01-02 09:34:00 3247.38 3246.92
5 2020-01-02 09:35:00 3246.89 3249.09
6 2020-01-02 16:00:00 3247.19 3245.22
# verify Dates is a datetime format
d.Dates = pd.to_datetime(d.Dates)
# use Boolean selection for 9:30 and 16:00 (4pm)
d = d[(d.Dates.dt.time == dtime(9, 30)) | (d.Dates.dt.time == dtime(16, 0))].copy()
# set the index
d.set_index('Dates', inplace=True)
# display(d)
Open Close
Dates
2020-01-02 09:30:00 3247.19 3245.22
2020-01-02 16:00:00 3247.19 3245.22
Try:
import pandas as pd
# create dummy daterange
date_range = pd.DatetimeIndex(pd.date_range("00:00", "23:59", freq='1min'))
# create df with enumerated column as data, and with daterange(DatetimeIndex) as index
df = pd.DataFrame(data=[i for i, d in enumerate(date_range)], index=date_range)
# boolean index using strings
four_and_nine = df[(df.index == '16:00:00') | (df.index == '21:00:00')]
print(four_and_nine)
0
2021-01-01 16:00:00 960
2021-01-01 21:00:00 1260
Pandas is pretty smart with comparing strings to actual datetimes(DatetimeIndex in this case).
Above is selecting top of the hour. If you wanted all minutes/seconds within specific hours, use boolean index like: df[(df.index.hour == 4) | (df.index.hour == 9)]

Finding max day of the month and year in a list of pandas DataFrame

I'm trying to get the last day from a month, but it's returning just one year. I need to get all records from all years. Any suggestions?
import pandas as pd
import numpy as np
df = pd.read_csv('PETR4_BOV_D_cor.csv', engine='c', skiprows=1, parse_dates=['date'], names=['ticker', 'date', 'trades', 'close', 'low', 'high', 'open', 'vol', 'qty', 'avg'])
df.date = pd.to_datetime(df.date)
df = df.set_index('date')
Result
ticker trades close low high open vol qty avg
date
2015-05-29 PETR4 44895 11.577403 11.577403 11.999936 11.934209 901139500.0 72120400 11.732238
2015-06-01 PETR4 31861 11.614961 11.502286 11.877871 11.671299 489916746.0 39483500 11.650736
2015-06-02 PETR4 47249 12.056274 11.708858 12.159559 11.783975 582467511.0 45754100 11.953363
2015-06-03 PETR4 37454 12.046884 11.943598 12.300404 12.168949 629815443.0 48703400 12.142376
2015-06-05 PETR4 34917 11.793364 11.661910 11.999936 11.812143 452516624.0 36024200 11.794773
2016-12-23 PETR4 23100 13.370821 13.154859 13.474106 13.192418 309168316.0 21776900 13.330539
2016-12-26 PETR4 4840 13.539834 13.398989 13.568003 13.445938 82501537.0 5734300 13.509224
2016-12-27 PETR4 13617 13.530444 13.389600 13.661899 13.614951 215534672.0 14949200 13.537768
2016-12-28 PETR4 20265 13.877860 13.483496 13.906029 13.549223 277762881.0 18979900 13.741335
2016-12-29 PETR4 19721 13.962367 13.633730 13.971756 13.943587 266439891.0 18090600 13.829128
395 rows × 9 columns
Groupby
df.groupby(df.index.month).apply(pd.Series.tail, 1).reset_index(level=0, drop=True)
Return
ticker trades close low high open vol qty avg
date
2016-01-29 PETR4 64685 4.544577 4.244109 4.563356 4.413122 4.398262e+08 93013900 4.439976
2016-02-29 PETR4 36334 4.826265 4.676031 4.910772 4.769928 4.312967e+08 84165000 4.811617
2016-03-31 PETR4 44127 7.840334 7.690100 8.103243 7.849723 5.834259e+08 69529900 7.878831
2016-04-29 PETR4 39767 9.605582 9.399011 9.849713 9.774596 5.482716e+08 53536700 9.615911
2016-05-31 PETR4 56676 7.549255 7.549255 8.046905 7.849723 4.804290e+08 58131400 7.760052
2016-06-30 PETR4 19998 8.845023 8.676010 8.910751 8.845023 4.090867e+08 43553100 8.819483
2016-07-29 PETR4 44681 11.145480 10.901350 11.248766 11.042195 7.142205e+08 60478800 11.088579
2016-08-31 PETR4 45622 12.065663 11.934209 12.413079 12.328573 7.848222e+08 60716500 12.137024
2016-09-30 PETR4 28869 12.741716 12.619651 12.929508 12.704157 5.284275e+08 38771900 12.797209
2016-10-31 PETR4 48694 16.610240 16.535123 17.060942 16.929487 7.480264e+08 42059100 16.699535
2016-11-30 PETR4 57759 15.023394 14.657199 15.201797 14.929498 1.316175e+09 82547300 14.971282
2016-12-29 PETR4 19721 13.962367 13.633730 13.971756 13.943587 2.664399e+08 18090600 13.829128
Tks #Ch3steR and David.
I changed the code like the David sample and separate the month and year in a new columns to sort the data.
import pandas as pd
import numpy as np
df = pd.read_csv('PETR4_BOV_D_cor.csv', engine='c', skiprows=1, parse_dates=['date'], names=['ticker', 'date', 'trades', 'close', 'low', 'high', 'open', 'vol', 'qty', 'avg'])
df['year'] = pd.DatetimeIndex(df.date).year
df['month'] = pd.DatetimeIndex(df.date).month
df.date = pd.to_datetime(df.date)
df = df.set_index('date')
result = df.groupby([df.index.month, df.index.year]).apply(pd.Series.tail, 1).reset_index(level=0, drop=True)
sorted = result.sort_values(['year', 'month'])
Result
ticker trades close low high open vol qty avg year month
date date
2015 2015-05-29 PETR4 44895 11.577403 11.577403 11.999936 11.934209 9.011395e+08 72120400 11.732238 2015 5
2015-06-30 PETR4 41060 11.934209 11.877871 12.197118 12.112611 4.078387e+08 31922400 11.996086 2015 6
2015-07-31 PETR4 38481 9.859102 9.690089 10.046895 9.840323 3.838792e+08 36465800 9.884548 2015 7
2015-08-31 PETR4 64015 8.629062 7.999957 8.722958 8.178360 6.765446e+08 75379100 8.427373 2015 8
2015-09-30 PETR4 77202 6.798086 6.544566 6.816865 6.807475 7.660222e+08 107245600 6.706725 2015 9
... ... ... ... ... ... ... ... ... ... ... ... ...
2020 2020-02-28 PETR4 109660 25.340000 24.620000 25.560000 25.160000 2.230362e+09 89095300 25.033400 2020 2
2020-03-31 PETR4 169315 13.990000 13.600000 14.540000 13.600000 2.180450e+09 155314800 14.038900 2020 3
2020-04-30 PETR4 80537 18.050000 17.700000 18.420000 17.980000 1.433551e+09 79395500 18.055800 2020 4
2020-05-29 PETR4 85912 20.340000 19.300000 20.340000 19.550000 2.528730e+09 127224200 19.876200 2020 5
2020-06-02 PETR4 99499 21.400000 20.600000 21.400000 20.750000 1.592479e+09 76091600 20.928500 2020 6

Find difference between dates pandas using loc function

I have this dataframe
open high low close volume
TimeStamp
2017-12-22 13:15:00 12935.00 13200.00 12508.71 12514.91 244.728611
2017-12-22 13:30:00 12514.91 12999.99 12508.71 12666.34 150.457869
2017-12-22 13:45:00 12666.33 12899.97 12094.00 12094.00 198.680014
2017-12-22 14:00:00 12094.01 12354.99 11150.00 11150.00 256.812634
2017-12-22 14:15:00 11150.01 12510.00 10400.00 12276.33 262.217127
I want to know if every rows have exactly 15 minutes diference in time
So I build a new column with a shift of the first columns
open high low close volume \
TimeStamp
2017-12-20 13:30:00 17503.98 17600.00 17100.57 17119.89 312.773644
2017-12-20 13:45:00 17119.89 17372.98 17049.00 17170.00 322.953671
2017-12-20 14:00:00 17170.00 17573.00 17170.00 17395.74 236.085829
2017-12-20 14:15:00 17395.74 17398.00 17200.01 17280.00 220.467382
2017-12-20 14:30:00 17280.00 17313.94 17150.00 17256.05 222.760598
new_time
TimeStamp
2017-12-20 13:30:00 2017-12-20 13:45:00
2017-12-20 13:45:00 2017-12-20 14:00:00
2017-12-20 14:00:00 2017-12-20 14:15:00
2017-12-20 14:15:00 2017-12-20 14:30:00
2017-12-20 14:30:00 2017-12-20 14:45:00
Now I want to locate every row that don't respect the 15minutes diference rule so I did
dfh.loc[(dfh['new_time'].to_pydatetime()-dfh.index.to_pydatetime())>datetime.timedelta(0, 900)]
I get this error,
Traceback (most recent call last):
File "<pyshell#252>", line 1, in <module>
dfh.loc[(dfh['new_time'].to_pydatetime()-dfh.index.to_pydatetime())>datetime.timedelta(0, 900)]
File "C:\Users\Araujo\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\core\generic.py", line 3614, in __getattr__
return object.__getattribute__(self, name)
AttributeError: 'Series' object has no attribute 'to_pydatetime'
Is there any way of do this?
EDIT:
Shift just works with periodic, there is any way of do this with non periodic?
This would work:
import pandas as pd
import numpy as np
import datetime as dt
data = [
['2017-12-22 13:15:00', 12935.00, 13200.00, 12508.71, 12514.91, 244.728611],
['2017-12-22 13:30:00', 12514.91, 12999.99, 12508.71, 12666.34, 150.457869],
['2017-12-22 13:45:00', 12666.33, 12899.97, 12094.00, 12094.00, 198.680014],
['2017-12-22 14:00:00', 12094.01, 12354.99, 11150.00, 11150.00, 256.812634],
['2017-12-22 14:15:00', 11150.01, 12510.00, 10400.00, 12276.33, 262.217127]
]
df = pd.DataFrame(data, columns = ['Timestamp', 'open', 'high', 'low', 'close', 'volume'])
df['Timestamp'] = pd.to_datetime(df['Timestamp'])
df['plus_15'] = df['Timestamp'].shift(1) + dt.timedelta(minutes = 15)
df['valid_time'] = np.where((df['Timestamp'] == df['plus_15']) | (df.index == 0), 1, 0)
print(df[['Timestamp', 'valid_time']])
#output
Timestamp valid_time
0 2017-12-22 13:15:00 1
1 2017-12-22 13:30:00 1
2 2017-12-22 13:45:00 1
3 2017-12-22 14:00:00 1
4 2017-12-22 14:15:00 1
So create a new column, plus 15, that looks at the previous timestamp and adds 15 minutes to it. Then create another column, valid time, which compares the timestamp column to the plus 15 column, and marks 1 when they are equal and 0 when they are not.
Can we do something like this?
import pandas as pd
import numpy as np
data = '''\
TimeStamp open high low close volume
2017-12-22T13:15:00 12935.00 13200.00 12508.71 12514.91 244.728611
2017-12-22T13:30:00 12514.91 12999.99 12508.71 12666.34 150.457869
2017-12-22T13:45:00 12666.33 12899.97 12094.00 12094.00 198.680014
2017-12-22T14:00:00 12094.01 12354.99 11150.00 11150.00 256.812634
2017-12-22T14:15:00 11150.01 12510.00 10400.00 12276.33 262.217127'''
df = pd.read_csv(pd.compat.StringIO(data),
sep='\s+', parse_dates=['TimeStamp'], index_col=['TimeStamp'])
df['new_time'] = df.index[1:].tolist()+[np.NaN]
# df['new_time'] = np.roll(df.index, -1) # if last is not first+15min
# use boolean indexing to filter away unwanted rows
df[[(dt2-dt1)/np.timedelta64(1, 's') == 900
for dt1,dt2 in zip(df.index.values,df.new_time.values)]]

Concatenate several stock price dataframes

I am getting monthly price data from yahoo with pandas_datareader like this:
import pandas_datareader.data as web
fb = web.get_data_yahoo('FB', '06/01/2012', interval='m')
amzn = web.get_data_yahoo('AMZN', '06/01/2012', interval='m')
nflx = web.get_data_yahoo('NFLX', '06/01/2012', interval='m')
goog = web.get_data_yahoo('GOOG', '06/01/2012', interval='m')
Which I then clean up to get the closing price like this:
import pandas as pd
amzn = amzn.rename(columns={'Adj Close': 'AMZN'})
amzn = pd.DataFrame(amzn['AMZN'], columns=['AMZN'])
Repeating the clean up for all four dataframes. With this done I want to merge these four data frames together. To do this I am using:
data = pd.concat([fb, amzn, nlfx, goog])
However this results in a dataframe where only three out of four columns data is NaN. I have verified that the dates match up. Why is this happening? Any insight is appreciated.
There is a better approach - use Pandas.Panel:
In [20]: p = web.get_data_yahoo(['FB','AMZN','NFLX','GOOG'], '06/01/2012', interval='m')
In [21]: p.loc['Adj Close']
Out[21]:
AMZN FB GOOG NFLX
Date
2012-06-01 228.350006 31.100000 289.745758 9.784286
2012-07-02 233.300003 21.709999 316.169373 8.121428
2012-08-01 248.270004 18.059999 342.203369 8.531428
2012-09-04 254.320007 21.660000 376.873779 7.777143
2012-10-01 232.889999 21.110001 339.810760 11.320000
2012-11-01 252.050003 28.000000 348.836761 11.672857
2012-12-03 250.869995 26.620001 353.337280 13.227143
2013-01-02 265.500000 30.980000 377.468170 23.605715
2013-02-01 264.269989 27.250000 400.200500 26.868572
2013-03-01 266.489990 25.580000 396.698975 27.040001
2013-04-01 253.809998 27.770000 411.873840 30.867144
2013-05-01 269.200012 24.350000 435.175598 32.321430
2013-06-03 277.690002 24.879999 439.746002 30.155714
2013-07-01 301.220001 36.799999 443.432343 34.925713
2013-08-01 280.980011 41.290001 423.027710 40.558571
2013-09-03 312.640015 50.230000 437.518250 44.172855
2013-10-01 364.029999 50.209999 514.776123 46.068573
2013-11-01 393.619995 47.009998 529.266602 52.257141
2013-12-02 398.790009 54.650002 559.796204 52.595715
2014-01-02 358.690002 62.570000 589.896118 58.475716
2014-02-03 362.100006 68.459999 607.218811 63.661430
2014-03-03 336.369995 60.240002 556.972473 50.290001
2014-04-01 304.130005 59.779999 526.662415 46.005714
2014-05-01 312.549988 63.299999 559.892578 59.689999
2014-06-02 324.779999 67.290001 575.282593 62.942856
... ... ... ... ...
2015-02-02 380.160004 78.970001 558.402527 67.844284
2015-03-02 372.100006 82.220001 548.002441 59.527142
2015-04-01 421.779999 78.769997 537.340027 79.500000
2015-05-01 429.230011 79.190002 532.109985 89.151428
2015-06-01 434.089996 85.769997 520.510010 93.848572
2015-07-01 536.150024 94.010002 625.609985 114.309998
2015-08-03 512.890015 89.430000 618.250000 115.029999
2015-09-01 511.890015 89.900002 608.419983 103.260002
2015-10-01 625.900024 101.970001 710.809998 108.379997
2015-11-02 664.799988 104.239998 742.599976 123.330002
2015-12-01 675.890015 104.660004 758.880005 114.379997
2016-01-04 587.000000 112.209999 742.950012 91.839996
2016-02-01 552.520020 106.919998 697.770020 93.410004
2016-03-01 593.640015 114.099998 744.950012 102.230003
2016-04-01 659.590027 117.580002 693.010010 90.029999
2016-05-02 722.789978 118.809998 735.719971 102.570000
2016-06-01 715.619995 114.279999 692.099976 91.480003
2016-07-01 758.809998 123.940002 768.789978 91.250000
2016-08-01 769.159973 126.120003 767.049988 97.449997
2016-09-01 837.309998 128.270004 777.289978 98.550003
2016-10-03 789.820007 130.990005 784.539978 124.870003
2016-11-01 750.570007 118.419998 758.039978 117.000000
2016-12-01 749.869995 115.050003 771.820007 123.800003
2017-01-03 823.479980 130.320007 796.789978 140.710007
2017-02-01 807.640015 132.059998 801.340027 140.970001
[57 rows x 4 columns]
Panel axes:
In [22]: p.axes
Out[22]:
[Index(['Open', 'High', 'Low', 'Close', 'Volume', 'Adj Close'], dtype='object'),
DatetimeIndex(['2012-06-01', '2012-07-02', '2012-08-01', '2012-09-04', '2012-10-01', '2012-11-01', '2012-12-03', '2013-01-02', '2013-02-01'
, '2013-03-01', '2013-04-01', '2013-05-01', '2013-06-03',
'2013-07-01', '2013-08-01', '2013-09-03', '2013-10-01', '2013-11-01', '2013-12-02', '2014-01-02', '2014-02-03', '2014-03-03'
, '2014-04-01', '2014-05-01', '2014-06-02', '2014-07-01',
'2014-08-01', '2014-09-02', '2014-10-01', '2014-11-03', '2014-12-01', '2015-01-02', '2015-02-02', '2015-03-02', '2015-04-01'
, '2015-05-01', '2015-06-01', '2015-07-01', '2015-08-03',
'2015-09-01', '2015-10-01', '2015-11-02', '2015-12-01', '2016-01-04', '2016-02-01', '2016-03-01', '2016-04-01', '2016-05-02'
, '2016-06-01', '2016-07-01', '2016-08-01', '2016-09-01',
'2016-10-03', '2016-11-01', '2016-12-01', '2017-01-03', '2017-02-01'],
dtype='datetime64[ns]', name='Date', freq=None),
Index(['AMZN', 'FB', 'GOOG', 'NFLX'], dtype='object')]

Categories