I have monthly data (1993 - 2019) but I am hoping to get the decimal format of only July, August, and September months from 1993 - 2019.
Below is the code for the months in decimal format between 1993 - 2019 (all 12 months) but hoping to get the same thing but just for July, August, and September months:
year_start = 1993
year_end = 2019
full_time_months = np.arange(year_start .5/12,year_end 1,1/12)
print(full_time_months[:12])
# these are the 12 months in 1993 as decimals
1993.04166667 1993.125 1993.20833333 1993.29166667 1993.375
1993.45833333 1993.54166667 1993.625 1993.70833333 1993.79166667
1993.875 1993.95833333
My goal is to just get an array of months july, august, and september:
1993.54167, 1993.625, 1993.708... 2019.54167 , 2019.625, 2019.708
where year.54167 = July, year.625 = August, and year.708 = September.
How might I go about doing this? Hope my question is clear enough, please comment if something is unclear, thank you!!!
CodePudding user response:
I'm not sure what you want to achieve with this, but you can do something like this, to separate the data you want.
import numpy as np
year_start = 1993
year_end = 2019
full_time_months = np.arange(year_start .5/12,year_end 1,1/12)
# Reshape into 2D array
full_time_months = full_time_months.reshape(-1, 12)
# Choose selected columns
# July, Aug, Sept
selected_months = full_time_months[:, [6,7,8]]
print(selected_months)
Results:
[[1993.54166667 1993.625 1993.70833333]
[1994.54166667 1994.625 1994.70833333]
...
[2018.54166667 2018.625 2018.70833333]
[2019.54166667 2019.625 2019.70833333]]