Python for Finance: Analyze Big Financial Data

(Elle) #1
In  [ 25 ]: df.index    =   dates
df
Out[25]: No1 No2 No3 No4
2015-01-31 -0.737304 1.065173 0.073406 1.301174
2015-02-28 -0.788818 -0.985819 0.403796 -1.753784
2015-03-31 -0.155881 -1.752672 1.037444 -0.400793
2015-04-30 -0.777546 1.730278 0.417114 0.184079
2015-05-31 -1.763660 -0.375469 0.098678 -1.553824
2015-06-30 -1.134258 1.401821 1.227124 0.979389
2015-07-31 0.458838 -0.143187 1.565701 -2.085863
2015-08-31 -0.103058 -0.366170 -0.478036 -0.032810
2015-09-30 1.040318 -0.128799 0.786187 0.414084

When it comes to the generation of DatetimeIndex objects with the help of the


date_range function, there are a number of choices for the frequency parameter freq.


Table 6-3 lists all the options.


Table 6-3. Frequency parameter values for date_range function


Alias Description

B

Business day frequency

C

Custom business day frequency (experimental)

D

Calendar day frequency

W

Weekly frequency

M

Month end frequency

BM

Business month end frequency

MS

Month start frequency

BMS

Business month start frequency

Q

Quarter end frequency

BQ

Business quarter end frequency

QS

Quarter start frequency

BQS

Business quarter start frequency
Free download pdf