How to compare date (yyyy-mm-dd) with year-Quarter (yyyyQQ) in python
Once you are able to get the month out into a variable: mon
you can use the following code to get the quarter information:
for mon in range(1, 13):
  print (mon-1)//3 + 1,
print
which would return: 

for months 1 - 3    : 1
for months 4 - 6    : 2
for months 7 - 9    : 3
for months 10 - 12  : 4
I am writing a sql query using pandas within python. In the where clause I need to compare a date column (say review date 2016-10-21) with this value '2016Q4'. In other words if the review dates fall in or after Q4 in 2016 then they will be selected. Now how do I convert the review date to something comparable to 'yyyyQ4' format. Is there any python function for that ? If not, how so I go about writing one for this purpose ?