title: Convert Tz-aware datetime.datetime to datetime64/DatetimeIndex/Timestamp
body: <p>I am using a PostgreSQL database to store and retrieve data. The columns I get are:</p>
  <ol>
  <li>date : timestamp with timezone</li>
  <li>value: double precision</li>
  <li>type : character varying (approximate geographical location of the data)</li>
  <li>code: character varying (code related to the exact geographical location)</li>
  </ol>
  <p>This is how I get my data using <code>pd.read_sql_query</code>:</p>
  <pre><code>df     = pd.read_sql_query(&quot;SELECT date, value FROM my_db WHERE code ='%s' and type = '%s' and date &gt;= '%s' and date &lt;= '%s' ORDER BY date;&quot;
                              % (code, type, start_date, end_date), con=Cdc.engine, index_col=&quot;date&quot;)
  df[&quot;value&quot;].replace(to_replace=0, value=np.nan, inplace=True)  # replace 0 by NaN since 0 is an error in my data
  </code></pre>
  <p><strong>Then I try to do the following, and this is where I get my error:</strong></p>
  <pre><code>df = df[df.index.month.isin(wanted_month)]
  </code></pre>
  <p>Which returns me the error:</p>
  <pre><code>AttributeError: 'Index' object has no attribute 'month'
  </code></pre>
  <p><strong>1. I tried to fix this by doing:</strong></p>
  <pre><code>self.df_cdc.index = pd.to_datetime(self.df_cdc.index)
  </code></pre>
  <p>But it does not work since I get this error:</p>
  <pre><code>ValueError: Array must be all same time zone
  During handling of the above exception, another exception occurred:
  ValueError: Tz-aware datetime.datetime cannot be converted to datetime64 unless utc=True
  </code></pre>
  <p><strong>2. I also tried to do:</strong></p>
  <pre><code>df = df[df.index.dt.month.isin(wanted_month)]
  </code></pre>
  <p>But I get this error:</p>
  <pre><code>AttributeError: 'Index' object has no attribute 'dt'
  </code></pre>
  <p>Here is an example of the index values of my DF:</p>
  <pre><code>#   2019-12-30 21:10:00+01:00 --&gt; &lt;class 'datetime.datetime'&gt;
  #   2019-10-11 15:00:00+02:00 --&gt; &lt;class 'datetime.datetime'&gt;
  </code></pre>
  <p>Those are french data, so we have daylight saving time with +1 hour in winter and +2 in summer compared to UTC (e.g. : <code>winter: UTC = 10h00 --&gt; France = 11h00; summer: UTC = 10h00 --&gt; France = 12h00</code>).</p>
  <p>Displaying tzinfo gives me this :</p>
  <pre><code>print(df.index[0], &quot;--&gt;&quot;, df.index[0].tzinfo)
  print(df.index[15000], &quot;--&gt;&quot;, df.index[15000].tzinfo
  2019-01-01 00:00:00+01:00 --&gt; psycopg2.tz.FixedOffsetTimezone(offset=60, name=None)
  2019-04-15 05:00:00+02:00 --&gt; psycopg2.tz.FixedOffsetTimezone(offset=120, name=None)
  </code></pre>
  <p>Thank you for your attention.</p>
  <p><strong>EDIT: I found the solution and posted it below.</strong></p>