title: TypeError: '>=' not supported between instances of 'datetime.date' and 'str'
body: <p>My pandas <code>df3</code> looks like this:</p>
  <pre><code>df3 = pd.DataFrame([['23.02.2012', '23.02.2012', 'aaa'], ['27.02.2014', '27.02.2014', 'bbb'], ['17.08.2018', '17.08.2018', 'ccc'], ['22.07.2019', '22.07.2019', 'ddd']], columns=['date', 'period', 'text'])
  </code></pre>
  <p>I want to make column <code>period</code> display the following periods if the dates correspond. Since some <code>date</code> values were formatted with timestamp and some not, it didnt create the correct (without timestamp) <code>period</code> values. That is why i did <code>df3['question_date'].dt.date</code></p>
  <pre><code>df3['date'] = pd.to_datetime(df3['date'], errors = 'coerce')
  df3['question_date'] = df3['question_date']
  df3['period'] = df3['date']
  col_name = 'period'
  strt_col = df3.pop(col_name)
  df3.insert(5, col_name, strt_col)
  
  date1 = pd.Timestamp('1990-10-14').date()
  date2 = pd.Timestamp('1994-11-10').date()
  date3 = pd.Timestamp('1999-10-1').date()
  date4 = pd.Timestamp('2004-6-13').date()
  date5 = pd.Timestamp('2009-8-30').date()
  date6 = pd.Timestamp('2014-10-14').date()
  date7 = pd.Timestamp('2019-11-26').date()
  date8 = pd.Timestamp('2021-9-20').date()
  mask1 = (df3['question_date'] &gt;= 'date1') &amp; (df3['question_date'] &lt; 'date2')
  mask2 = (df3['question_date'] &gt;= 'date2') &amp; (df3['question_date'] &lt; 'date3')
  mask3 = (df3['question_date'] &gt;= 'date3') &amp; (df3['question_date'] &lt; 'date4')
  mask4 = (df3['question_date'] &gt;= 'date4') &amp; (df3['question_date'] &lt; 'date5')
  mask5 = (df3['question_date'] &gt;= 'date5') &amp; (df3['question_date'] &lt; 'date6')
  mask6 = (df3['question_date'] &gt;= 'date6') &amp; (df3['question_date'] &lt; 'date7')
  mask7 = (df3['question_date'] &gt;= 'date7') &amp; (df3['question_date'] &lt; 'date8')
  df3.loc[mask1, 'leg_per'] = '1990-1994'
  df3.loc[mask2, 'leg_per'] = '1994-1999'
  df3.loc[mask3, 'leg_per'] = '1999-2004'
  df3.loc[mask4, 'leg_per'] = '2004-2009'
  df3.loc[mask5, 'leg_per'] = '2009-2014'
  df3.loc[mask6, 'leg_per'] = '2014-2019'
  df3.loc[mask7, 'leg_per'] = '2019-2021'
  .
  .
  .
  </code></pre>
  <p>At <code>mask1</code> it throws error</p>
  <pre><code>TypeError: '&gt;=' not supported between instances of 'datetime.date' and 'str'
  </code></pre>
  <p>Original question: <a href="https://stackoverflow.com/questions/69358058/preventing-timestamp-creation-in-to-datetime-formatting-in-order-to-group-by-d">preventing timestamp creation in to_datetime() formatting in order to group by periods</a></p>