text: Q:
  
  How can I generate a random day of the year in a specified year quarter with python?
  
  Let's suppose in a pandas dataframe I have for a certain record:
  x.index.quarter
  
  is 3
  I need to generate an integer from 1 to 365 as day of the year, that would belong to the same quarter.
  How does pandas decide the year quarter? Is there a mathematical formula? Does it depends only on the months?
  
  A:
  
  Numbering the days of the year from 0 to 364, you can find the quarter interval with
  q = 3 # Quarter index from 0 to 3
  q_length = int(365/4) # 91, length of the quarter 
  d_min = q*q_length
  d_max = (q+1)*q_length
  
  Then find a random day of the year within that quarter using:
  d = np.random.randint(d_min, d_max)
  
  Just change q for x.index.quarter.
  
  